Tagged: Cart, hook, shipping, woocommerce
Hello there,
i tried to insert individual text after the shipping rates in cart page.
Link to image where i show on which position the text should appear: https://cloud.boehm.media/index.php/s/eCiPLPnZiJwMekK
So i tried to use the hook “woocommerce_cart_totals_after_shipping” (as mentioned in the visual hook page of: https://www.businessbloomer.com/woocommerce-visual-hook-guide-cart-page/).
Unfortunately it appears on top of the shipping section :-(
This is the result: (Link to image) https://cloud.boehm.media/index.php/s/cyuPC0lHch6XKjK
I hope, you can name me the right hook.
Thanks a lot
Kind regards
Bernd
Hey boehmmedia,
I believe that you do have the right hook, but that you have not added any html tags to add text into the table, since I assume that your function looks something like this with just plan text:
add_action('woocommerce_cart_totals_after_shipping', 'why_pay_shipping');
function why_pay_shipping() {
if (WC()->cart->cart_contents_total) {
echo '▸ Warum bezahle ich Versandkosten';
}
}
and you are getting this result:
to add the text into the table you need to add a table tag like this:
add_action('woocommerce_cart_totals_after_shipping', 'why_pay_shipping');
function why_pay_shipping() {
if (WC()->cart->cart_contents_total) {
echo '<td colspan="2" style="text-align:center;">▸ Warum bezahle ich Versandkosten</td>';
}
}
this is the new result:
please give this a try.
Best regards,
Mike
Hi Mike,
thanks a lot for help :-) and sorry, that i doesn’t share my code :-(
As i want to illustrate my issue i forget to copy the code into the post :-(
With your help now it works. I have not realised that the shipping fees are ordered in a table.
Your code works fine.
Kind regards
Bernd