WooCommerce Code Reference

WC_Shortcode_Checkout

Shortcode checkout class.

Table of Contents

get()  : string
Get the shortcode content.
output()  : mixed
Output the shortcode.
checkout()  : mixed
Show the checkout.
get_order_preselected_gateway()  : WC_Payment_Gateway|null
Get the gateway to pre-select on the pay page, when it should differ from the default selection.
guest_should_verify_email()  : bool
Tries to determine if the user's email address should be verified before rendering either the 'order received' or 'order pay' pages. This should only be applied to guest orders.
order_pay()  : mixed
Show the pay page.
order_received()  : mixed
Show the thanks page.
print_notice()  : void
Print a notice inside the shared notices wrapper.

Methods

get_order_preselected_gateway()

Get the gateway to pre-select on the pay page, when it should differ from the default selection.

private static get_order_preselected_gateway(WC_Order $order, array<string|int, WC_Payment_Gateway> $available_gateways) : WC_Payment_Gateway|null

A merchant assigns the method when creating an order in admin, so that assignment is the pre-selection. Orders placed through checkout carry the method the shopper picked, so those keep the default selection.

Parameters
$order : WC_Order

Order being paid for.

$available_gateways : array<string|int, WC_Payment_Gateway>

Gateways available on the pay page, keyed by gateway ID.

Tags
since
11.3.0
Return values
WC_Payment_Gateway|null —

guest_should_verify_email()

Tries to determine if the user's email address should be verified before rendering either the 'order received' or 'order pay' pages. This should only be applied to guest orders.

private static guest_should_verify_email(WC_Order $order, string $context) : bool
Parameters
$order : WC_Order

The order for which a need for email verification is being determined.

$context : string

The context in which email verification is being tested.

Return values
bool —

print_notice()

Print a notice inside the shared notices wrapper.

private static print_notice(string $message, string $notice_type) : void
Parameters
$message : string

Notice text.

$notice_type : string

Notice type: error, success or notice.

Return values
void —