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:
Claudiu Lodromanean 2018-08-14 13:02:25 -07:00 committed by GitHub
commit 41a9994e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;