简体   繁体   中英

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

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.

在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM