Search
Send email notification to Shop Owner, if a product was checked-out on a different site - WP Global Cart
15506
documentation-template-default,single,single-documentation,postid-15506,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
 

Send email notification to Shop Owner, if a product was checked-out on a different site

WP Global Cart / Send email notification to Shop Owner, if a product was checked-out on a different site
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

Send email notification to Shop Owner, if a product was checked-out on a different site

When using Single Site Check-out type, the Global Cart is being processed at a specified shop in the network or one at the customer preference. All Products will be included in a single order created on the site where the check-out occurs.

On shop Networks, where the owner chose to use Shop Managers to allow individual sites to be run by individual users, when a new Order is created on the Check-out Shop, a notification e-mail might be required to be sent to the shop where the product originated. A custom code can be used to achieve this functionality.

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


    add_action( 'woocommerce_checkout_update_order_meta', 'woogc_woocommerce_checkout_update_order_meta' ); 
    function woogc_woocommerce_checkout_update_order_meta (  $order_id )
        {
            $subject    =   'New Order';
                
            $order  =   wc_get_order( $order_id );
            foreach( $order->get_items() as  $key    =>  $order_item )
                {
                    switch_to_blog( $order_item->get_meta('blog_id') );
                            
                    $product_name           = $order_item->get_name();
                    $product_id             = $order_item->get_product_id();
                    $product_variation_id   = $order_item->get_variation_id();
                    
                    $message    =   "A new order has received which include a product from your shop: \n" . $product_name . " " . get_permalink($product_id);
                    
                    $to =   get_option('admin_email');
                    wp_mail( $to, $subject, $message );   
                    
                    restore_current_blog();
                } 
        }

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