'' === $data && ! empty( $legacy_data ) ) { $data = $legacy_data; } return $data; } public function get_manufacture_country( $context = 'view' ) { $legacy_data = $this->get_forced_parent_product()->get_meta( '_dhl_manufacture_country', true, $context ); $country = $this->get_forced_parent_product()->get_meta( '_manufacture_country', true, $context ); if ( empty( $country ) && ! empty( $legacy_data ) ) { $country = $legacy_data; } if ( empty( $country ) && 'view' === $context ) { $country = Package::get_base_country(); } $country = substr( wc_strtoupper( $country ), 0, 2 ); $country = strlen( $country ) < 2 ? '' : $country; return $country; } public function get_main_category() { $ids = $this->get_forced_parent_product()->get_category_ids(); $term_name = ''; if ( ! empty( $ids ) ) { foreach ( $ids as $term_id ) { $term = get_term( $term_id, 'product_cat' ); if ( empty( $term->slug ) ) { continue; } $term_name = $term->name; break; } } return $term_name; } public function set_hs_code( $code ) { $this->product->update_meta_data( '_hs_code', $code ); } public function set_mid_code( $code ) { $this->product->update_meta_data( '_mid_code', $code ); } public function set_manufacture_country( $country ) { $country = substr( wc_strtoupper( $country ), 0, 2 ); $country = strlen( $country ) < 2 ? '' : $country; $this->product->update_meta_data( '_manufacture_country', $country ); } public function set_ship_separately_via( $shipping_provider ) { $this->product->update_meta_data( '_ship_separately_via', $shipping_provider ); } public function set_shipping_weight( $weight ) { $this->product->update_meta_data( '_shipping_weight', wc_format_decimal( $weight ) ); } public function set_shipping_length( $length ) { $this->product->update_meta_data( '_shipping_length', wc_format_decimal( $length ) ); } public function set_shipping_width( $width ) { $this->product->update_meta_data( '_shipping_width', wc_format_decimal( $width ) ); } public function set_shipping_height( $height ) { $this->product->update_meta_data( '_shipping_height', wc_format_decimal( $height ) ); } public function set_customs_description( $description ) { $this->product->update_meta_data( '_customs_description', $description ); } public function set_is_non_returnable( $is_non_returnable ) { $this->product->update_meta_data( '_is_non_returnable', wc_bool_to_string( $is_non_returnable ) ); } /** * Call child methods if the method does not exist. * * @param $method * @param $args * * @return bool|mixed */ public function __call( $method, $args ) { if ( method_exists( $this->product, $method ) ) { return call_user_func_array( array( $this->product, $method ), $args ); } return false; } }