ShippingAddress
extends AbstractOrderConfirmationBlock
in package
ShippingAddress class.
Table of Contents
- $asset_api : Api
- Instance of the asset API.
- $asset_data_registry : AssetDataRegistry
- Instance of the asset data registry.
- $block_name : string
- Block name.
- $enqueued_assets : bool
- Tracks if assets have been enqueued.
- $integration_registry : IntegrationRegistry
- Instance of the integration registry.
- $namespace : string
- Block namespace.
- __construct() : mixed
- Constructor.
- enqueue_editor_assets() : mixed
- Enqueue assets used for rendering the block in editor context.
- register_patterns() : mixed
- Register block pattern for Order Confirmation to make it translatable.
- render_callback() : string
- The default render_callback for all blocks. This will ensure assets are enqueued just in time, then render the block (if applicable).
- allow_guest_checkout() : bool
- See if guest checkout is enabled.
- email_verification_permitted() : bool
- Guest users without an active session can provide their email address to view order details. This however can only be permitted if the user also provided the correct order key, and guest checkout is actually enabled.
- email_verification_required() : bool
- See if we need to verify the email address before showing the order details.
- enqueue_data() : mixed
- Extra data passed through from server to client for block.
- enqueue_scripts() : mixed
- Register/enqueue scripts used for this block on the frontend, during render.
- get_block_type() : string
- Get the block type.
- get_block_type_attributes() : array<string|int, mixed>
- Get block attributes.
- get_block_type_editor_script() : array<string|int, mixed>|string
- Get the editor script data for this block type.
- get_block_type_editor_style() : string|null
- Get the editor style handle for this block type.
- get_block_type_render_callback() : callable|null
- Get the render callback for this block type.
- get_block_type_script() : array<string|int, mixed>|string|null
- Get the frontend script handle for this block type.
- get_block_type_style() : array<string|int, string>|null
- Get the frontend style handle for this block type.
- get_block_type_supports() : string
- Get the supports array for this block type.
- get_block_type_uses_context() : array<string|int, mixed>
- Get block usesContext.
- get_chunks_paths() : array<string|int, string>
- Generate an array of chunks paths for loading translation.
- get_full_block_name() : string
- Get the interactivity namespace. Only used when utilizing the interactivity API.
- get_hook_content() : string
- Get the content from a hook and return it.
- get_order() : WC_Order|null
- Get current order.
- get_routes_from_namespace() : array<string|int, mixed>
- Get routes from a REST API namespace.
- get_view_order_permissions() : string|false
- View mode for order details based on the order, current user, and settings.
- has_valid_order_key() : bool
- See if the order key is valid.
- initialize() : mixed
- Initialize this block type.
- is_current_customer_order() : bool
- See if the current logged in user ID matches the given order customer ID.
- is_customer_order() : bool
- See if the current order came from a guest or a logged in customer.
- is_email_verified() : bool
- Returns true if the email has been verified (posted email matches given order email).
- is_within_grace_period() : bool
- See if the order was created within the grace period for viewing details.
- parse_render_callback_attributes() : array<string|int, mixed>
- Parses block attributes from the render_callback.
- register_block_type() : array<string|int, string>
- Registers the block type with WordPress.
- register_block_type_assets() : mixed
- Register script and style assets for the block type before it is registered.
- register_chunk_translations() : mixed
- Injects Chunk Translations into the page so translations work for lazy loaded components.
- render() : string
- Render the block. Extended by children.
- render_additional_field() : string
- Render custom field row.
- render_additional_fields() : string
- Render custom fields for the order.
- render_content() : string
- This renders the content of the block within the wrapper.
- render_content_fallback() : string
- This is what gets rendered when the order does not exist. Renders nothing by default, but can be overridden by child classes.
Properties
$asset_api
Instance of the asset API.
protected
Api
$asset_api
$asset_data_registry
Instance of the asset data registry.
protected
AssetDataRegistry
$asset_data_registry
$block_name
Block name.
protected
string
$block_name
= 'order-confirmation-shipping-address'
$enqueued_assets
Tracks if assets have been enqueued.
protected
bool
$enqueued_assets
= false
$integration_registry
Instance of the integration registry.
protected
IntegrationRegistry
$integration_registry
$namespace
Block namespace.
protected
string
$namespace
= 'woocommerce'
Methods
__construct()
Constructor.
public
__construct(Api $asset_api, AssetDataRegistry $asset_data_registry, IntegrationRegistry $integration_registry[, string $block_name = '' ]) : mixed
Parameters
- $asset_api : Api
-
Instance of the asset API.
- $asset_data_registry : AssetDataRegistry
-
Instance of the asset data registry.
- $integration_registry : IntegrationRegistry
-
Instance of the integration registry.
- $block_name : string = ''
-
Optionally set block name during construct.
Return values
mixed —enqueue_editor_assets()
Enqueue assets used for rendering the block in editor context.
public
enqueue_editor_assets() : mixed
This is needed if a block is not yet within the post content--render
and enqueue_assets
may not have ran.
Return values
mixed —register_patterns()
Register block pattern for Order Confirmation to make it translatable.
public
register_patterns() : mixed
Return values
mixed —render_callback()
The default render_callback for all blocks. This will ensure assets are enqueued just in time, then render the block (if applicable).
public
render_callback([array<string|int, mixed>|WP_Block $attributes = [] ][, string $content = '' ][, WP_Block|null $block = null ]) : string
Parameters
- $attributes : array<string|int, mixed>|WP_Block = []
-
Block attributes, or an instance of a WP_Block. Defaults to an empty array.
- $content : string = ''
-
Block content. Default empty string.
- $block : WP_Block|null = null
-
Block instance.
Return values
string — Rendered block type output.allow_guest_checkout()
See if guest checkout is enabled.
protected
allow_guest_checkout() : bool
Return values
bool —email_verification_permitted()
Guest users without an active session can provide their email address to view order details. This however can only be permitted if the user also provided the correct order key, and guest checkout is actually enabled.
protected
email_verification_permitted(WC_Order $order) : bool
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —email_verification_required()
See if we need to verify the email address before showing the order details.
protected
email_verification_required(WC_Order $order) : bool
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —enqueue_data()
Extra data passed through from server to client for block.
protected
enqueue_data([array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $attributes : array<string|int, mixed> = []
-
Any attributes that currently are available from the block. Note, this will be empty in the editor context when the block is not in the post content on editor load.
Return values
mixed —enqueue_scripts()
Register/enqueue scripts used for this block on the frontend, during render.
protected
enqueue_scripts([array<string|int, mixed> $attributes = [] ]) : mixed
Parameters
- $attributes : array<string|int, mixed> = []
-
Any attributes that currently are available from the block.
Return values
mixed —get_block_type()
Get the block type.
protected
get_block_type() : string
Return values
string —get_block_type_attributes()
Get block attributes.
protected
get_block_type_attributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_block_type_editor_script()
Get the editor script data for this block type.
protected
get_block_type_editor_script([string $key = null ]) : array<string|int, mixed>|string
Parameters
- $key : string = null
-
Data to get, or default to everything.
Tags
Return values
array<string|int, mixed>|string —get_block_type_editor_style()
Get the editor style handle for this block type.
protected
get_block_type_editor_style() : string|null
Tags
Return values
string|null —get_block_type_render_callback()
Get the render callback for this block type.
protected
get_block_type_render_callback() : callable|null
Dynamic blocks should return a callback, for example, return [ $this, 'render' ];
Tags
Return values
callable|null —get_block_type_script()
Get the frontend script handle for this block type.
protected
get_block_type_script([string $key = null ]) : array<string|int, mixed>|string|null
Parameters
- $key : string = null
-
Data to get, or default to everything.
Tags
Return values
array<string|int, mixed>|string|null —get_block_type_style()
Get the frontend style handle for this block type.
protected
get_block_type_style() : array<string|int, string>|null
Return values
array<string|int, string>|null —get_block_type_supports()
Get the supports array for this block type.
protected
get_block_type_supports() : string
Tags
Return values
string —get_block_type_uses_context()
Get block usesContext.
protected
get_block_type_uses_context() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_chunks_paths()
Generate an array of chunks paths for loading translation.
protected
get_chunks_paths(string $chunks_folder) : array<string|int, string>
Parameters
- $chunks_folder : string
-
The folder to iterate over.
Return values
array<string|int, string> — $chunks list of chunks to load.get_full_block_name()
Get the interactivity namespace. Only used when utilizing the interactivity API.
protected
get_full_block_name() : string
Return values
string — The interactivity namespace, used to namespace interactivity API actions and state.get_hook_content()
Get the content from a hook and return it.
protected
get_hook_content(string $hook, array<string|int, mixed> $args) : string
Parameters
- $hook : string
-
Hook name.
- $args : array<string|int, mixed>
-
Array of args to pass to the hook.
Return values
string —get_order()
Get current order.
protected
get_order() : WC_Order|null
Return values
WC_Order|null —get_routes_from_namespace()
Get routes from a REST API namespace.
protected
get_routes_from_namespace(string $namespace) : array<string|int, mixed>
Parameters
- $namespace : string
-
Namespace to retrieve.
Return values
array<string|int, mixed> —get_view_order_permissions()
View mode for order details based on the order, current user, and settings.
protected
get_view_order_permissions(WC_Order|null $order) : string|false
Parameters
- $order : WC_Order|null
-
Order object.
Return values
string|false — Returns "full" if the user can view all order details. False if they can view no details.has_valid_order_key()
See if the order key is valid.
protected
has_valid_order_key(WC_Order $order) : bool
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —initialize()
Initialize this block type.
protected
initialize() : mixed
- Hook into WP lifecycle.
- Register the block with WordPress.
Return values
mixed —is_current_customer_order()
See if the current logged in user ID matches the given order customer ID.
protected
is_current_customer_order(WC_Order $order) : bool
Returns false for logged-out customers.
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —is_customer_order()
See if the current order came from a guest or a logged in customer.
protected
is_customer_order(WC_Order $order) : bool
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —is_email_verified()
Returns true if the email has been verified (posted email matches given order email).
protected
is_email_verified(WC_Order $order) : bool
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —is_within_grace_period()
See if the order was created within the grace period for viewing details.
protected
is_within_grace_period(WC_Order $order) : bool
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —parse_render_callback_attributes()
Parses block attributes from the render_callback.
protected
parse_render_callback_attributes(array<string|int, mixed>|WP_Block $attributes) : array<string|int, mixed>
Parameters
- $attributes : array<string|int, mixed>|WP_Block
-
Block attributes, or an instance of a WP_Block. Defaults to an empty array.
Return values
array<string|int, mixed> —register_block_type()
Registers the block type with WordPress.
protected
register_block_type() : array<string|int, string>
Return values
array<string|int, string> — Chunks paths.register_block_type_assets()
Register script and style assets for the block type before it is registered.
protected
register_block_type_assets() : mixed
This registers the scripts; it does not enqueue them.
Return values
mixed —register_chunk_translations()
Injects Chunk Translations into the page so translations work for lazy loaded components.
protected
register_chunk_translations(array<string|int, string> $chunks) : mixed
The chunk names are defined when creating lazy loaded components using webpackChunkName.
Parameters
- $chunks : array<string|int, string>
-
Array of chunk names.
Return values
mixed —render()
Render the block. Extended by children.
protected
render(array<string|int, mixed> $attributes, string $content, WP_Block $block) : string
Parameters
- $attributes : array<string|int, mixed>
-
Block attributes.
- $content : string
-
Block content.
- $block : WP_Block
-
Block instance.
Return values
string — Rendered block type output.render_additional_field()
Render custom field row.
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 for the order.
protected
render_additional_fields(array<string|int, mixed> $fields) : string
Parameters
- $fields : array<string|int, mixed>
-
List of additional fields with values.
Return values
string —render_content()
This renders the content of the block within the wrapper.
protected
render_content(WC_Order $order[, string|false $permission = false ][, array<string|int, mixed> $attributes = [] ][, string $content = '' ]) : string
Parameters
- $order : WC_Order
-
Order object.
- $permission : string|false = false
-
If the current user can view the order details or not.
- $attributes : array<string|int, mixed> = []
-
Block attributes.
- $content : string = ''
-
Original block content.
Return values
string —render_content_fallback()
This is what gets rendered when the order does not exist. Renders nothing by default, but can be overridden by child classes.
protected
render_content_fallback() : string