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

WC_Coupon_Data_Store_CPT::read() public WC 3.0.0

Method to read a coupon.

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

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

null. Ничего.

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

$WC_Coupon_Data_Store_CPT = new WC_Coupon_Data_Store_CPT();
$WC_Coupon_Data_Store_CPT->read( $coupon );
$coupon(WC_Coupon) (обязательный) (передается по ссылке — &)
Coupon object.

Список изменений

С версии 3.0.0 Введена.

Код WC_Coupon_Data_Store_CPT::read() WC 5.2.2

<?php
public function read( &$coupon ) {
	$coupon->set_defaults();

	$post_object = get_post( $coupon->get_id() );

	if ( ! $coupon->get_id() || ! $post_object || 'shop_coupon' !== $post_object->post_type ) {
		throw new Exception( __( 'Invalid coupon.', 'woocommerce' ) );
	}

	$coupon_id = $coupon->get_id();
	$coupon->set_props(
		array(
			'code'                        => $post_object->post_title,
			'description'                 => $post_object->post_excerpt,
			'date_created'                => $this->string_to_timestamp( $post_object->post_date_gmt ),
			'date_modified'               => $this->string_to_timestamp( $post_object->post_modified_gmt ),
			'date_expires'                => metadata_exists( 'post', $coupon_id, 'date_expires' ) ? get_post_meta( $coupon_id, 'date_expires', true ) : get_post_meta( $coupon_id, 'expiry_date', true ), // @todo: Migrate expiry_date meta to date_expires in upgrade routine.
			'discount_type'               => get_post_meta( $coupon_id, 'discount_type', true ),
			'amount'                      => get_post_meta( $coupon_id, 'coupon_amount', true ),
			'usage_count'                 => get_post_meta( $coupon_id, 'usage_count', true ),
			'individual_use'              => 'yes' === get_post_meta( $coupon_id, 'individual_use', true ),
			'product_ids'                 => array_filter( (array) explode( ',', get_post_meta( $coupon_id, 'product_ids', true ) ) ),
			'excluded_product_ids'        => array_filter( (array) explode( ',', get_post_meta( $coupon_id, 'exclude_product_ids', true ) ) ),
			'usage_limit'                 => get_post_meta( $coupon_id, 'usage_limit', true ),
			'usage_limit_per_user'        => get_post_meta( $coupon_id, 'usage_limit_per_user', true ),
			'limit_usage_to_x_items'      => 0 < get_post_meta( $coupon_id, 'limit_usage_to_x_items', true ) ? get_post_meta( $coupon_id, 'limit_usage_to_x_items', true ) : null,
			'free_shipping'               => 'yes' === get_post_meta( $coupon_id, 'free_shipping', true ),
			'product_categories'          => array_filter( (array) get_post_meta( $coupon_id, 'product_categories', true ) ),
			'excluded_product_categories' => array_filter( (array) get_post_meta( $coupon_id, 'exclude_product_categories', true ) ),
			'exclude_sale_items'          => 'yes' === get_post_meta( $coupon_id, 'exclude_sale_items', true ),
			'minimum_amount'              => get_post_meta( $coupon_id, 'minimum_amount', true ),
			'maximum_amount'              => get_post_meta( $coupon_id, 'maximum_amount', true ),
			'email_restrictions'          => array_filter( (array) get_post_meta( $coupon_id, 'customer_email', true ) ),
			'used_by'                     => array_filter( (array) get_post_meta( $coupon_id, '_used_by' ) ),
		)
	);
	$coupon->read_meta_data();
	$coupon->set_object_read( true );
	do_action( 'woocommerce_coupon_loaded', $coupon );
}