简体   繁体   English

WooCommerce 购物车挂钩“woocommerce_cart_contents”显示内容错误 position

[英]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 .我正在使用动作挂钩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看来您使用的是正确的钩子,但由于它涉及表格行,请将其包装在<table>标记中

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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