wordpress - Woocommerce - How to change a link in php checkout page

613

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!!

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>';

}
246

Answer

Solution:

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>';
}

People are also looking for solutions to the problem: html - Display Category Name via functions.php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.