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

WC_REST_Coupons_V2_Controller::get_item_schema() public WC 1.0

Get the Coupon's schema, conforming to JSON Schema.

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

Хуков нет.

Возвращает

Массив.

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

$WC_REST_Coupons_V2_Controller = new WC_REST_Coupons_V2_Controller();
$WC_REST_Coupons_V2_Controller->get_item_schema();

Код WC_REST_Coupons_V2_Controller::get_item_schema() WC 4.7.1

<?php
public function get_item_schema() {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => $this->post_type,
		'type'       => 'object',
		'properties' => array(
			'id'                          => array(
				'description' => __( 'Unique identifier for the object.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'code'                        => array(
				'description' => __( 'Coupon code.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'amount'                      => array(
				'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'date_created'                => array(
				'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_created_gmt'            => array(
				'description' => __( 'The date the coupon was created, as GMT.', 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_modified'               => array(
				'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'date_modified_gmt'           => array(
				'description' => __( 'The date the coupon was last modified, as GMT.', 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'discount_type'               => array(
				'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce' ),
				'type'        => 'string',
				'default'     => 'fixed_cart',
				'enum'        => array_keys( wc_get_coupon_types() ),
				'context'     => array( 'view', 'edit' ),
			),
			'description'                 => array(
				'description' => __( 'Coupon description.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'date_expires'                => array(
				'description' => __( "The date the coupon expires, in the site's timezone.", 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'date_expires_gmt'            => array(
				'description' => __( 'The date the coupon expires, as GMT.', 'woocommerce' ),
				'type'        => 'date-time',
				'context'     => array( 'view', 'edit' ),
			),
			'usage_count'                 => array(
				'description' => __( 'Number of times the coupon has been used already.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'individual_use'              => array(
				'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => false,
				'context'     => array( 'view', 'edit' ),
			),
			'product_ids'                 => array(
				'description' => __( 'List of product IDs the coupon can be used on.', 'woocommerce' ),
				'type'        => 'array',
				'items'       => array(
					'type' => 'integer',
				),
				'context'     => array( 'view', 'edit' ),
			),
			'excluded_product_ids'        => array(
				'description' => __( 'List of product IDs the coupon cannot be used on.', 'woocommerce' ),
				'type'        => 'array',
				'items'       => array(
					'type' => 'integer',
				),
				'context'     => array( 'view', 'edit' ),
			),
			'usage_limit'                 => array(
				'description' => __( 'How many times the coupon can be used in total.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
			),
			'usage_limit_per_user'        => array(
				'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
			),
			'limit_usage_to_x_items'      => array(
				'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce' ),
				'type'        => 'integer',
				'context'     => array( 'view', 'edit' ),
			),
			'free_shipping'               => array(
				'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => false,
				'context'     => array( 'view', 'edit' ),
			),
			'product_categories'          => array(
				'description' => __( 'List of category IDs the coupon applies to.', 'woocommerce' ),
				'type'        => 'array',
				'items'       => array(
					'type' => 'integer',
				),
				'context'     => array( 'view', 'edit' ),
			),
			'excluded_product_categories' => array(
				'description' => __( 'List of category IDs the coupon does not apply to.', 'woocommerce' ),
				'type'        => 'array',
				'items'       => array(
					'type' => 'integer',
				),
				'context'     => array( 'view', 'edit' ),
			),
			'exclude_sale_items'          => array(
				'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce' ),
				'type'        => 'boolean',
				'default'     => false,
				'context'     => array( 'view', 'edit' ),
			),
			'minimum_amount'              => array(
				'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'maximum_amount'              => array(
				'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
			),
			'email_restrictions'          => array(
				'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce' ),
				'type'        => 'array',
				'items'       => array(
					'type' => 'string',
				),
				'context'     => array( 'view', 'edit' ),
			),
			'used_by'                     => array(
				'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce' ),
				'type'        => 'array',
				'items'       => array(
					'type' => 'integer',
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'meta_data'                   => array(
				'description' => __( 'Meta data.', 'woocommerce' ),
				'type'        => 'array',
				'context'     => array( 'view', 'edit' ),
				'items'       => array(
					'type'       => 'object',
					'properties' => array(
						'id'    => array(
							'description' => __( 'Meta ID.', 'woocommerce' ),
							'type'        => 'integer',
							'context'     => array( 'view', 'edit' ),
							'readonly'    => true,
						),
						'key'   => array(
							'description' => __( 'Meta key.', 'woocommerce' ),
							'type'        => 'string',
							'context'     => array( 'view', 'edit' ),
						),
						'value' => array(
							'description' => __( 'Meta value.', 'woocommerce' ),
							'type'        => 'mixed',
							'context'     => array( 'view', 'edit' ),
						),
					),
				),
			),
		),
	);
	return $this->add_additional_fields_schema( $schema );
}