WC_Cart::__construct()publicWC 1.0

Constructor for the cart class. Loads options and hooks in the init method.

Method of the class: WC_Cart{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Cart = new WC_Cart();
$WC_Cart->__construct();

WC_Cart::__construct() code WC 8.7.0

public function __construct() {
	$this->session  = new WC_Cart_Session( $this );
	$this->fees_api = new WC_Cart_Fees();

	// Register hooks for the objects.
	$this->session->init();

	add_action( 'woocommerce_add_to_cart', array( $this, 'calculate_totals' ), 20, 0 );
	add_action( 'woocommerce_applied_coupon', array( $this, 'calculate_totals' ), 20, 0 );
	add_action( 'woocommerce_cart_item_removed', array( $this, 'calculate_totals' ), 20, 0 );
	add_action( 'woocommerce_cart_item_restored', array( $this, 'calculate_totals' ), 20, 0 );
	add_action( 'woocommerce_check_cart_items', array( $this, 'check_cart_items' ), 1 );
	add_action( 'woocommerce_check_cart_items', array( $this, 'check_cart_coupons' ), 1 );
	add_action( 'woocommerce_after_checkout_validation', array( $this, 'check_customer_coupons' ), 1, 2 );
}