Woocommerce – How to change a link in php checkout page

I want to insert / change a link on my checkout page, but am not sure how to change the code so it appears correctly. Hoping someone might be able to shed some light. I research & tried a number of things, but kept getting error pages. All I am trying to do is change the “Cart” link to be another link. But since the cart link isn’t formatted like a regular link, I’m not sure what to replace to get it to show properly. I want to just replace it with a regular URL (https://sprinly.com/subscription-plans).

Thanks in advance!!

Read More

Screenshot of what I am trying to change

add_action( 'woocommerce_checkout_before_order_review', 'my_wc_checkout_before_order_review', 10, 0 );
function my_wc_checkout_before_order_review() {
echo '<p class="return-to-cart">If you'd like to change your subscription, go back to <a href="'. WC()->cart->get_cart_url() .'">Cart</a>. </p>';

}

Related posts

1 comment

  1. You need to replace the PHP that is generating the cart link (WC()->cart->get_cart_url()) with the URL, like so:

    add_action( 'woocommerce_checkout_before_order_review', 'my_wc_checkout_before_order_review', 10, 0 );
    function my_wc_checkout_before_order_review() {
        echo '<p class="return-to-cart">If you'd like to change your subscription, go back to <a href="https://sprinly.com/subscription-plans">Cart</a>. </p>';
    }
    

Comments are closed.