a
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudanti.
a
Follow Me
Search
Loop though the Cart items - WooCommerce MultiSite Global Cart
15795
documentation-template-default,single,single-documentation,postid-15795,theme-awake,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-6.3.0,vc_responsive
 

Loop though the Cart items

WooCommerce MultiSite Global Cart / Loop though the Cart items
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

Loop though the Cart items

Looping through the Cart Items is straightforward and achievable through the code:

    $cart_items = WC()->cart->get_cart();
    foreach ( $cart_items as $cart_key => $item )
        {
            //custom code
        }

When the cart include products from different shops ( within the MultiSite Netowrk ), the same code can be used. Still, a switch to the product shop is required, for the inner code to be able to correctly retrieve the data. The easiest approach will be to add 2 actions as the example:

    $cart_items = WC()->cart->get_cart();
    foreach ( $cart_items as $cart_key => $item )
        {
            do_action( 'woocommerce/cart_loop/start', $item );
            
            //custom code
            
            do_action( 'woocommerce/cart_loop/end', $item );
        }