WC_Product_Data_Store_CPT::read()
Method to read a product from the database.
Метод класса: WC_Product_Data_Store_CPT{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT(); $WC_Product_Data_Store_CPT->read( $product );
- $product(WC_Product) (обязательный) (передается по ссылке — &)
- Product object.
Код WC_Product_Data_Store_CPT::read() WC Product Data Store CPT::read WC 9.4.2
public function read( &$product ) { $product->set_defaults(); $post_object = get_post( $product->get_id() ); if ( ! $product->get_id() || ! $post_object || 'product' !== $post_object->post_type ) { throw new Exception( __( 'Invalid product.', 'woocommerce' ) ); } $product->set_props( array( 'name' => $post_object->post_title, 'slug' => $post_object->post_name, 'date_created' => $this->string_to_timestamp( $post_object->post_date_gmt ), 'date_modified' => $this->string_to_timestamp( $post_object->post_modified_gmt ), 'status' => $post_object->post_status, 'description' => $post_object->post_content, 'short_description' => $post_object->post_excerpt, 'parent_id' => $post_object->post_parent, 'menu_order' => $post_object->menu_order, 'post_password' => $post_object->post_password, 'reviews_allowed' => 'open' === $post_object->comment_status, ) ); $this->read_attributes( $product ); $this->read_downloads( $product ); $this->read_visibility( $product ); $this->read_product_data( $product ); $this->read_extra_data( $product ); $product->set_object_read( true ); do_action( 'woocommerce_product_read', $product->get_id() ); }