woocommerce_cart_contents_changed
Filters the entire cart contents when the cart changes.
Использование
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 of all cart items.
Список изменений
С версии 2.5.0 | Введена. |
Где вызывается хук
woocommerce_cart_contents_changed
woocommerce_cart_contents_changed
woocommerce/src/StoreApi/Utilities/CartController.php 165
$cart->cart_contents = apply_filters( 'woocommerce_cart_contents_changed', $cart->cart_contents );
woocommerce/includes/class-wc-cart.php 1285
$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 ) );