From 70e13702ae0a61b54f8200fa04b5b388ce4e8e9e Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Thu, 29 Sep 2016 20:16:42 -0300 Subject: [PATCH] Fixed several erros while setting data --- includes/abstracts/abstract-wc-product.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index a76f0f44632..0f76e5907df 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -637,7 +637,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @param string $sku Product SKU. */ public function set_sku( $sku ) { - if ( ! wc_product_has_unique_sku( $this->get_id(), $sku ) ) { + if ( ! empty( $sku ) && ! wc_product_has_unique_sku( $this->get_id(), $sku ) ) { $this->error( 'product_invalid_sku', __( 'Invalid or duplicated SKU.', 'woocommerce' ) ); } @@ -708,6 +708,11 @@ class WC_Product extends WC_Abstract_Legacy_Product { 'none', ); + // Set default if empty. + if ( empty( $status ) ) { + $status = 'taxable'; + } + if ( ! in_array( $status, $options, true ) ) { $this->error( 'product_invalid_tax_status', __( 'Invalid product tax status.', 'woocommerce' ) ); } @@ -761,9 +766,10 @@ class WC_Product extends WC_Abstract_Legacy_Product { } if ( update_post_meta( $this->get_id(), '_stock_status', $status ) ) { - $this->data['stock_status'] = $status; do_action( 'woocommerce_product_set_stock_status', $this->get_id(), $status ); } + + $this->data['stock_status'] = $status; } /** @@ -872,7 +878,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @since 2.7.0 * @param string $purchase_note Purchase note. */ - public function set_purchase_note() { + public function set_purchase_note( $purchase_note ) { $this->data['purchase_note'] = $purchase_note; }