Search
When Splitting the order, show only split transactions on the checkout shop - WP Global Cart
16770
documentation-template-default,single,single-documentation,postid-16770,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
 

When Splitting the order, show only split transactions on the checkout shop

WP Global Cart / When Splitting the order, show only split transactions on the checkout shop
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

When Splitting the order, show only split transactions on the checkout shop

Splitting Orders, is a powerful tool when working with separate shop managers and merchants. That helps to create split orders with products that belong to different shops in the network. So each of the shops that had at least one product in the cart, will receive an order with its own products.

A split can be ignored for the shop, where the check-out occurs. Or the main order can be hidden, on the checkout site and show the split Order instead, to avoid confusion. That can be achieved through a custom code.

The following code should be placed in a custom file inside you /wp-content/mu-plugins folder. If the folder does not exist on your WordPress, you should create it manually.


    add_action ( 'pre_get_posts' , '_pre_get_posts');
    function _pre_get_posts( $query_object )
        {
            global $blog_id, $WooGC;
            
            $plugin_options =   $WooGC->functions->get_options();
            
            if ( $plugin_options['cart_checkout_type']  !=  'single_checkout' )
                return;
                
            if ( $blog_id != 1 )
                return;
            
            if ( ! is_admin() ||    strpos( $_SERVER['SCRIPT_NAME'], '/edit.php' )  === FALSE   ||  strpos( $_SERVER['REQUEST_URI'], 'post_type=shop_order' )   === FALSE )
                return;
            
            $query_object->query_vars['meta_key']        =   'checkout_order_id';   
            $query_object->query_vars['meta_value']      =   '1';
            $query_object->query_vars['meta_compare']    =   '>';            
        }

The code automatically can pick up your check-out shop and check against that, before the code run:


    add_action ( 'pre_get_posts' , '_pre_get_posts');
    function _pre_get_posts( $query_object )
        {
            global $blog_id, $WooGC;
            
            $plugin_options =   $WooGC->functions->get_options();
            
            if ( $plugin_options['cart_checkout_type']  !=  'single_checkout' )
                return;
                
            if ( $blog_id != $plugin_options['cart_checkout_location'] )
                return;
            
            if ( ! is_admin() ||    strpos( $_SERVER['SCRIPT_NAME'], '/edit.php' )  === FALSE   ||  strpos( $_SERVER['REQUEST_URI'], 'post_type=shop_order' )   === FALSE )
                return;
            
            $query_object->query_vars['meta_key']        =   'checkout_order_id';   
            $query_object->query_vars['meta_value']      =   '1';
            $query_object->query_vars['meta_compare']    =   '>';            
        }

0
Would love your thoughts, please comment.x
()
x