diff --git a/cost-of-goods-for-woocommerce.php b/cost-of-goods-for-woocommerce.php index 1f0e89f..e4d9f3f 100644 --- a/cost-of-goods-for-woocommerce.php +++ b/cost-of-goods-for-woocommerce.php @@ -3,13 +3,13 @@ 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.7 +Version: 3.1.8 Author: WPFactory Author URI: https://wpfactory.com Text Domain: cost-of-goods-for-woocommerce Domain Path: /langs Copyright: © 2023 WPFactory -WC tested up to: 8.3 +WC tested up to: 8.4 License: GNU General Public License v3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html */ diff --git a/includes/class-alg-wc-cog-products-add-stock.php b/includes/class-alg-wc-cog-products-add-stock.php index b2e065b..15bb44d 100644 --- a/includes/class-alg-wc-cog-products-add-stock.php +++ b/includes/class-alg-wc-cog-products-add-stock.php @@ -2,7 +2,7 @@ /** * Cost of Goods for WooCommerce - Products - Add Stock. * - * @version 3.1.7 + * @version 3.1.8 * @since 2.8.2 * @author WPFactory */ @@ -25,12 +25,12 @@ class Alg_WC_Cost_of_Goods_Products_Add_Stock { /** * Constructor. * - * @version 3.1.7 + * @version 3.1.8 * @since 2.8.2 */ function __construct() { // Add product stock - add_action( 'add_meta_boxes', array( $this, 'add_product_add_stock_meta_box' ) ); + add_action( 'add_meta_boxes', array( $this, 'add_product_add_stock_meta_box' ), 10, 2 ); add_action( 'save_post_product', array( $this, 'save_product_add_stock' ), PHP_INT_MAX, 2 ); add_action( 'admin_head', array( $this, 'create_add_stock_style' ) ); add_action( 'wp_ajax_get_add_stock_history_table', array( $this, 'get_add_stock_history_table_ajax' ) ); @@ -54,28 +54,27 @@ function is_add_stock_enabled() { /** * add_product_add_stock_meta_box. * - * @version 3.1.7 + * @version 3.1.8 * @since 1.7.0 */ - function add_product_add_stock_meta_box() { + function add_product_add_stock_meta_box( $post_type, $post ) { if ( ! apply_filters( 'alg_wc_cog_create_product_meta_box_validation', true ) ) { return; } - if ( $this->is_add_stock_enabled() ) { - if ( - ( $product = wc_get_product( get_the_ID() ) ) && - $product->is_type( 'simple' ) || $product->is_type( 'variable' ) - ) { - $tip = wc_help_tip( __( 'Enter values and "Update" the product.', 'cost-of-goods-for-woocommerce' ) . ' ' . - __( '"Stock" will be added to your inventory, and "Cost" will be used to calculate new average cost of goods for the product.', 'cost-of-goods-for-woocommerce' ) ); - add_meta_box( 'alg-wc-cog-add-stock', - //__( 'Cost of Goods', 'cost-of-goods-for-woocommerce' ) . ': ' . __( 'Add stock', 'cost-of-goods-for-woocommerce' ) . $tip, - __( 'Add stock', 'cost-of-goods-for-woocommerce' ) . $tip, - array( $this, 'product_add_stock_meta_box' ), - 'product', - 'side' - ); - } + if ( + $post && + is_a( $product = wc_get_product( $post->ID ), 'WC_Product' ) && + $this->is_add_stock_enabled() && + ( $product->is_type( 'simple' ) || $product->is_type( 'variable' ) ) + ) { + $tip = wc_help_tip( __( 'Enter values and "Update" the product.', 'cost-of-goods-for-woocommerce' ) . ' ' . + __( '"Stock" will be added to your inventory, and "Cost" will be used to calculate new average cost of goods for the product.', 'cost-of-goods-for-woocommerce' ) ); + add_meta_box( 'alg-wc-cog-add-stock', + __( 'Add stock', 'cost-of-goods-for-woocommerce' ) . $tip, + array( $this, 'product_add_stock_meta_box' ), + 'product', + 'side' + ); } } diff --git a/includes/class-alg-wc-cog.php b/includes/class-alg-wc-cog.php index b027f5c..8195c20 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.7'; + public $version = '3.1.8'; /** * @since 1.0.0 diff --git a/langs/cost-of-goods-for-woocommerce.pot b/langs/cost-of-goods-for-woocommerce.pot index 3cc68e9..dfbc8d0 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.7\n" +"Project-Id-Version: cost-of-goods-for-woocommerce 3.1.8\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-13T04:17:51+01:00\n" +"POT-Creation-Date: 2023-12-13T13:29:25+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" @@ -77,8 +77,8 @@ msgstr "" #: 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-products-add-stock.php:352 -#: includes/class-alg-wc-cog-products-add-stock.php:405 +#: 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 #: includes/class-alg-wc-cog-products.php:316 #: includes/class-alg-wc-cog-products.php:327 @@ -293,11 +293,11 @@ msgstr "" msgid "Handling Fee" msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:69 +#: includes/class-alg-wc-cog-products-add-stock.php:70 msgid "Enter values and \"Update\" the product." msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:70 +#: includes/class-alg-wc-cog-products-add-stock.php:71 #: includes/settings/class-alg-wc-cog-settings-products.php:240 msgid "\"Stock\" will be added to your inventory, and \"Cost\" will be used to calculate new average cost of goods for the product." msgstr "" @@ -310,8 +310,8 @@ msgstr "" msgid "Add stock" msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:348 -#: includes/class-alg-wc-cog-products-add-stock.php:404 +#: includes/class-alg-wc-cog-products-add-stock.php:347 +#: includes/class-alg-wc-cog-products-add-stock.php:403 #: includes/pro/class-alg-wc-cog-pro.php:812 #: includes/pro/reports/class-wc-report-alg-cog-stock.php:120 #: includes/settings/class-alg-wc-cog-settings-tools.php:133 @@ -319,29 +319,29 @@ msgstr "" msgid "Stock" msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:369 +#: includes/class-alg-wc-cog-products-add-stock.php:368 msgid "History" msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:403 +#: includes/class-alg-wc-cog-products-add-stock.php:402 #: includes/settings/class-alg-wc-cog-settings-products.php:204 msgid "Date" msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:444 +#: includes/class-alg-wc-cog-products-add-stock.php:443 msgid "Variation history" msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:451 +#: includes/class-alg-wc-cog-products-add-stock.php:450 #: includes/class-alg-wc-cog-products-cost-archive.php:295 msgid "Select variation" msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:530 +#: includes/class-alg-wc-cog-products-add-stock.php:529 msgid "If no variation is selected, the parent product will be updated." msgstr "" -#: includes/class-alg-wc-cog-products-add-stock.php:531 +#: includes/class-alg-wc-cog-products-add-stock.php:530 msgid "Update variation(s)" msgstr "" diff --git a/readme.txt b/readme.txt index 081e5fc..1034d93 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.7 +Stable tag: 3.1.8 License: GNU General Public License v3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -365,6 +365,10 @@ Once activated, access the plugin's settings by navigating to “WooCommerce > S == Changelog == += 3.1.8 - 13/12/2023 = +* Fix - Uncaught Error: Call to a member function is_type() on bool in `Alg_WC_Cost_of_Goods_Products_Add_Stock`. +* WC tested up to: 8.4. + = 3.1.7 - 13/12/2023 = * Fix - Cost archive - Cost data is updated even when previous and current values are the same. * Fix - It's possible to use the "Add stock" feature even with the product "Stock management" disabled.