在woocommerce里如何自定义add to cart 按钮文字和修改链接到产品页

本文介绍如何在WooCommerce中自定义“加入购物车”按钮的文字及链接,通过在子主题的functions.php文件中添加特定代码实现。适用于产品列表页。

在woocommerce里如何自定义add to cart 按钮文字和修改链接到产品页(在产品列表页上的按钮)

how to change add to cart button text and link in woocommerce shop and archieve page。

在子主题的functions文件中添加如下代码即可:

add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 2 );
function replacing_add_to_cart_button( $button, $product  ) {
    $button_text = __("My_custom_text", "woocommerce");
    $button = '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';

    return $button;
}

上面的代码中,第三行中的"My_custom_text" 这里就是自定义后的文字。

第四行中的class="button",这个是按钮的样式,可以根据实际情况修改成主题所用的class (用主题的class代替)。

Im building my cart page. Im using wordpress woocommerce and woodmart theme, and I have a child theme for my woodmart theme. Currently my cart page is empty and im using the default cart page from woodmart theme. I want to fully rebuild it. I have a few requirement here: I want to display a checkbox before the items on the cart page. When the checkbox is clicked, the subtotal on the cart page will change based on the selected items. 在購物車中可以選擇相應的商品下單,based on checkbox(目前實現的是全部商品下單) 4)沒被選擇下單的商品會保留在購物車内,讓用戶下一次再選擇下單 As what i know, the default setting for woocommerce is checkout everything in cart page all at once and remove everything from cart. I think need to overwrite the default setting so that the items can retain inside cart. I have no coding basic, please give me the FULL CODE to be inserted into each required section. the cart.php in my child theme is currently empty, can you give me the full code, i want the layout like normal cart page with 6 column 1)全选商品(checkbox) 2)商品信息 3)商品参数 4)单价 5)数量(可±) 6)金额 7)操作(移除商品) make this as a table with 7 column. After the table, i want a sticky footer that shows select all checkbox, 刪除選中的商品 & 清理購物車 已选商品 (x) 件,共计: RM(x.xx),结算(checkout button) I want my cart page to be 1024px, just like the default settings
最新发布
07-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值