CartShipping
extends AbstractCart
in package
Cart Shipping Route
Handles shipping address and method updates for express checkout Used by Link, Apple Pay, Google Pay payment sheets
Tags
Table of Contents
Methods
- 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_delete_request() : mixed
- Handle DELETE request
- handle_get_request() : mixed
- Handle GET request
- handle_post_request() : array<string|int, mixed>|WP_Error
- Handle POST request - Update shipping
- 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_shipping_response() : array<string|int, mixed>
- Get shipping response data
- get_wc_notice() : string
- Get WooCommerce notice
- has_shipping_options() : bool
- Check if the shipping response contains available shipping options.
- is_address_complete() : bool
- Check if address is complete enough to require shipping
- normalize_state() : string
- Normalize state code for country
- populate_post_data() : mixed
- Populate $_POST and $_REQUEST with request data
- update_shipping_address() : void
- Update customer shipping address
- update_shipping_method() : void
- Update selected shipping method
- add_postcode_format_filter() : mixed
Methods
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_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 - Update shipping
public
handle_post_request(WP_REST_Request $request) : array<string|int, mixed>|WP_Error
Parameters
- $request : WP_REST_Request
Return values
array<string|int, mixed>|WP_Errorhandle_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_shipping_response()
Get shipping response data
protected
get_shipping_response() : array<string|int, mixed>
Return values
array<string|int, mixed>get_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
stringhas_shipping_options()
Check if the shipping response contains available shipping options.
protected
has_shipping_options(array<string|int, mixed> $response) : bool
Parameters
- $response : array<string|int, mixed>
Return values
boolis_address_complete()
Check if address is complete enough to require shipping
protected
is_address_complete(array<string|int, mixed>|null $address) : bool
Parameters
- $address : array<string|int, mixed>|null
-
Address data
Return values
boolnormalize_state()
Normalize state code for country
protected
normalize_state(string $state, string $country) : string
Parameters
- $state : string
-
State code or name
- $country : string
-
Country code
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
update_shipping_address()
Update customer shipping address
protected
update_shipping_address(array<string|int, mixed> $address) : void
Parameters
- $address : array<string|int, mixed>
-
Address data
update_shipping_method()
Update selected shipping method
protected
update_shipping_method(string $shipping_method) : void
Parameters
- $shipping_method : string
-
Shipping method ID
add_postcode_format_filter()
private
add_postcode_format_filter(mixed $country) : mixed
Parameters
- $country : mixed