WC_Shortcode_Checkout::output
Output the shortcode.
Method of the class: WC_Shortcode_Checkout{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Shortcode_Checkout::output( $atts );
- $atts(array) (required)
- Shortcode attributes.
WC_Shortcode_Checkout::output() WC Shortcode Checkout::output code WC 10.4.3
public static function output( $atts ) {
global $wp;
// Check cart class is loaded or abort.
if ( is_null( WC()->cart ) ) {
return;
}
// Backwards compatibility with old pay and thanks link arguments.
if ( isset( $_GET['order'] ) && isset( $_GET['key'] ) ) { // WPCS: input var ok, CSRF ok.
wc_deprecated_argument( __CLASS__ . '->' . __FUNCTION__, '2.1', '"order" is no longer used to pass an order ID. Use the order-pay or order-received endpoint instead.' );
// Get the order to work out what we are showing.
$order_id = absint( $_GET['order'] ); // WPCS: input var ok.
$order = wc_get_order( $order_id );
if ( $order && $order->has_status( OrderStatus::PENDING ) ) {
$wp->query_vars['order-pay'] = absint( $_GET['order'] ); // WPCS: input var ok.
} else {
$wp->query_vars['order-received'] = absint( $_GET['order'] ); // WPCS: input var ok.
}
}
// Handle checkout actions.
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
self::order_pay( $wp->query_vars['order-pay'] );
} elseif ( isset( $wp->query_vars['order-received'] ) ) {
self::order_received( $wp->query_vars['order-received'] );
} else {
self::checkout();
}
}