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
This newly implemented functionality helps with displaying WooCommerce Products across shops, in the network, under your WordPress MultiSite environment. Promote specific products, types of merchandise, category of goods, so boosting overall network sales. The new function is available as a Woocommerce Product Shortcode and is easy to implement. Any section of a site can include the shortcode to output the required products. The woocommerce shortcode is usable within the default WordPress editor ( classic ) or any advanced layout composer like Elementor, Divi, Visual Builder etc.
WooCommerce Tax area provides...
Name: woogc/get_cart_from_session/validate_hash
Type:Â Filter
Arguments:Â $force_validation, $values
When reconstructing...
Incredibly flexible, the WooCommerce...
On the Synchronization screen...
Name: woogc/network_orders/get_orders/mysql_query/GROUP_BY
Type:Â Filter
Arguments:Â $mysql_query, $blog_id
The filter...
Name: woogc/network_orders/get_orders/mysql_query/JOIN
Type:Â Filter
Arguments:Â $mysql_query, $blog_id
The filter...
Name: woogc/network_orders/get_orders/mysql_query/SELECT
Type:Â Filter
Arguments:Â $mysql_query, $blog_id
The filter...
Deprecated notice: The recent...
The WooCommerce Global Cart...