WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_REST_Products_V2_Controller::get_product_data() protected WC 1.0

Get product data.

{} Это метод класса: WC_REST_Products_V2_Controller{}

Хуки из метода
Возвращает

Массив.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_product_data( $product, $context );
$product(WC_Product) (обязательный)
Product instance.
$context(строка)
Request context. Options: 'view' and 'edit'.
По умолчанию: 'view'

Код WC_REST_Products_V2_Controller::get_product_data() WC 4.7.1

<?php
protected function get_product_data( $product, $context = 'view' ) {
	$data = array(
		'id'                    => $product->get_id(),
		'name'                  => $product->get_name( $context ),
		'slug'                  => $product->get_slug( $context ),
		'permalink'             => $product->get_permalink(),
		'date_created'          => wc_rest_prepare_date_response( $product->get_date_created( $context ), false ),
		'date_created_gmt'      => wc_rest_prepare_date_response( $product->get_date_created( $context ) ),
		'date_modified'         => wc_rest_prepare_date_response( $product->get_date_modified( $context ), false ),
		'date_modified_gmt'     => wc_rest_prepare_date_response( $product->get_date_modified( $context ) ),
		'type'                  => $product->get_type(),
		'status'                => $product->get_status( $context ),
		'featured'              => $product->is_featured(),
		'catalog_visibility'    => $product->get_catalog_visibility( $context ),
		'description'           => 'view' === $context ? wpautop( do_shortcode( $product->get_description() ) ) : $product->get_description( $context ),
		'short_description'     => 'view' === $context ? apply_filters( 'woocommerce_short_description', $product->get_short_description() ) : $product->get_short_description( $context ),
		'sku'                   => $product->get_sku( $context ),
		'price'                 => $product->get_price( $context ),
		'regular_price'         => $product->get_regular_price( $context ),
		'sale_price'            => $product->get_sale_price( $context ) ? $product->get_sale_price( $context ) : '',
		'date_on_sale_from'     => wc_rest_prepare_date_response( $product->get_date_on_sale_from( $context ), false ),
		'date_on_sale_from_gmt' => wc_rest_prepare_date_response( $product->get_date_on_sale_from( $context ) ),
		'date_on_sale_to'       => wc_rest_prepare_date_response( $product->get_date_on_sale_to( $context ), false ),
		'date_on_sale_to_gmt'   => wc_rest_prepare_date_response( $product->get_date_on_sale_to( $context ) ),
		'price_html'            => $product->get_price_html(),
		'on_sale'               => $product->is_on_sale( $context ),
		'purchasable'           => $product->is_purchasable(),
		'total_sales'           => $product->get_total_sales( $context ),
		'virtual'               => $product->is_virtual(),
		'downloadable'          => $product->is_downloadable(),
		'downloads'             => $this->get_downloads( $product ),
		'download_limit'        => $product->get_download_limit( $context ),
		'download_expiry'       => $product->get_download_expiry( $context ),
		'external_url'          => $product->is_type( 'external' ) ? $product->get_product_url( $context ) : '',
		'button_text'           => $product->is_type( 'external' ) ? $product->get_button_text( $context ) : '',
		'tax_status'            => $product->get_tax_status( $context ),
		'tax_class'             => $product->get_tax_class( $context ),
		'manage_stock'          => $product->managing_stock(),
		'stock_quantity'        => $product->get_stock_quantity( $context ),
		'in_stock'              => $product->is_in_stock(),
		'backorders'            => $product->get_backorders( $context ),
		'backorders_allowed'    => $product->backorders_allowed(),
		'backordered'           => $product->is_on_backorder(),
		'sold_individually'     => $product->is_sold_individually(),
		'weight'                => $product->get_weight( $context ),
		'dimensions'            => array(
			'length' => $product->get_length( $context ),
			'width'  => $product->get_width( $context ),
			'height' => $product->get_height( $context ),
		),
		'shipping_required'     => $product->needs_shipping(),
		'shipping_taxable'      => $product->is_shipping_taxable(),
		'shipping_class'        => $product->get_shipping_class(),
		'shipping_class_id'     => $product->get_shipping_class_id( $context ),
		'reviews_allowed'       => $product->get_reviews_allowed( $context ),
		'average_rating'        => 'view' === $context ? wc_format_decimal( $product->get_average_rating(), 2 ) : $product->get_average_rating( $context ),
		'rating_count'          => $product->get_rating_count(),
		'related_ids'           => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ),
		'upsell_ids'            => array_map( 'absint', $product->get_upsell_ids( $context ) ),
		'cross_sell_ids'        => array_map( 'absint', $product->get_cross_sell_ids( $context ) ),
		'parent_id'             => $product->get_parent_id( $context ),
		'purchase_note'         => 'view' === $context ? wpautop( do_shortcode( wp_kses_post( $product->get_purchase_note() ) ) ) : $product->get_purchase_note( $context ),
		'categories'            => $this->get_taxonomy_terms( $product ),
		'tags'                  => $this->get_taxonomy_terms( $product, 'tag' ),
		'images'                => $this->get_images( $product ),
		'attributes'            => $this->get_attributes( $product ),
		'default_attributes'    => $this->get_default_attributes( $product ),
		'variations'            => array(),
		'grouped_products'      => array(),
		'menu_order'            => $product->get_menu_order( $context ),
		'meta_data'             => $product->get_meta_data(),
	);

	return $data;
}