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:
<?php
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
Related Posts
Name: woogc/single_checkout/split_order/order_created
Type:Â Action
Arguments:Â $new_order
The `woogc/single_checkout/split_order/order_created` action...
The WordPress WooCommerce Global...
By default, on Product...
Name: woogc/ps/synchronize_product/child_product
Type:Â Filter
Arguments:
(object)$child_product
(array)$main_product_data
(int)$origin_product_blog_ID
This filter...
The WooCommerce Global Cart...
The Global Cart feature...
In the ever-evolving landscape of e-commerce, where seamless customer experiences are the cornerstone of success, WooCommerce Global Cart is now supporting the new WooCommerce Cart Blocks and Checkout Blocks, as powerful allies for merchants seeking to elevate their checkout processes. This groundbreaking integration seamlessly blends the benefits of Global Cart with the enhanced functionality of the new blocks, propelling businesses towards a paradigm shift in their online shopping journeys. Starting WooCommerce version 8.3 the Cart Blocks and Checkout Blocks are now the default checkout flow for new installations.
Name: woogc/ps/interfaces/sync_to_shop
Type:Â Filter
Arguments:Â $status, $remote_blog_id, $post
The...
Name: woogc/ps/synchronize_product/completed
Type:Â Filter
Arguments: $child_product_ID, $main_product_ID,...