diff --git a/cost-of-goods-for-woocommerce.php b/cost-of-goods-for-woocommerce.php index 922ba8a..9e06fd0 100644 --- a/cost-of-goods-for-woocommerce.php +++ b/cost-of-goods-for-woocommerce.php @@ -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.1.9 +Version: 3.2.0 Author: WPFactory Author URI: https://wpfactory.com Text Domain: cost-of-goods-for-woocommerce diff --git a/includes/class-alg-wc-cog-orders.php b/includes/class-alg-wc-cog-orders.php index 88dab21..5bf6899 100644 --- a/includes/class-alg-wc-cog-orders.php +++ b/includes/class-alg-wc-cog-orders.php @@ -2,7 +2,7 @@ /** * Cost of Goods for WooCommerce - Orders Class. * - * @version 3.1.9 + * @version 3.2.0 * @since 2.1.0 * @author WPFactory */ @@ -248,6 +248,15 @@ class Alg_WC_Cost_of_Goods_Orders { */ public $is_columns_sorting_exclude_empty_lines; + /** + * $avoid_empty_order_metadata_saving. + * + * @since 3.2.0 + * + * @var null + */ + protected $avoid_empty_order_metadata_saving = null; + /** * Constructor. * @@ -427,23 +436,44 @@ function add_hooks() { /** * avoid_empty_order_metadata_saving. * - * @version 3.1.3 + * @version 3.2.0 * @since 3.1.3 * * @param WC_Abstract_Order $order * @param $data_store * - * @return void + * @return WC_Abstract_Order */ function avoid_empty_order_metadata_saving( WC_Abstract_Order $order, $data_store ) { - if ( 'yes' === get_option( 'alg_wc_cog_avoid_empty_order_metadata_saving', 'yes' ) ) { + if ( $this->need_to_avoid_empty_order_metadata_saving() ) { /* @var $meta_data WC_Meta_Data */ foreach ( $order->get_meta_data() as $meta_data ) { - if ( empty( $meta_data->get_data()['value'] ) ) { + if ( + substr( $meta_data->get_data()['key'], 0, 12 ) === "_alg_wc_cog_" && + empty( $meta_data->get_data()['value'] ) + ) { $order->delete_meta_data( $meta_data->get_data()['key'] ); } } } + + return $order; + } + + /** + * need_to_avoid_empty_order_metadata_saving. + * + * @version 3.2.0 + * @since 3.2.0 + * + * @return bool|null + */ + function need_to_avoid_empty_order_metadata_saving() { + if ( is_null( $this->avoid_empty_order_metadata_saving ) ) { + $this->avoid_empty_order_metadata_saving = 'yes' === get_option( 'alg_wc_cog_avoid_empty_order_metadata_saving', 'yes' ); + } + + return $this->avoid_empty_order_metadata_saving; } /** diff --git a/includes/class-alg-wc-cog.php b/includes/class-alg-wc-cog.php index ccb2fd8..9715726 100644 --- a/includes/class-alg-wc-cog.php +++ b/includes/class-alg-wc-cog.php @@ -35,7 +35,7 @@ final class Alg_WC_Cost_of_Goods { * @since 1.0.0 * @var string */ - public $version = '3.1.9'; + public $version = '3.2.0'; /** * @since 1.0.0 diff --git a/langs/cost-of-goods-for-woocommerce.pot b/langs/cost-of-goods-for-woocommerce.pot index 06ab844..606fa9d 100644 --- a/langs/cost-of-goods-for-woocommerce.pot +++ b/langs/cost-of-goods-for-woocommerce.pot @@ -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.1.9\n" +"Project-Id-Version: cost-of-goods-for-woocommerce 3.2.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cost-of-goods-for-woocommerce\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-12-19T16:25:09+01:00\n" +"POT-Creation-Date: 2023-12-20T20:39:44+01: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" @@ -75,8 +75,8 @@ msgstr "" #: includes/analytics/class-alg-wc-cog-analytics-revenue.php:47 #: includes/analytics/class-alg-wc-cog-analytics-stock.php:88 #: includes/class-alg-wc-cog-orders-meta-boxes.php:151 -#: includes/class-alg-wc-cog-orders.php:701 -#: includes/class-alg-wc-cog-orders.php:811 +#: includes/class-alg-wc-cog-orders.php:731 +#: includes/class-alg-wc-cog-orders.php:841 #: includes/class-alg-wc-cog-products-add-stock.php:351 #: includes/class-alg-wc-cog-products-add-stock.php:404 #: includes/class-alg-wc-cog-products.php:305 @@ -102,8 +102,8 @@ msgstr "" #: includes/analytics/class-alg-wc-cog-analytics-revenue.php:48 #: includes/analytics/class-alg-wc-cog-analytics-stock.php:89 #: includes/class-alg-wc-cog-orders-meta-boxes.php:152 -#: includes/class-alg-wc-cog-orders.php:702 -#: includes/class-alg-wc-cog-orders.php:821 +#: includes/class-alg-wc-cog-orders.php:732 +#: includes/class-alg-wc-cog-orders.php:851 #: includes/class-alg-wc-cog-products.php:387 #: includes/pro/reports/class-wc-report-alg-cog-stock.php:123 #: includes/tools/class-alg-wc-cog-bulk-edit-tool.php:391 @@ -246,51 +246,51 @@ msgstr "" msgid "fee" msgstr "" -#: includes/class-alg-wc-cog-orders.php:313 +#: includes/class-alg-wc-cog-orders.php:322 #: includes/settings/class-alg-wc-cog-settings-orders.php:180 msgid "You are selling below the cost of goods." msgstr "" -#: includes/class-alg-wc-cog-orders.php:509 +#: includes/class-alg-wc-cog-orders.php:539 #: includes/settings/class-alg-wc-cog-settings-orders.php:295 #: includes/settings/class-alg-wc-cog-settings-tools.php:360 msgid "Taxes to profit" msgstr "" -#: includes/class-alg-wc-cog-orders.php:548 +#: includes/class-alg-wc-cog-orders.php:578 #: includes/settings/class-alg-wc-cog-settings-orders.php:288 #: includes/settings/class-alg-wc-cog-settings-tools.php:359 msgid "Fees to profit" msgstr "" -#: includes/class-alg-wc-cog-orders.php:588 +#: includes/class-alg-wc-cog-orders.php:618 #: includes/settings/class-alg-wc-cog-settings-orders.php:274 #: includes/settings/class-alg-wc-cog-settings-tools.php:358 msgid "Shipping to profit" msgstr "" -#: includes/class-alg-wc-cog-orders.php:590 +#: includes/class-alg-wc-cog-orders.php:620 msgid "Shipping to profit (%s)" msgstr "" -#: includes/class-alg-wc-cog-orders.php:705 -#: includes/class-alg-wc-cog-orders.php:1160 +#: includes/class-alg-wc-cog-orders.php:735 +#: includes/class-alg-wc-cog-orders.php:1190 #: includes/pro/class-alg-wc-cog-pro.php:627 #: includes/pro/class-alg-wc-cog-pro.php:646 msgid "Cost of goods" msgstr "" -#: includes/class-alg-wc-cog-orders.php:824 +#: includes/class-alg-wc-cog-orders.php:854 #: includes/settings/class-alg-wc-cog-settings-orders.php:48 msgid "Profit percent" msgstr "" -#: includes/class-alg-wc-cog-orders.php:827 +#: includes/class-alg-wc-cog-orders.php:857 #: includes/settings/class-alg-wc-cog-settings-orders.php:48 msgid "Profit margin" msgstr "" -#: includes/class-alg-wc-cog-orders.php:1196 +#: includes/class-alg-wc-cog-orders.php:1226 msgid "Handling Fee" msgstr "" diff --git a/readme.txt b/readme.txt index 4a1bfc3..77e6d2b 100644 --- a/readme.txt +++ b/readme.txt @@ -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.4 -Stable tag: 3.1.9 +Stable tag: 3.2.0 License: GNU General Public License v3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -365,6 +365,9 @@ Once activated, access the plugin's settings by navigating to “WooCommerce > S == Changelog == += 3.2.0 - 20/12/2023 = +* Fix - Advanced - "Avoid empty order metadata from being saved to database" option might trigger errors on checkout. + = 3.1.9 - 19/12/2023 = * Dev - Compatibility - Measurement Price Calculator - Add option to adjust the cost of goods sold according to the product measurement. * Dev - Compatibility - Measurement Price Calculator - Create option to add the placeholder `%measurement_unit%` to the cost field label option.