Skip to content

Commit

Permalink
v3.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed May 15, 2024
1 parent 76b6cec commit 3f67b4a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cost-of-goods-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Cost of Goods for WooCommerce
Plugin URI: https://wpfactory.com/item/cost-of-goods-for-woocommerce/
Description: Save product purchase costs (cost of goods) in WooCommerce. Beautifully.
Version: 3.4.0
Version: 3.4.1
Author: WPFactory
Author URI: https://wpfactory.com
Text Domain: cost-of-goods-for-woocommerce
Expand Down
52 changes: 29 additions & 23 deletions includes/class-alg-wc-cog-orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Cost of Goods for WooCommerce - Orders Class.
*
* @version 3.3.7
* @version 3.4.1
* @since 2.1.0
* @author WPFactory
*/
Expand Down Expand Up @@ -387,8 +387,8 @@ function add_hooks() {
add_action( 'woocommerce_before_save_order_items', array( $this, 'save_order_items_ajax' ), PHP_INT_MAX, 2 );
// Save order items costs on new order.
add_action( 'woocommerce_new_order', array( $this, 'update_order_items_costs_on_new_order' ), 10 );
add_action( 'woocommerce_store_api_checkout_order_processed', array( $this, 'save_cost_input_shop_order_new' ), 10 );
add_action( 'woocommerce_new_order', array( $this, 'save_cost_input_shop_order_new' ), PHP_INT_MAX, 2 );
add_action( 'woocommerce_store_api_checkout_order_processed', array( $this, 'save_cost_input_shop_order_new' ), 10 );
add_action( 'woocommerce_api_create_order', array( $this, 'save_cost_input_shop_order_new' ), PHP_INT_MAX );
add_action( 'woocommerce_cli_create_order', array( $this, 'save_cost_input_shop_order_new' ), PHP_INT_MAX );
add_action( 'kco_before_confirm_order', array( $this, 'save_cost_input_shop_order_new' ), PHP_INT_MAX );
Expand Down Expand Up @@ -665,7 +665,7 @@ function add_order_shipping_cost_to_profit( $order_values, $order_info ) {
/**
* get_new_order_hooks_for_cost_updating.
*
* @version 3.3.6
* @version 3.4.1
* @since 2.6.3
*
* @return array
Expand All @@ -677,7 +677,9 @@ function get_new_order_hooks_for_cost_updating() {
'woocommerce_cli_create_order' => 'woocommerce_cli_create_order',
'kco_before_confirm_order' => 'kco_before_confirm_order',
'woocommerce_checkout_order_processed' => 'woocommerce_checkout_order_processed',
'woocommerce_store_api_checkout_order_processed' => 'woocommerce_store_api_checkout_order_processed'
'woocommerce_store_api_checkout_order_processed' => 'woocommerce_store_api_checkout_order_processed',
'save_post_shop_order' => 'woocommerce_store_api_checkout_order_processed',
'woocommerce_process_shop_order_meta' => 'woocommerce_process_shop_order_meta',
);
}

Expand Down Expand Up @@ -960,20 +962,22 @@ function update_order_item_costs_on_order_meta_update( $meta_id, $post_id, $meta
/**
* update_order_items_costs_on_new_order.
*
* @version 3.3.6
* @version 3.4.1
* @since 3.3.6
*
* @param $order_id
*
* @return void
*/
function update_order_items_costs_on_new_order( $order_id ) {
remove_action( 'woocommerce_new_order', array( $this, 'update_order_items_costs_on_new_order' ), 10 );
$this->update_order_items_costs( array(
'order_id' => $order_id,
'is_new_order' => true,
'is_no_costs_only' => false
) );
if ( in_array( current_filter(), get_option( 'alg_wc_cog_new_order_hooks_for_cost_update', array_keys( $this->get_new_order_hooks_for_cost_updating() ) ) ) ) {
remove_action( 'woocommerce_new_order', array( $this, 'update_order_items_costs_on_new_order' ), 10 );
$this->update_order_items_costs( array(
'order_id' => $order_id,
'is_new_order' => true,
'is_no_costs_only' => false
) );
}
}

/**
Expand Down Expand Up @@ -1015,24 +1019,26 @@ function update_order_items_costs_new_item( $item_id, $item, $order_id ) {
/**
* save_cost_input_shop_order_save_post.
*
* @version 3.3.6
* @version 3.4.1
* @since 1.1.0
*/
function save_cost_input_shop_order_save_post( $post_id, $post ) {
remove_action( 'save_post_shop_order', array( $this, 'save_cost_input_shop_order_save_post' ), 9 );
remove_action( 'woocommerce_process_shop_order_meta', array( $this, 'save_cost_input_shop_order_save_post' ), 9 );

$this->update_order_items_costs( array(
'order_id' => $post_id,
'is_new_order' => false,
) );
if ( in_array( current_filter(), get_option( 'alg_wc_cog_new_order_hooks_for_cost_update', array_keys( $this->get_new_order_hooks_for_cost_updating() ) ) ) ) {
remove_action( 'save_post_shop_order', array( $this, 'save_cost_input_shop_order_save_post' ), 9 );
remove_action( 'woocommerce_process_shop_order_meta', array( $this, 'save_cost_input_shop_order_save_post' ), 9 );

if ( $this->do_force_on_order_update ) {
$this->update_order_items_costs( array(
'order_id' => $post_id,
'is_new_order' => true,
'is_no_costs_only' => true
'order_id' => $post_id,
'is_new_order' => false,
) );

if ( $this->do_force_on_order_update ) {
$this->update_order_items_costs( array(
'order_id' => $post_id,
'is_new_order' => true,
'is_no_costs_only' => true
) );
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion includes/class-alg-wc-cog.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Alg_WC_Cost_of_Goods {
* @since 1.0.0
* @var string
*/
public $version = '3.4.0';
public $version = '3.4.1';

/**
* @since 1.0.0
Expand Down
12 changes: 6 additions & 6 deletions includes/settings/class-alg-wc-cog-settings-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Cost of Goods for WooCommerce - Advanced Section Settings.
*
* @version 3.1.3
* @version 3.4.1
* @since 1.7.0
* @author WPFactory
*/
Expand Down Expand Up @@ -44,7 +44,7 @@ function get_allowed_user_roles_option() {
/**
* get_settings.
*
* @version 3.1.3
* @version 3.4.1
* @since 1.7.0
* @todo [later] "Force costs update on ...": better title and desc (3x)
*/
Expand All @@ -71,7 +71,7 @@ function get_settings() {
'custom_attributes' => apply_filters( 'alg_wc_cog_settings', array( 'disabled' => 'disabled' ) ),
),
array(
'title' => __( 'Force costs update', 'cost-of-goods-for-woocommerce' ),
'title' => __( 'Order item costs', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Auto fill empty order items costs on order update', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_orders_force_on_update',
'default' => 'no',
Expand Down Expand Up @@ -101,16 +101,16 @@ function get_settings() {
'type' => 'checkbox',
),
array(
'title' => __( 'Costs update hooks', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Hooks from new orders that will trigger cost update.', 'cost-of-goods-for-woocommerce' ),
'title' => __( 'Order calculation hooks', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Hooks that will update order cost/profit calculation.', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_new_order_hooks_for_cost_update',
'type' => 'multiselect',
'class' => 'chosen_select',
'default' => array_keys( alg_wc_cog()->core->orders->get_new_order_hooks_for_cost_updating() ),
'options' => alg_wc_cog()->core->orders->get_new_order_hooks_for_cost_updating()
),
array(
'title' => __( 'Metadata', 'cost-of-goods-for-woocommerce' ),
'title' => __( 'Order metadata', 'cost-of-goods-for-woocommerce' ),
'desc' => __( 'Avoid empty order metadata from being saved to database', 'cost-of-goods-for-woocommerce' ),
'id' => 'alg_wc_cog_avoid_empty_order_metadata_saving',
'default' => 'yes',
Expand Down
30 changes: 15 additions & 15 deletions langs/cost-of-goods-for-woocommerce.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GNU General Public License v3.0.
msgid ""
msgstr ""
"Project-Id-Version: cost-of-goods-for-woocommerce 3.4.0\n"
"Project-Id-Version: cost-of-goods-for-woocommerce 3.4.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cost-of-goods-for-woocommerce\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-05-08T23:20:03+02:00\n"
"POT-Creation-Date: 2024-05-15T23:39:57+02:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Domain: cost-of-goods-for-woocommerce\n"
Expand Down Expand Up @@ -75,8 +75,8 @@ msgstr ""
#: includes/analytics/class-alg-wc-cog-analytics-revenue.php:47
#: includes/analytics/class-alg-wc-cog-analytics-stock.php:281
#: includes/class-alg-wc-cog-orders-meta-boxes.php:155
#: includes/class-alg-wc-cog-orders.php:748
#: includes/class-alg-wc-cog-orders.php:858
#: includes/class-alg-wc-cog-orders.php:750
#: includes/class-alg-wc-cog-orders.php:860
#: includes/class-alg-wc-cog-products-add-stock.php:352
#: includes/class-alg-wc-cog-products-add-stock.php:408
#: includes/class-alg-wc-cog-products.php:301
Expand Down Expand Up @@ -104,8 +104,8 @@ msgstr ""
#: includes/analytics/class-alg-wc-cog-analytics-revenue.php:48
#: includes/analytics/class-alg-wc-cog-analytics-stock.php:282
#: includes/class-alg-wc-cog-orders-meta-boxes.php:156
#: includes/class-alg-wc-cog-orders.php:749
#: includes/class-alg-wc-cog-orders.php:868
#: includes/class-alg-wc-cog-orders.php:751
#: includes/class-alg-wc-cog-orders.php:870
#: includes/class-alg-wc-cog-products.php:383
#: includes/pro/class-alg-wc-cog-pro-compatibility-wpsyncsheets.php:53
#: includes/pro/reports/class-wc-report-alg-cog-stock.php:123
Expand Down Expand Up @@ -280,24 +280,24 @@ msgstr ""
msgid "Shipping to profit (%s)"
msgstr ""

#: includes/class-alg-wc-cog-orders.php:752
#: includes/class-alg-wc-cog-orders.php:1190
#: includes/class-alg-wc-cog-orders.php:754
#: includes/class-alg-wc-cog-orders.php:1196
#: includes/pro/class-alg-wc-cog-pro.php:638
#: includes/pro/class-alg-wc-cog-pro.php:657
msgid "Cost of goods"
msgstr ""

#: includes/class-alg-wc-cog-orders.php:871
#: includes/class-alg-wc-cog-orders.php:873
#: includes/settings/class-alg-wc-cog-settings-orders.php:48
msgid "Profit percent"
msgstr ""

#: includes/class-alg-wc-cog-orders.php:874
#: includes/class-alg-wc-cog-orders.php:876
#: includes/settings/class-alg-wc-cog-settings-orders.php:48
msgid "Profit margin"
msgstr ""

#: includes/class-alg-wc-cog-orders.php:1226
#: includes/class-alg-wc-cog-orders.php:1232
msgid "Handling Fee"
msgstr ""

Expand Down Expand Up @@ -741,7 +741,7 @@ msgid "The administrator can't be blocked."
msgstr ""

#: includes/settings/class-alg-wc-cog-settings-advanced.php:74
msgid "Force costs update"
msgid "Order item costs"
msgstr ""

#: includes/settings/class-alg-wc-cog-settings-advanced.php:75
Expand All @@ -765,15 +765,15 @@ msgid "Only triggers with meta not starting with <code>_alg_wc_cog</code>."
msgstr ""

#: includes/settings/class-alg-wc-cog-settings-advanced.php:104
msgid "Costs update hooks"
msgid "Order calculation hooks"
msgstr ""

#: includes/settings/class-alg-wc-cog-settings-advanced.php:105
msgid "Hooks from new orders that will trigger cost update."
msgid "Hooks that will update order cost/profit calculation."
msgstr ""

#: includes/settings/class-alg-wc-cog-settings-advanced.php:113
msgid "Metadata"
msgid "Order metadata"
msgstr ""

#: includes/settings/class-alg-wc-cog-settings-advanced.php:114
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: wpcodefactory, omardabbas, karzin, anbinder, algoritmika, kousikmu
Tags: woocommerce, cost, cost of goods, profit, profit calculator
Requires at least: 6.1
Tested up to: 6.5
Stable tag: 3.4.0
Stable tag: 3.4.1
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -344,6 +344,12 @@ Once activated, access the plugin's settings by navigating to “WooCommerce > S

== Changelog ==

= 3.4.1 - 15/05/2024 =
* Fix - Advanced - Change option title from "Costs update hooks" to "Order calculation hooks".
* Fix - Advanced - Change option title from "Metadata" to "Order metadata".
* Fix - Advanced - Change option title from "Force costs update" to "Order item costs".
* Dev - Advanced - Order calculation hooks - Add all order calculation hooks to the corresponding option making it possible to avoid order metas by leaving the option empty.

= 3.4.0 - 08/05/2024 =
* Dev - Tools - Add a stock status filter to Bulk edit costs and prices.

Expand Down

0 comments on commit 3f67b4a

Please sign in to comment.