admin管理员组文章数量:1334669
I am using WooCommerce for the eCommerce part of my WordPress site.
When using the add_to_cart
button I want it to say "read more" on a specific webpage only.
So far I have found the code to change the button text:
add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text');
function woo_custom_cart_button_text() {
return__('Read More','woocommerce'); }
The question is, how do I make this apply to the appearance of the add_to_cart
button on a single page of my website? The page is not a shop page. It is a normal webpage where is have the description of products and the associated treatment. The button is there to take them to the product page.
I am using WooCommerce for the eCommerce part of my WordPress site.
When using the add_to_cart
button I want it to say "read more" on a specific webpage only.
So far I have found the code to change the button text:
add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text');
function woo_custom_cart_button_text() {
return__('Read More','woocommerce'); }
The question is, how do I make this apply to the appearance of the add_to_cart
button on a single page of my website? The page is not a shop page. It is a normal webpage where is have the description of products and the associated treatment. The button is there to take them to the product page.
2 Answers
Reset to default 0Why not add a regular button with link to the product page, as in
<a href..><button></button></a>
?
You use two different text for product listing page and product details page.
- Open Wordpress admin panel, go to Appearance > Theme Editor Open functions.php theme file
- Add the following code at the bottom of function.php file
- Save the changes and check your website. The custom text in add to cart button should show up now.
// To change add to cart text on single product page add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); function woocommerce_custom_single_add_to_cart_text() { return __( 'Buy Now', 'woocommerce' ); } // To change add to cart text on product archives(Collection) page add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' ); function woocommerce_custom_product_add_to_cart_text() { return __( 'Buy Now', 'woocommerce' ); }
本文标签: pluginsMake modification of addtocart button specific to single page
版权声明:本文标题:plugins - Make modification of add_to_cart button specific to single page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742373929a2462781.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论