【问题标题】:Woocommerce - adding link under add to cart buttonWoocommerce - 在添加到购物车按钮下添加链接
【发布时间】:2021-08-06 18:25:27
【问题描述】:

下午好,

我整个上午都在网上搜索,试图在单个产品页面的“添加到购物车”按钮下添加“查看购物车”链接。

我正在尝试这样做,因为我只想在购物车中有商品时看到购物车的链接,而不是将其添加到主站点菜单中。

我试过这个 sn-p 但它什么也没做:

add_action( 'woocommerce_after_single_product_summary', 'add_cart_link', 0   );

function add_custom_field() {
global $post;

echo "something here";

return true;
}

我不确定最好的解决方案是什么...有人遇到过可行的解决方案吗?

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    将以下代码添加到您主题的functions.php

    add_action('woocommerce_after_add_to_cart_button','view_cart_text');
    
    function view_cart_text(){
        echo '<button type="submit" class="single_add_to_cart_button button alt">View cart</button>';
    }
    

    显然你需要根据你的主题做一些 CSS 或样式。但它会给你想要达到的结果。

    【讨论】:

    • 这正是我想要的,非常感谢:-)
    • 对于其他感兴趣的人,该按钮确实有效,但您必须更改链接,因为上面的链接会将产品添加到购物篮/而不是带您去结账。
    猜你喜欢
    • 2018-10-30
    • 2018-05-08
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-03
    • 2016-07-18
    相关资源
    最近更新 更多