CheckoutFieldsFrontend
in package
Service class managing checkout fields and its related extensibility points on the frontend.
Table of Contents
- $checkout_fields_controller : CheckoutFields
- Checkout field controller.
- __construct() : mixed
- Sets up core fields.
- edit_account_form_fields() : mixed
- Adds additional contact fields to the My Account edit account form.
- edit_account_form_required_fields() : array<string|int, mixed>
- Register required additional contact fields.
- edit_address_fields() : array<string|int, mixed>
- Adds additional address fields to the My Account edit address form.
- init() : mixed
- Initialize hooks. This is not run Store API requests.
- render_address_fields() : mixed
- Renders address fields on the account page.
- render_order_address_fields() : mixed
- Renders address fields on the order details page.
- render_order_other_fields() : mixed
- Renders additional fields on the order details page.
- save_account_form_fields() : mixed
- Validates and saves additional address fields to the customer object on the My Account page.
- save_address_fields() : mixed
- For the My Account page, save address fields. This uses the Store API endpoint for saving addresses so extensibility hooks are consistent across the codebase.
- render_additional_field() : string
- Render custom field.
- render_additional_fields() : string
- Render custom fields.
Properties
$checkout_fields_controller
Checkout field controller.
private
CheckoutFields
$checkout_fields_controller
Methods
__construct()
Sets up core fields.
public
__construct(CheckoutFields $checkout_fields_controller) : mixed
Parameters
- $checkout_fields_controller : CheckoutFields
-
Instance of the checkout field controller.
Return values
mixed —edit_account_form_fields()
Adds additional contact fields to the My Account edit account form.
public
edit_account_form_fields() : mixed
Return values
mixed —edit_account_form_required_fields()
Register required additional contact fields.
public
edit_account_form_required_fields(array<string|int, mixed> $fields) : array<string|int, mixed>
Parameters
- $fields : array<string|int, mixed>
-
Required fields.
Return values
array<string|int, mixed> —edit_address_fields()
Adds additional address fields to the My Account edit address form.
public
edit_address_fields(array<string|int, mixed> $address, string $address_type) : array<string|int, mixed>
Parameters
- $address : array<string|int, mixed>
-
Address fields.
- $address_type : string
-
Type of address (billing or shipping).
Return values
array<string|int, mixed> — Updated address fields.init()
Initialize hooks. This is not run Store API requests.
public
init() : mixed
Return values
mixed —render_address_fields()
Renders address fields on the account page.
public
render_address_fields(string $address_type) : mixed
Parameters
- $address_type : string
-
Type of address (billing or shipping).
Return values
mixed —render_order_address_fields()
Renders address fields on the order details page.
public
render_order_address_fields(string $address_type, WC_Order $order) : mixed
Parameters
- $address_type : string
-
Type of address (billing or shipping).
- $order : WC_Order
-
Order object.
Return values
mixed —render_order_other_fields()
Renders additional fields on the order details page.
public
render_order_other_fields(WC_Order $order) : mixed
Parameters
- $order : WC_Order
-
Order object.
Return values
mixed —save_account_form_fields()
Validates and saves additional address fields to the customer object on the My Account page.
public
save_account_form_fields(int $user_id) : mixed
Customer is not provided by this hook so we handle save here.
Parameters
- $user_id : int
-
User ID.
Return values
mixed —save_address_fields()
For the My Account page, save address fields. This uses the Store API endpoint for saving addresses so extensibility hooks are consistent across the codebase.
public
save_address_fields(int $user_id, string $address_type, array<string|int, mixed> $address, WC_Customer $customer) : mixed
The caller saves the customer object if there are no errors. Nonces are checked before this method executes.
Parameters
- $user_id : int
-
User ID.
- $address_type : string
-
Type of address (billing or shipping).
- $address : array<string|int, mixed>
-
Address fields.
- $customer : WC_Customer
-
Customer object.
Return values
mixed —render_additional_field()
Render custom field.
protected
render_additional_field(array<string|int, mixed> $field) : string
Parameters
- $field : array<string|int, mixed>
-
An additional field and value.
Return values
string —render_additional_fields()
Render custom fields.
protected
render_additional_fields(array<string|int, mixed> $fields) : string
Parameters
- $fields : array<string|int, mixed>
-
List of additional fields with values.