Automattic\WooCommerce\Blocks\Shipping

ShippingController::register_settings()publicWC 1.0

Register Local Pickup settings for rest api.

Метод класса: ShippingController{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$ShippingController = new ShippingController();
$ShippingController->register_settings();

Код ShippingController::register_settings() WC 9.0.2

public function register_settings() {
	register_setting(
		'options',
		'woocommerce_pickup_location_settings',
		array(
			'type'         => 'object',
			'description'  => 'WooCommerce Local Pickup Method Settings',
			'default'      => array(),
			'show_in_rest' => array(
				'name'   => 'pickup_location_settings',
				'schema' => array(
					'type'       => 'object',
					'properties' => array(
						'enabled'    => array(
							'description' => __( 'If enabled, this method will appear on the block based checkout.', 'woocommerce' ),
							'type'        => 'string',
							'enum'        => array( 'yes', 'no' ),
						),
						'title'      => array(
							'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
							'type'        => 'string',
						),
						'tax_status' => array(
							'description' => __( 'If a cost is defined, this controls if taxes are applied to that cost.', 'woocommerce' ),
							'type'        => 'string',
							'enum'        => array( 'taxable', 'none' ),
						),
						'cost'       => array(
							'description' => __( 'Optional cost to charge for local pickup.', 'woocommerce' ),
							'type'        => 'string',
						),
					),
				),
			),
		)
	);
	register_setting(
		'options',
		'pickup_location_pickup_locations',
		array(
			'type'         => 'array',
			'description'  => 'WooCommerce Local Pickup Locations',
			'default'      => array(),
			'show_in_rest' => array(
				'name'   => 'pickup_locations',
				'schema' => array(
					'type'  => 'array',
					'items' => array(
						'type'       => 'object',
						'properties' => array(
							'name'    => array(
								'type' => 'string',
							),
							'address' => array(
								'type'       => 'object',
								'properties' => array(
									'address_1' => array(
										'type' => 'string',
									),
									'city'      => array(
										'type' => 'string',
									),
									'state'     => array(
										'type' => 'string',
									),
									'postcode'  => array(
										'type' => 'string',
									),
									'country'   => array(
										'type' => 'string',
									),
								),
							),
							'details' => array(
								'type' => 'string',
							),
							'enabled' => array(
								'type' => 'boolean',
							),
						),
					),
				),
			),
		)
	);
}