Redirect all Carts to a specific Shop Cart - WP Global Cart
documentation-template-default,single,single-documentation,postid-15695,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

Redirect all Carts to a specific Shop Cart

WP Global Cart / Redirect all Carts to a specific Shop Cart
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

Redirect all Carts to a specific Shop Cart

Each of the Network Shops run their own cart page. This can be changed so the cart link redirects the user to a specific Shop Cart in the network, which is usually the Check-out Shop, when using Single Site Check-out type.

The feature can be achieved through a custom code. The WOOGC_REQUIRED_CART_URL value should be updated with the required shop cart URL:

    define('WOOGC_REQUIRED_CART_URL',             '--MainShopDomain--/cart/');

    add_action('init', 'custom_init');
    function custom_init()
            ob_start( "custom_ob_callback");
    function custom_ob_callback( $buffer ) 
            $current_site_url   =   wc_get_cart_url();   
            $current_site_url   =   preg_replace('/:[0-9]+/', '', str_replace(array ("https://" , "http://"), "", $current_site_url ));
            $current_site_url   =   trailingslashit( $current_site_url );
            $buffer =   str_ireplace( $current_site_url, WOOGC_REQUIRED_CART_URL, $buffer);
            //jsonencoded replacements
            $buffer =   str_ireplace(   trim( json_encode( $current_site_url ), '"' )  , trim( json_encode( WOOGC_REQUIRED_CART_URL ), '"' ) , $buffer  );
            return $buffer;   


*The code should be placed into a custom file on /wp-content/mu-plugins/ or theme functions.php

Would love your thoughts, please comment.x