DocumentObject
in package
DocumentObject class.
This will combine and format given cart/customer/checkout data into a standard object format that can be queried through JSON. This is used for conditional fields and validation during checkout.
Table of Contents
- $cart : WC_Cart|null
- The cart object.
- $cart_controller : CartController
- Cart controller class instance.
- $context : null|string
- Docuemnt object context which may adjust the schema response.
- $customer : WC_Customer|null
- The customer object.
- $request_data : array<string|int, mixed>
- The request data.
- $schema_controller : SchemaController
- Schema controller class instance.
- $valid_contexts : array<string|int, mixed>
- Valid contexts.
- __construct() : mixed
- The constructor.
- get_context() : null|string
- Get the current context.
- get_data() : array<string|int, mixed>
- Get the data for the document object.
- set_cart() : mixed
- Set the cart object.
- set_context() : mixed
- Set document object context.
- set_customer() : mixed
- Set the customer object.
- get_cart_data() : array<string|int, mixed>
- Gets a subset of cart data.
- get_checkout_data() : array<string|int, mixed>
- Get checkout data.
- get_customer_data() : array<string|int, mixed>
- Get the customer data.
Properties
$cart
The cart object.
protected
WC_Cart|null
$cart
= null
$cart_controller
Cart controller class instance.
protected
CartController
$cart_controller
$context
Docuemnt object context which may adjust the schema response.
protected
null|string
$context
= null
$customer
The customer object.
protected
WC_Customer|null
$customer
= null
$request_data
The request data.
protected
array<string|int, mixed>
$request_data
= []
$schema_controller
Schema controller class instance.
protected
SchemaController
$schema_controller
$valid_contexts
Valid contexts.
protected
array<string|int, mixed>
$valid_contexts
= ['shipping_address', 'billing_address', 'contact', 'order']
Methods
__construct()
The constructor.
public
__construct([array<string|int, mixed> $request_data = [] ]) : mixed
Parameters
- $request_data : array<string|int, mixed> = []
-
Data that overrides the default values.
Return values
mixed —get_context()
Get the current context.
public
get_context() : null|string
Return values
null|string — The context.get_data()
Get the data for the document object.
public
get_data() : array<string|int, mixed>
This isn't a 1:1 match with Store API because some data is simplified to make it easier to parse as JSON.
Return values
array<string|int, mixed> — The data for the document object.set_cart()
Set the cart object.
public
set_cart(WC_Cart $cart) : mixed
Parameters
- $cart : WC_Cart
-
The cart object.
Return values
mixed —set_context()
Set document object context.
public
set_context([null|string $context = null ]) : mixed
Parameters
- $context : null|string = null
-
Context to set.
Return values
mixed —set_customer()
Set the customer object.
public
set_customer(WC_Customer $customer) : mixed
Parameters
- $customer : WC_Customer
-
The customer object.
Return values
mixed —get_cart_data()
Gets a subset of cart data.
protected
get_cart_data() : array<string|int, mixed>
Return values
array<string|int, mixed> — The cart data.get_checkout_data()
Get checkout data.
protected
get_checkout_data() : array<string|int, mixed>
Return values
array<string|int, mixed> — Checkout data context.get_customer_data()
Get the customer data.
protected
get_customer_data() : array<string|int, mixed>