WordPress at Your Fingertips
function is not described

WC_Cart_Session::init() public WC 1.0

Register methods for this object on the appropriate WordPress hooks.

{} It's a method of the class: WC_Cart_Session{}

No Hooks.

Return

null. Nothing.

Usage

$WC_Cart_Session = new WC_Cart_Session();
$WC_Cart_Session->init();

Code of WC_Cart_Session::init() WC 5.9.0

public function init() {
	add_action( 'wp_loaded', array( $this, 'get_cart_from_session' ) );
	add_action( 'woocommerce_cart_emptied', array( $this, 'destroy_cart_session' ) );
	add_action( 'woocommerce_after_calculate_totals', array( $this, 'set_session' ) );
	add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'set_session' ) );
	add_action( 'woocommerce_removed_coupon', array( $this, 'set_session' ) );

	// Persistent cart stored to usermeta.
	add_action( 'woocommerce_add_to_cart', array( $this, 'persistent_cart_update' ) );
	add_action( 'woocommerce_cart_item_removed', array( $this, 'persistent_cart_update' ) );
	add_action( 'woocommerce_cart_item_restored', array( $this, 'persistent_cart_update' ) );
	add_action( 'woocommerce_cart_item_set_quantity', array( $this, 'persistent_cart_update' ) );

	// Cookie events - cart cookies need to be set before headers are sent.
	add_action( 'woocommerce_add_to_cart', array( $this, 'maybe_set_cart_cookies' ) );
	add_action( 'wp', array( $this, 'maybe_set_cart_cookies' ), 99 );
	add_action( 'shutdown', array( $this, 'maybe_set_cart_cookies' ), 0 );
}