WC_Cart::__construct()
Constructor for the cart class. Loads options and hooks in the init method.
Description Description
Source Source
File: includes/class-wc-cart.php
public function __construct() { $this->session = new WC_Cart_Session( $this ); $this->fees_api = new WC_Cart_Fees( $this ); $this->tax_display_cart = $this->is_tax_displayed(); // 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 ); }