Add new filter to allow modifications of cart contents

This commit is contained in:
Boro Sitnikovski 2018-08-14 18:34:52 +02:00
parent a19fff2da0
commit 1c4ef011d2
2 changed files with 7 additions and 0 deletions

View File

@ -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 ) ) ) {

View File

@ -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;