Merge pull request #15966 from woocommerce/fix/15960
[REST API] Allow unset product shipping_class
This commit is contained in:
commit
d03982bea1
|
@ -1120,11 +1120,9 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller {
|
||||||
|
|
||||||
// Shipping class.
|
// Shipping class.
|
||||||
if ( isset( $data['shipping_class'] ) ) {
|
if ( isset( $data['shipping_class'] ) ) {
|
||||||
$shipping_class_term = get_term_by( 'slug', wc_clean( $data['shipping_class'] ), 'product_shipping_class' );
|
$data_store = $product->get_data_store();
|
||||||
|
$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
|
||||||
if ( $shipping_class_term ) {
|
$product->set_shipping_class_id( $shipping_class_id );
|
||||||
$product->set_shipping_class_id( $shipping_class_term->term_id );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $product;
|
return $product;
|
||||||
|
|
|
@ -1494,11 +1494,9 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
|
|
||||||
// Shipping class
|
// Shipping class
|
||||||
if ( isset( $data['shipping_class'] ) ) {
|
if ( isset( $data['shipping_class'] ) ) {
|
||||||
$data_store = $product->get_data_store();
|
$data_store = $product->get_data_store();
|
||||||
$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
|
$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
|
||||||
if ( $shipping_class_id ) {
|
$product->set_shipping_class_id( $shipping_class_id );
|
||||||
$product->set_shipping_class_id( $shipping_class_id );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $product;
|
return $product;
|
||||||
|
|
|
@ -1998,11 +1998,9 @@ class WC_API_Products extends WC_API_Resource {
|
||||||
|
|
||||||
// Shipping class
|
// Shipping class
|
||||||
if ( isset( $data['shipping_class'] ) ) {
|
if ( isset( $data['shipping_class'] ) ) {
|
||||||
$data_store = $product->get_data_store();
|
$data_store = $product->get_data_store();
|
||||||
$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
|
$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
|
||||||
if ( $shipping_class_id ) {
|
$product->set_shipping_class_id( $shipping_class_id );
|
||||||
$product->set_shipping_class_id( $shipping_class_id );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $product;
|
return $product;
|
||||||
|
|
|
@ -932,11 +932,9 @@ class WC_REST_Products_V1_Controller extends WC_REST_Posts_Controller {
|
||||||
|
|
||||||
// Shipping class.
|
// Shipping class.
|
||||||
if ( isset( $data['shipping_class'] ) ) {
|
if ( isset( $data['shipping_class'] ) ) {
|
||||||
$shipping_class_term = get_term_by( 'slug', wc_clean( $data['shipping_class'] ), 'product_shipping_class' );
|
$data_store = $product->get_data_store();
|
||||||
|
$shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) );
|
||||||
if ( $shipping_class_term ) {
|
$product->set_shipping_class_id( $shipping_class_id );
|
||||||
$product->set_shipping_class_id( $shipping_class_term->term_id );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $product;
|
return $product;
|
||||||
|
|
Loading…
Reference in New Issue