在商店页面的woocommerce商店中更改“添加到购物车"按钮的重定向 [英] Changing the redirect of the “add to cart” button in woocommerce store in Shop page

查看:91
本文介绍了在商店页面的woocommerce商店中更改“添加到购物车"按钮的重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在woocommerce中更改除单个产品页面以外的页面中添加到购物车"按钮的重定向URL.可以使用

I am trying to change the redirect URL in the woocommerce for the 'add to cart' button in pages other than the single product page. The URL for the single product page can be changed with this solution. However this solution will not work for the for any other pages, to change the redirect after pressing the 'add to cart' button. Any help is greatly appreciated.

推荐答案

您可以在外观>主题编辑器> function.php

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 = __("View product", "woocommerce");
    $button = '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';

    return $button;
}

这会将您的添加到购物车"更改为查看产品,而网址"将是特定产品的网址

This will change your Add to cart to View porducts and the Url would be that specific products's Url

这篇关于在商店页面的woocommerce商店中更改“添加到购物车"按钮的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆