WC_Cart::__construct PHP Method

__construct() public method

Constructor for the cart class. Loads options and hooks in the init method.
public __construct ( )
    public function __construct()
    {
        add_action('wp_loaded', array($this, 'init'));
        // Get cart after WP and plugins are loaded.
        add_action('wp', array($this, 'maybe_set_cart_cookies'), 99);
        // Set cookies
        add_action('shutdown', array($this, 'maybe_set_cart_cookies'), 0);
        // Set cookies before shutdown and ob flushing
        add_action('woocommerce_add_to_cart', array($this, 'calculate_totals'), 20, 0);
        add_action('woocommerce_applied_coupon', array($this, 'calculate_totals'), 20, 0);
    }

Usage Example

Exemplo n.º 1
0
 public function __construct()
 {
     _deprecated_function('woocommerce_cart', '1.4', 'WC_Cart()');
     parent::__construct();
 }
WC_Cart