diff --git a/plugins/woocommerce/changelog/abstract-wc-products b/plugins/woocommerce/changelog/abstract-wc-products new file mode 100644 index 00000000000..6f558e5096f --- /dev/null +++ b/plugins/woocommerce/changelog/abstract-wc-products @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Fixed visibility and tax values convert to lowercase as issue facing in importing. diff --git a/plugins/woocommerce/includes/abstracts/abstract-wc-product.php b/plugins/woocommerce/includes/abstracts/abstract-wc-product.php index 16d87eac306..861180bbf68 100644 --- a/plugins/woocommerce/includes/abstracts/abstract-wc-product.php +++ b/plugins/woocommerce/includes/abstracts/abstract-wc-product.php @@ -781,7 +781,9 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @param string $visibility Options: 'hidden', 'visible', 'search' and 'catalog'. */ public function set_catalog_visibility( $visibility ) { - $options = array_keys( wc_get_product_visibility_options() ); + $options = array_keys( wc_get_product_visibility_options() ); + $visibility = in_array( $visibility, $options, true ) ? $visibility : strtolower( $visibility ); + if ( ! in_array( $visibility, $options, true ) ) { $this->error( 'product_invalid_catalog_visibility', __( 'Invalid catalog visibility option.', 'woocommerce' ) ); } @@ -911,6 +913,8 @@ class WC_Product extends WC_Abstract_Legacy_Product { $status = 'taxable'; } + $status = strtolower( $status ); + if ( ! in_array( $status, $options, true ) ) { $this->error( 'product_invalid_tax_status', __( 'Invalid product tax status.', 'woocommerce' ) ); }