different cart content for different woocommerce mini-cart

by Yasir   Last Updated January 11, 2019 11:08 AM - source

i have two different categories for woocommerce products, when i'm on category A page there should be products in mini cart section from category A only.

and when on category B there should only be category b products in mini cart.

i have mini-cart.php and other is mini-cart-b.php

when i click "add to cart" it out puts perfect data against category only products, but when i click on category B LINK mini cart shows category A products :( and this is the problem. and if i click add to cart on category B page than it gets updated with products against this category.

what i want to understand is when page loads how data is populated in mini-cart which file is being used or data comes from session ?

if it comes from session how i can edit it on page redirect

this is how i'm showing different products for different categories

first creating index on WC()->cart->get_cart() object

foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {

            $terms = wp_get_post_terms($cart_item['data']->id, 'product_cat' );
            $products_by_categories[$terms[0]->name][] = $cart_item;
            $cart_keys[$cart_item['product_id']] = $cart_item_key;
        }

than looping through products_by_categories

foreach ( $products_by_categories as $cat_name => $cart_items ) {

listing products

foreach ( $cart_items as $tmp_index => $cart_item ) {
Tags : woocommerce


Related Questions


How can add and preview product Frontend

Updated March 26, 2015 12:02 PM


How to add "Reply-to" in Woocommerce

Updated April 04, 2015 15:03 PM


WooCommerce epdq gateway Change order status

Updated April 06, 2015 19:03 PM