id, '_' . $key ); } /** * Magic __get method for backwards compatibility.Maps legacy vars to new getters. * * @param string $key Key name. * @return mixed */ public function __get( $key ) { _doing_it_wrong( $key, __( 'Product properties should not be accessed directly.', 'woocommerce' ), '2.7' ); switch ( $key ) { case 'id' : $value = $this->get_id(); break; case 'product_attributes' : $value = isset( $this->data['attributes'] ) ? $this->data['attributes'] : ''; break; case 'visibility' : $value = $this->get_catalog_visibility(); break; case 'sale_price_dates_from' : $value = $this->get_date_on_sale_from(); break; case 'sale_price_dates_to' : $value = $this->get_date_on_sale_to(); break; case 'post' : $value = get_post( $this->get_id() ); break; default : $value = get_post_meta( $this->id, '_' . $key, true ); // Get values or default if not set. if ( in_array( $key, array( 'downloadable', 'virtual', 'backorders', 'manage_stock', 'featured', 'sold_individually' ) ) ) { $value = $value ? $value : 'no'; } elseif ( in_array( $key, array( 'product_attributes', 'crosssell_ids', 'upsell_ids' ) ) ) { $value = $value ? $value : array(); } elseif ( 'stock' === $key ) { $value = $value ? $value : 0; } elseif ( 'stock_status' === $key ) { $value = $value ? $value : 'instock'; } elseif ( 'tax_status' === $key ) { $value = $value ? $value : 'taxable'; } break; } return $value; } /** * Get the product's post data. * * @deprecated 2.7.0 * @return WP_Post */ public function get_post_data() { return $this->post; } /** * Get the title of the post. * * @deprecated 2.7.0 * @return string */ public function get_title() { return apply_filters( 'woocommerce_product_title', $this->post ? $this->post->post_title : '', $this ); } /** * Get the parent of the post. * * @deprecated 2.7.0 * @return int */ public function get_parent() { return apply_filters( 'woocommerce_product_parent', absint( $this->post->post_parent ), $this ); } }