Fixed import and visibility tax values to lowercase (#33820)

* Fixed import and visibility tax values to lowercase

* Minor fixes

---------

Co-authored-by: Jorge A. Torres <jorge.torres@automattic.com>
This commit is contained in:
ajayghaghretiya-multidots 2023-05-26 23:53:35 +05:30 committed by GitHub
parent bf77b4c022
commit 0780386610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: enhancement
Fixed visibility and tax values convert to lowercase as issue facing in importing.

View File

@ -781,7 +781,9 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @param string $visibility Options: 'hidden', 'visible', 'search' and 'catalog'. * @param string $visibility Options: 'hidden', 'visible', 'search' and 'catalog'.
*/ */
public function set_catalog_visibility( $visibility ) { 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 ) ) { if ( ! in_array( $visibility, $options, true ) ) {
$this->error( 'product_invalid_catalog_visibility', __( 'Invalid catalog visibility option.', 'woocommerce' ) ); $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 = 'taxable';
} }
$status = strtolower( $status );
if ( ! in_array( $status, $options, true ) ) { if ( ! in_array( $status, $options, true ) ) {
$this->error( 'product_invalid_tax_status', __( 'Invalid product tax status.', 'woocommerce' ) ); $this->error( 'product_invalid_tax_status', __( 'Invalid product tax status.', 'woocommerce' ) );
} }