WC_REST_Products_V1_Controller::save_product_shipping_data()
Save product shipping data.
Метод класса: WC_REST_Products_V1_Controller{}
Хуков нет.
Возвращает
WC_Product
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->save_product_shipping_data( $product, $data );
- $product(WC_Product) (обязательный)
- Product instance.
- $data(массив) (обязательный)
- Shipping data.
Код WC_REST_Products_V1_Controller::save_product_shipping_data() WC REST Products V1 Controller::save product shipping data WC 9.3.1
protected function save_product_shipping_data( $product, $data ) { // Virtual. if ( isset( $data['virtual'] ) && true === $data['virtual'] ) { $product->set_weight( '' ); $product->set_height( '' ); $product->set_length( '' ); $product->set_width( '' ); } else { if ( isset( $data['weight'] ) ) { $product->set_weight( $data['weight'] ); } // Height. if ( isset( $data['dimensions']['height'] ) ) { $product->set_height( $data['dimensions']['height'] ); } // Width. if ( isset( $data['dimensions']['width'] ) ) { $product->set_width( $data['dimensions']['width'] ); } // Length. if ( isset( $data['dimensions']['length'] ) ) { $product->set_length( $data['dimensions']['length'] ); } } // Shipping class. if ( isset( $data['shipping_class'] ) ) { $data_store = $product->get_data_store(); $shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) ); $product->set_shipping_class_id( $shipping_class_id ); } return $product; }