PHP Class WC_Checkout

The WooCommerce checkout class handles the checkout process, collecting user data and processing the payment.
Author: WooThemes
Afficher le fichier Open project: woocommerce/woocommerce Class Usage Examples

Protected Properties

Свойство Type Description
$fields array | null Checkout fields are stored here.
$instance WC_Checkout | null The single instance of the class.

Méthodes publiques

Méthode Description
__clone ( ) Cloning is forbidden.
__get ( string $key ) : string Gets the legacy public variables for backwards compatibility.
__isset ( string $key ) : boolean See if variable is set. Used to support legacy public variables which are no longer defined.
__set ( string $key, mixed $value ) Sets the legacy public variables for backwards compatibility.
__wakeup ( ) Unserializing instances of this class is forbidden.
check_cart_items ( ) When we process the checkout, lets ensure cart items are rechecked to prevent checkout.
checkout_form_billing ( ) Output the billing form.
checkout_form_shipping ( ) Output the shipping form.
create_order ( $data ) : integer | WP_ERROR Create an order. Error codes: 520 - Cannot insert order into the database.
get_checkout_fields ( string $fieldset = '' ) : array Get an array of checkout fields.
get_posted_address_data ( string $key, string $type = 'billing' ) : string Get a posted address field after sanitization and validation.
get_value ( string $input ) : string | null Gets the value either from the posted data, or from the users meta data.
instance ( ) : WC_Checkout Gets the main WC_Checkout Instance.
is_registration_enabled ( ) : boolean Is registration enabled on the checkout page?
is_registration_required ( ) : boolean Is registration required to checkout?
process_checkout ( ) Process the checkout after the confirm order button is pressed.

Méthodes protégées

Méthode Description
create_order_coupon_lines ( WC_Order &$order ) Add coupon lines to the order.
create_order_fee_lines ( WC_Order &$order ) Add fees to the order.
create_order_line_items ( WC_Order &$order ) Add line items to the order.
create_order_shipping_lines ( WC_Order &$order ) Add shipping lines to the order.
create_order_tax_lines ( WC_Order &$order ) Add tax lines to the order.
get_posted_data ( ) : array Get posted data from the checkout form.
maybe_skip_fieldset ( string $fieldset_key, array $data ) See if a fieldset should be skipped.
process_customer ( array $data ) Create a new customer account if needed.
process_order_payment ( integer $order_id, string $payment_method ) Process an order that does require payment.
process_order_without_payment ( integer $order_id ) Process an order that doesn't require payment.
send_ajax_failure_response ( ) If checkout failed during an AJAX call, send failure response.
update_session ( array $data ) Update customer and session data from the posted checkout data.
validate_checkout ( array &$data, WP_Error &$errors ) Validates that the checkout has enough info to proceed.
validate_posted_data ( array &$data, WP_Error &$errors ) Validates the posted checkout data based on field properties.

Method Details

__clone() public méthode

Cloning is forbidden.
public __clone ( )

__get() public méthode

Gets the legacy public variables for backwards compatibility.
public __get ( string $key ) : string
$key string
Résultat string

__isset() public méthode

See if variable is set. Used to support legacy public variables which are no longer defined.
public __isset ( string $key ) : boolean
$key string
Résultat boolean

__set() public méthode

Sets the legacy public variables for backwards compatibility.
public __set ( string $key, mixed $value )
$key string
$value mixed

__wakeup() public méthode

Unserializing instances of this class is forbidden.
public __wakeup ( )

check_cart_items() public méthode

When we process the checkout, lets ensure cart items are rechecked to prevent checkout.
public check_cart_items ( )

checkout_form_billing() public méthode

Output the billing form.

checkout_form_shipping() public méthode

Output the shipping form.

create_order() public méthode

521 - Cannot get order after creation. 522 - Cannot update order. 525 - Cannot create line item. 526 - Cannot create fee item. 527 - Cannot create shipping item. 528 - Cannot create tax item. 529 - Cannot create coupon item.
public create_order ( $data ) : integer | WP_ERROR
$data Posted data.
Résultat integer | WP_ERROR

create_order_coupon_lines() protected méthode

Add coupon lines to the order.
protected create_order_coupon_lines ( WC_Order &$order )
$order WC_Order

create_order_fee_lines() protected méthode

Add fees to the order.
protected create_order_fee_lines ( WC_Order &$order )
$order WC_Order

create_order_line_items() protected méthode

Add line items to the order.
protected create_order_line_items ( WC_Order &$order )
$order WC_Order

create_order_shipping_lines() protected méthode

Add shipping lines to the order.
protected create_order_shipping_lines ( WC_Order &$order )
$order WC_Order

create_order_tax_lines() protected méthode

Add tax lines to the order.
protected create_order_tax_lines ( WC_Order &$order )
$order WC_Order

get_checkout_fields() public méthode

Get an array of checkout fields.
public get_checkout_fields ( string $fieldset = '' ) : array
$fieldset string to get.
Résultat array

get_posted_address_data() public méthode

Get a posted address field after sanitization and validation.
public get_posted_address_data ( string $key, string $type = 'billing' ) : string
$key string
$type string billing for shipping
Résultat string

get_posted_data() protected méthode

Get posted data from the checkout form.
Since: 2.7.0
protected get_posted_data ( ) : array
Résultat array of data and errors.

get_value() public méthode

Gets the value either from the posted data, or from the users meta data.
public get_value ( string $input ) : string | null
$input string
Résultat string | null

instance() public static méthode

Gets the main WC_Checkout Instance.
Since: 2.1
public static instance ( ) : WC_Checkout
Résultat WC_Checkout Main instance

is_registration_enabled() public méthode

Is registration enabled on the checkout page?
Since: 2.7.0
public is_registration_enabled ( ) : boolean
Résultat boolean

is_registration_required() public méthode

Is registration required to checkout?
Since: 2.7.0
public is_registration_required ( ) : boolean
Résultat boolean

maybe_skip_fieldset() protected méthode

See if a fieldset should be skipped.
Since: 2.7.0
protected maybe_skip_fieldset ( string $fieldset_key, array $data )
$fieldset_key string
$data array

process_checkout() public méthode

Process the checkout after the confirm order button is pressed.
public process_checkout ( )

process_customer() protected méthode

Create a new customer account if needed.
protected process_customer ( array $data )
$data array

process_order_payment() protected méthode

Process an order that does require payment.
Since: 2.7.0
protected process_order_payment ( integer $order_id, string $payment_method )
$order_id integer
$payment_method string

process_order_without_payment() protected méthode

Process an order that doesn't require payment.
Since: 2.7.0
protected process_order_without_payment ( integer $order_id )
$order_id integer

send_ajax_failure_response() protected méthode

If checkout failed during an AJAX call, send failure response.

update_session() protected méthode

Update customer and session data from the posted checkout data.
Since: 2.7.0
protected update_session ( array $data )
$data array

validate_checkout() protected méthode

Validates that the checkout has enough info to proceed.
Since: 2.7.0
protected validate_checkout ( array &$data, WP_Error &$errors )
$data array An array of posted data.
$errors WP_Error

validate_posted_data() protected méthode

Validates the posted checkout data based on field properties.
Since: 2.7.0
protected validate_posted_data ( array &$data, WP_Error &$errors )
$data array An array of posted data.
$errors WP_Error

Property Details

$fields protected_oe property

Checkout fields are stored here.
protected array|null $fields
Résultat array | null

$instance protected_oe static_oe property

The single instance of the class.
protected static WC_Checkout|null $instance
Résultat WC_Checkout | null