Automattic\WooCommerce\StoreApi\Schemas\V1

CartSchema::get_properties()publicWC 1.0

Cart schema properties.

Method of the class: CartSchema{}

No Hooks.

Return

Array.

Usage

$CartSchema = new CartSchema();
$CartSchema->get_properties();

CartSchema::get_properties() code WC 8.6.1

public function get_properties() {
	return [
		'coupons'                 => [
			'description' => __( 'List of applied cart coupons.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'items'       => [
				'type'       => 'object',
				'properties' => $this->force_schema_readonly( $this->coupon_schema->get_properties() ),
			],
		],
		'shipping_rates'          => [
			'description' => __( 'List of available shipping rates for the cart.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'items'       => [
				'type'       => 'object',
				'properties' => $this->force_schema_readonly( $this->shipping_rate_schema->get_properties() ),
			],
		],
		'shipping_address'        => [
			'description' => __( 'Current set shipping address for the customer.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'properties'  => $this->force_schema_readonly( $this->shipping_address_schema->get_properties() ),
		],
		'billing_address'         => [
			'description' => __( 'Current set billing address for the customer.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'properties'  => $this->force_schema_readonly( $this->billing_address_schema->get_properties() ),
		],
		'items'                   => [
			'description' => __( 'List of cart items.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'items'       => [
				'type'       => 'object',
				'properties' => $this->force_schema_readonly( $this->item_schema->get_properties() ),
			],
		],
		'items_count'             => [
			'description' => __( 'Number of items in the cart.', 'woocommerce' ),
			'type'        => 'integer',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'items_weight'            => [
			'description' => __( 'Total weight (in grams) of all products in the cart.', 'woocommerce' ),
			'type'        => 'number',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'cross_sells'             => [
			'description' => __( 'List of cross-sells items related to cart items.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'items'       => [
				'type'       => 'object',
				'properties' => $this->force_schema_readonly( $this->cross_sells_item_schema->get_properties() ),
			],
		],
		'needs_payment'           => [
			'description' => __( 'True if the cart needs payment. False for carts with only free products and no shipping costs.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'needs_shipping'          => [
			'description' => __( 'True if the cart needs shipping. False for carts with only digital goods or stores with no shipping methods set-up.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'has_calculated_shipping' => [
			'description' => __( 'True if the cart meets the criteria for showing shipping costs, and rates have been calculated and included in the totals.', 'woocommerce' ),
			'type'        => 'boolean',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'fees'                    => [
			'description' => __( 'List of cart fees.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'items'       => [
				'type'       => 'object',
				'properties' => $this->force_schema_readonly( $this->fee_schema->get_properties() ),
			],
		],
		'totals'                  => [
			'description' => __( 'Cart total amounts provided using the smallest unit of the currency.', 'woocommerce' ),
			'type'        => 'object',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'properties'  => array_merge(
				$this->get_store_currency_properties(),
				[
					'total_items'        => [
						'description' => __( 'Total price of items in the cart.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_items_tax'    => [
						'description' => __( 'Total tax on items in the cart.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_fees'         => [
						'description' => __( 'Total price of any applied fees.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_fees_tax'     => [
						'description' => __( 'Total tax on fees.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_discount'     => [
						'description' => __( 'Total discount from applied coupons.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_discount_tax' => [
						'description' => __( 'Total tax removed due to discount from applied coupons.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_shipping'     => [
						'description' => __( 'Total price of shipping. If shipping has not been calculated, a null response will be sent.', 'woocommerce' ),
						'type'        => [ 'string', 'null' ],
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_shipping_tax' => [
						'description' => __( 'Total tax on shipping. If shipping has not been calculated, a null response will be sent.', 'woocommerce' ),
						'type'        => [ 'string', 'null' ],
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_price'        => [
						'description' => __( 'Total price the customer will pay.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'total_tax'          => [
						'description' => __( 'Total tax applied to items and shipping.', 'woocommerce' ),
						'type'        => 'string',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
					],
					'tax_lines'          => [
						'description' => __( 'Lines of taxes applied to items and shipping.', 'woocommerce' ),
						'type'        => 'array',
						'context'     => [ 'view', 'edit' ],
						'readonly'    => true,
						'items'       => [
							'type'       => 'object',
							'properties' => [
								'name'  => [
									'description' => __( 'The name of the tax.', 'woocommerce' ),
									'type'        => 'string',
									'context'     => [ 'view', 'edit' ],
									'readonly'    => true,
								],
								'price' => [
									'description' => __( 'The amount of tax charged.', 'woocommerce' ),
									'type'        => 'string',
									'context'     => [ 'view', 'edit' ],
									'readonly'    => true,
								],
								'rate'  => [
									'description' => __( 'The rate at which tax is applied.', 'woocommerce' ),
									'type'        => 'string',
									'context'     => [ 'view', 'edit' ],
									'readonly'    => true,
								],
							],
						],
					],
				]
			),
		],
		'errors'                  => [
			'description' => __( 'List of cart item errors, for example, items in the cart which are out of stock.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
			'items'       => [
				'type'       => 'object',
				'properties' => $this->force_schema_readonly( $this->error_schema->get_properties() ),
			],
		],
		'payment_methods'         => [
			'description' => __( 'List of available payment method IDs that can be used to process the order.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		'payment_requirements'    => [
			'description' => __( 'List of required payment gateway features to process the order.', 'woocommerce' ),
			'type'        => 'array',
			'context'     => [ 'view', 'edit' ],
			'readonly'    => true,
		],
		self::EXTENDING_KEY       => $this->get_extended_schema( self::IDENTIFIER ),
	];
}