WooCommerce cart hook 'woocommerce_cart_contents' displaying content in the wrong position

Viewed 1919

I am trying to add content below the cart items and above the 'Apply Coupon' and 'Update Cart' buttons.

I am using the action hook woocommerce_cart_contents.

add_action('woocommerce_cart_contents', 'add_content');
function add_content(){
    echo 'The content';
} 

The echoed text is being displayed above the cart table.

enter image description here

I have tested this on two different websites and found the same issue. Any idea where I am going wrong?

1 Answers

It seems you are using the correct hook, but since it concerns table rows, wrap it in <table> tags

function add_content(){
    echo '<tr><td>The content</td></tr>';
}
add_action('woocommerce_cart_contents', 'add_content');
Related