woocommerce_cart_contents_changed filter-hookWC 2.5.0

Filters the entire cart contents when the cart changes.

Usage

add_filter( 'woocommerce_cart_contents_changed', 'wp_kama_woocommerce_cart_contents_changed_filter' );

/**
 * Function for `woocommerce_cart_contents_changed` filter-hook.
 * 
 * @param array $cart_contents Array of all cart items.
 *
 * @return array
 */
function wp_kama_woocommerce_cart_contents_changed_filter( $cart_contents ){

	// filter...
	return $cart_contents;
}
$cart_contents(array)
Array of all cart items.

Changelog

Since 2.5.0 Introduced.

Where the hook is called

CartController::add_to_cart()
woocommerce_cart_contents_changed
WC_Cart::add_to_cart()
woocommerce_cart_contents_changed
WC_Cart_Session::get_cart_from_session()
woocommerce_cart_contents_changed
woocommerce/src/StoreApi/Utilities/CartController.php 146
$cart->cart_contents = apply_filters( 'woocommerce_cart_contents_changed', $cart->cart_contents );
woocommerce/includes/class-wc-cart.php 1284
$this->cart_contents = apply_filters( 'woocommerce_cart_contents_changed', $this->cart_contents );
woocommerce/includes/class-wc-cart-session.php 216
$this->cart->set_cart_contents( apply_filters( 'woocommerce_cart_contents_changed', $cart_contents ) );

Where the hook is used in WooCommerce

Usage not found.