CartCheckout
extends AbstractCart
in package
Cart Checkout Route
Processes checkout from cart for express payment methods
Tags
Table of Contents
Properties
- $payment_method : WC_Payment_Gateway_Stripe
- $request : WP_REST_Request
Methods
- filter_posted_data() : array<string|int, mixed>
- Filter checkout posted data
- get_error_response() : WP_Error
- Convert exceptions/WP_Error to error responses
- get_full_path() : string
- Get full path including namespace
- get_namespace() : string
- Get the route namespace
- get_path() : string
- Get the route path
- get_routes() : array<string|int, mixed>
- Get route configuration
- handle_checkout_validation() : mixed
- Handle checkout validation errors
- handle_delete_request() : mixed
- Handle DELETE request
- handle_get_request() : mixed
- Handle GET request
- handle_post_request() : void
- Handle POST request - Process checkout
- handle_put_request() : mixed
- Handle PUT request
- handle_request() : WP_REST_Response|WP_Error
- Handle REST request
- validate_payment_method() : bool
- Validate payment method
- calculate_totals() : void
- Calculate cart totals
- clear_cached_shipping_rates() : void
- Clear cached shipping rates
- get_payment_method_from_request() : WC_Payment_Gateway|null
- Get payment gateway from request
- get_wc_notice() : string
- Get WooCommerce notice
- populate_post_data() : mixed
- Populate $_POST and $_REQUEST with request data
- apply_product_gateway_options() : mixed
- Apply product-specific gateway options
- create_customer() : mixed
- Create customer account for guest users
- get_order_review_url() : string
- Get order review URL with encoded payment data
- initialize() : mixed
- Initialize hooks for checkout processing
- prepare_request_params() : mixed
- Prepare and normalize request parameters
- set_required_fields() : mixed
- Set required POST fields for checkout
Properties
$payment_method
private
WC_Payment_Gateway_Stripe
$payment_method
$request
private
WP_REST_Request
$request
Methods
filter_posted_data()
Filter checkout posted data
public
filter_posted_data(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
Posted checkout data
Return values
array<string|int, mixed>get_error_response()
Convert exceptions/WP_Error to error responses
public
get_error_response(Exception|WP_Error $error) : WP_Error
Parameters
- $error : Exception|WP_Error
Return values
WP_Errorget_full_path()
Get full path including namespace
public
get_full_path() : string
Return values
stringget_namespace()
Get the route namespace
public
get_namespace() : string
Return values
stringget_path()
Get the route path
public
get_path() : string
Return values
stringget_routes()
Get route configuration
public
get_routes() : array<string|int, mixed>
Return values
array<string|int, mixed>handle_checkout_validation()
Handle checkout validation errors
public
handle_checkout_validation(array<string|int, mixed> $data, WP_Error $errors) : mixed
Parameters
- $data : array<string|int, mixed>
-
Posted data
- $errors : WP_Error
-
Validation errors
handle_delete_request()
Handle DELETE request
public
handle_delete_request(WP_REST_Request $request) : mixed
Parameters
- $request : WP_REST_Request
Tags
handle_get_request()
Handle GET request
public
handle_get_request(WP_REST_Request $request) : mixed
Parameters
- $request : WP_REST_Request
Tags
handle_post_request()
Handle POST request - Process checkout
public
handle_post_request(WP_REST_Request $request) : void
Parameters
- $request : WP_REST_Request
handle_put_request()
Handle PUT request
public
handle_put_request(WP_REST_Request $request) : mixed
Parameters
- $request : WP_REST_Request
Tags
handle_request()
Handle REST request
public
handle_request(WP_REST_Request $request) : WP_REST_Response|WP_Error
Routes to appropriate method handler based on HTTP method
Parameters
- $request : WP_REST_Request
Return values
WP_REST_Response|WP_Errorvalidate_payment_method()
Validate payment method
public
validate_payment_method(string $payment_method, WP_REST_Request $request) : bool
Parameters
- $payment_method : string
-
Payment method ID
- $request : WP_REST_Request
-
Request object
Return values
boolcalculate_totals()
Calculate cart totals
protected
calculate_totals() : void
clear_cached_shipping_rates()
Clear cached shipping rates
protected
clear_cached_shipping_rates() : void
Forces WooCommerce to recalculate shipping rates
get_payment_method_from_request()
Get payment gateway from request
protected
get_payment_method_from_request(WP_REST_Request $request) : WC_Payment_Gateway|null
Parameters
- $request : WP_REST_Request
Return values
WC_Payment_Gateway|nullget_wc_notice()
Get WooCommerce notice
protected
get_wc_notice([string $notice_type = '' ][, string $default = '' ]) : string
Parameters
- $notice_type : string = ''
-
Notice type (error, success, notice)
- $default : string = ''
-
Default message if no notice found
Return values
stringpopulate_post_data()
Populate $_POST and $_REQUEST with request data
protected
populate_post_data(WP_REST_Request $request) : mixed
Some 3rd party plugins depend on $_POST being populated
Parameters
- $request : WP_REST_Request
apply_product_gateway_options()
Apply product-specific gateway options
private
apply_product_gateway_options() : mixed
create_customer()
Create customer account for guest users
private
create_customer(WP_REST_Request $request) : mixed
Parameters
- $request : WP_REST_Request
Tags
get_order_review_url()
Get order review URL with encoded payment data
private
get_order_review_url() : string
Return values
stringinitialize()
Initialize hooks for checkout processing
private
initialize() : mixed
prepare_request_params()
Prepare and normalize request parameters
private
prepare_request_params(WP_REST_Request $request) : mixed
Parameters
- $request : WP_REST_Request
set_required_fields()
Set required POST fields for checkout
private
set_required_fields() : mixed