Merge pull request #21051 from woocommerce/feature/add-cart-contents-filter
Add new filter to allow modifications of cart contents
This commit is contained in:
commit
41a9994e52
|
@ -130,6 +130,11 @@ final class WC_Cart_Session {
|
|||
}
|
||||
}
|
||||
|
||||
// If it's not empty, it's been already populated by the loop above.
|
||||
if ( ! empty( $cart_contents ) ) {
|
||||
$this->cart->set_cart_contents( apply_filters( 'woocommerce_cart_contents_changed', $cart_contents ) );
|
||||
}
|
||||
|
||||
do_action( 'woocommerce_cart_loaded_from_session', $this->cart );
|
||||
|
||||
if ( $update_cart_session || is_null( WC()->session->get( 'cart_totals', null ) ) ) {
|
||||
|
|
|
@ -1093,6 +1093,8 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
);
|
||||
}
|
||||
|
||||
$this->cart_contents = apply_filters( 'woocommerce_cart_contents_changed', $this->cart_contents );
|
||||
|
||||
do_action( 'woocommerce_add_to_cart', $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data );
|
||||
|
||||
return $cart_item_key;
|
||||
|
|
Loading…
Reference in New Issue