I want to add ‘continue shopping’ / ‘add product’ link before order review on checkout page. But I want it to be inline with "Your order" text.
See this screenshot: https://ibb.co/47f6vd7
I tried this code:
add_action('woocommerce_checkout_order_review','woocommerce_checkout_before_order_review_add_product');
function woocommerce_checkout_before_order_review_add_product(){
$continue_shopping_url = wc_get_page_permalink( 'shop' );
$add_product_label = 'add product';
if(!empty($continue_shopping_url)){
echo "$add_product_label";
}
}
But it show on the line below "Your order" text. So it looks ugly.
How do i make it inline with "Your order" text using additional css?
2
Answers
First of all you are using the wrong hook.
While
woocommerce_checkout_order_review
will cause the text to be added insde the#order_review
div, thewoocommerce_checkout_before_order_review
hook will cause it to be placed before the#order_review
div.So you get:
Which CSS you will have to apply for this is completely theme dependent,
but using
display: inline-block;
can certainly come in handyMake sure you have a child theme setup. You can then add the ‘Continue shopping’ link via the
woocommerce_checkout_before_order_review
action hook:Add the above code snippet to the functions.php of your child theme. Then take care of the CSS styling in the style.css of your child theme.
For instance like this:
Which will give you the following result:
You will probably also have to add some CSS media queries to make this look good on mobile and tablet.