Search
Display the Product Title along the Shop Name where it come from the network - WP Global Cart
14452
documentation-template-default,single,single-documentation,postid-14452,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
 

Display the Product Title along the Shop Name where it come from the network

WP Global Cart / Display the Product Title along the Shop Name where it come from the network
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

Display the Product Title along the Shop Name where it come from the network

Using the WooCommerce Global Cart all shops in the network can share the same cart, products from different sites can be added and checked-out in a single process. To make cart content more descriptive and clearer to the customers, a shop name can be append to each product title, to indicate the location where the product come from. Also, other necessary information can append, if apply.

The following bit of code appends the origin Shop name, to each product title as the above image show:

    add_filter('woocommerce_cart_item_name', 'woocommerce_cart_item_name', 10, 3);
    function woocommerce_cart_item_name( $product_name, $cart_item, $cart_item_key)
        {
            
            if( !   isset($cart_item['blog_id'])    ||  $cart_item['blog_id']   ==  '')
                return $product_name;
                
            $site_data  =   get_blog_details( $cart_item['blog_id'] );
               
            if(isset($site_data->blogname)    &&  $site_data->blogname  !=  '')
                $product_name   .=  ' - (' .  $site_data->blogname . ')';
            
            return $product_name;
        }
2
0
Would love your thoughts, please comment.x
()
x