【问题标题】:WooCommerce cart hook 'woocommerce_cart_contents' displaying content in the wrong positionWooCommerce 购物车挂钩“woocommerce_cart_contents”在错误位置显示内容
【发布时间】:2020-08-31 20:12:46
【问题描述】:

我正在尝试在购物车项目下方以及“应用优惠券”和“更新购物车”按钮上方添加内容。

我正在使用动作钩子woocommerce_cart_contents

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

回显的文本显示在购物车表上方。

我在两个不同的网站上对此进行了测试,发现了同样的问题。知道我哪里出错了吗?

【问题讨论】:

    标签: php html wordpress woocommerce hook-woocommerce


    【解决方案1】:

    您似乎使用了正确的hook,但由于它涉及表格行,请将其包装在<table> 标签中

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

    【讨论】:

      猜你喜欢
      • 2016-03-14
      • 2017-12-01
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 2015-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多