WC_Meta_Box_Order_Data
in package
WC_Meta_Box_Order_Data Class.
Table of Contents
- $billing_fields : array<string|int, mixed>
- Billing fields.
- $shipping_fields : array<string|int, mixed>
- Shipping fields.
- init_address_fields() : mixed
- Init billing and shipping fields we display + save. Maintained for backwards compat.
- output() : mixed
- Output the metabox.
- save() : mixed
- Save meta box data.
- get_billing_fields() : array<string|int, mixed>
- Get billing fields for the meta box.
- get_shipping_fields() : array<string|int, mixed>
- Get shipping fields for the meta box.
- order_has_no_shipping() : bool
- Whether an order has no persisted shipping method.
- order_has_only_virtual_products() : bool
- Whether every resolvable product line on an order is currently virtual.
- order_shipping_matches_billing() : bool
- Whether an order's shipping address is still the billing-derived copy.
Properties
$billing_fields
Billing fields.
protected
static array<string|int, mixed>
$billing_fields
= array()
$shipping_fields
Shipping fields.
protected
static array<string|int, mixed>
$shipping_fields
= array()
Methods
init_address_fields()
Init billing and shipping fields we display + save. Maintained for backwards compat.
public
static init_address_fields() : mixed
Return values
mixed —output()
Output the metabox.
public
static output(WP_Post|WC_Order $post) : mixed
Parameters
- $post : WP_Post|WC_Order
-
Post or order object.
Return values
mixed —save()
Save meta box data.
public
static save(int $order_id) : mixed
Parameters
- $order_id : int
-
Order ID.
Tags
Return values
mixed —get_billing_fields()
Get billing fields for the meta box.
protected
static get_billing_fields([WC_Order $order = false ][, string $context = 'edit' ]) : array<string|int, mixed>
Parameters
- $order : WC_Order = false
-
Order object.
- $context : string = 'edit'
-
Context of fields (view or edit).
Return values
array<string|int, mixed> —get_shipping_fields()
Get shipping fields for the meta box.
protected
static get_shipping_fields([WC_Order $order = false ][, string $context = 'edit' ]) : array<string|int, mixed>
Parameters
- $order : WC_Order = false
-
Order object.
- $context : string = 'edit'
-
Context of fields (view or edit).
Return values
array<string|int, mixed> —order_has_no_shipping()
Whether an order has no persisted shipping method.
private
static order_has_no_shipping(WC_Order $order) : bool
A shipping line is order-time fulfillment evidence that remains stable when a merchant later changes the ordered catalog products. Orders that retain one, including Store API local pickup orders, must keep showing shipping details.
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —order_has_only_virtual_products()
Whether every resolvable product line on an order is currently virtual.
private
static order_has_only_virtual_products(WC_Order $order) : bool
This check is used only when no persisted shipping method provides historical fulfillment evidence. It intentionally reflects current, filterable catalog semantics, so product edits can change the summary for no-line orders. Empty or unresolved product sets remain visible because suppressing their persisted shipping details would be ambiguous.
Reading live catalog state is a deliberate, bounded departure from PR #66488's principle that suppression should rest on order-time evidence immune to later catalog edits. This fallback runs only for orders with no persisted shipping line (guaranteed by order_has_no_shipping() earlier in the gate's && chain), which is exactly the population that carries no such order-time evidence, so the catalog read is the only available signal and can never override a persisted shipping line. The accepted tradeoff: reclassifying a product as virtual can later re-hide a no-line order that genuinely shipped. That recurrence is display-only, admin-only, filterable, and pinned as intended by test_hides_shipping_details_after_physical_product_without_shipping_line_becomes_virtual().
The aggregation and fallback here are deliberately local rather than reusing WC_Order::needs_shipping() or the shipping-label helpers: needs_shipping() short-circuits on the global shipping setting and, like those helpers, does not default unresolved or product-less orders to the conservative "keep visible" outcome this summary requires.
Parameters
- $order : WC_Order
-
Order object.
Return values
bool —order_shipping_matches_billing()
Whether an order's shipping address is still the billing-derived copy.
private
static order_shipping_matches_billing(WC_Order $order) : bool
Store API checkout copies the billing address into the shipping address for backwards compatibility when a purchase needs no fulfillment. There is no persisted marker for that copy, so the shipping address is treated as billing-derived only while every copied field still matches billing. Once a merchant or integration edits the shipping fields to diverge, the values are explicit and must be shown. Individual getters use the edit context instead of get_address() so view filters cannot make distinct persisted values appear equal.
Parameters
- $order : WC_Order
-
Order object.
