• Resolved webenthusiast

    (@adityabajaj)


    With regards to WooCommerce on WordPress, how do I override the cart and checkout URL for specific page ID?

    One of the plugins I am using is using wc_get_cart_url() to get cart URL for example. I am looking for a hook or something that will override the cart and checkout page URLs for that specific page.

    Please provide specific code if you can. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter webenthusiast

    (@adityabajaj)

    Here is the code I am trying:

    
    //checkout url
    add_filter('woocommerce_get_checkout_url', 'my_checkout');
    function my_checkout($url) { 
    	global $woocommerce; 
    	global $post;
    	//echo "<script>$(document.body).trigger('wc_fragment_refresh');</script>";
    	if(is_page(4390) ){
    		return $checkout_url = '/whatevercheckout';
    	}
    	else {
    		return $checkout_url = '/checkout';
    	}
    }
    
    //cart url
    add_filter('woocommerce_get_cart_url', 'my_cart_url');
    function my_cart_url($url) { 
    	global $woocommerce; 
    	global $post;
    
    	if(is_page(4390) ){
    		return $cart_url = '/whatevercart';
    	}
    	else {
    		return $cart_url = '/cart';
    	}
    }
    
    • This reply was modified 4 years, 4 months ago by Yui.
    • This reply was modified 4 years, 4 months ago by Yui. Reason: please use CODE button for proper formatting
    Kenin

    (@kbassart)

    Automattic Happiness Engineer

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the following places for more development-oriented questions:

    1. WooCommerce Slack Community: https://woocommerce.com/community-slack/
    2. WooCommerce FB group: https://www.facebook.com/groups/advanced.woocommerce/
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Override Cart and Checkout URL for specific page’ is closed to new replies.