Hi,
I love this plugin, and really value its functionality on my websites.
BUT it appears to abandoned as it hasn’t been updated for two years and has not been tested with multiple versions of WordPress.
Can I ask a huge favour and get a response from this question: Will this be updated soon or do I need to find an alternative plugin?
Many thanks,
Matthew
]]>Hi there,
I’m the author of WooCommerce Mix and Match products, which creates a custom product type. A customer came to me in support today to ask why the Mix and Match product’s add to cart button reads “Read More”. Upon investigation it is because that’s the default from your custom add to cart labels plugin for a product type that is not explicitly supported. Instead, I’d like to propose that you default to the existing add to cart text when nothing is changed via your plugin settings.
I would send a pull request, but your Github repo links back to your WordPress plugin page.
Here are the modifications I’d like to propose…
1. Don’t check if Woo is active via activated plugins setting. None of the filters exist is Woo is not active, so it’s redundant.
2. Separate custom_woocommerce_product_add_to_cart_text
into custom_woocommerce_product_add_to_cart_text
and custom_woocommerce_product_single_add_to_cart_text
3. Pass $product
to those functions automatically.
4. Remove translation functions from settings values as they are useless for dynamic settings.
5. Add translations functions for settings titles/descriptions (and use unique text domain).
Here is the resulting code:
<?php
/*
Plugin Name: WC Custom Add to Cart labels
Plugin URI: https://profiles.www.ads-software.com/rynald0s
Description: This plugin lets you change the "add to cart" labels on single product pages (per product type) and archive / shop page (per product type).
Author: Rynaldo Stoltz
Author URI: https://github.com/rynaldos
Version: 1.3
License: GPLv3 or later License
URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Add settings
*/
function catcl_section( $sections ) {
$sections['catcl_section'] = __( 'Add to cart button labels', 'wc-add-to-cart-labels' );
return $sections;
}
add_filter( 'woocommerce_get_sections_products', 'catcl_section' );
function catcl_settings( $settings, $current_section ) {
/**
* Check the current section is what we want
**/
if ( 'catcl_section' === $current_section ) {
$settings[] = array( 'title' => __( 'Change the "add to cart" button label on single product pages (per product type)', 'wc-add-to-cart-labels' ), 'type' => 'title', 'id' => 'wc_atc_change' );
$settings[] = array(
'title' => __( 'Simple products', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label shown on single product page of simple product type', 'wc-add-to-cart-labels' ),
'id' => 'simple_button_text_single',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Grouped products', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label shown on single product page of grouped product type', 'wc-add-to-cart-labels' ),
'id' => 'grouped_button_text_single',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'External products', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label shown on single product page of external product type', 'wc-add-to-cart-labels' ),
'id' => 'external_button_text_single',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Variable products', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label shown on single product page of variable product type', 'wc-add-to-cart-labels' ),
'id' => 'variable_button_text_single',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Bookable products', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label shown on single product page of bookable product type', 'wc-add-to-cart-labels' ),
'id' => 'booking_button_text_single',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Subscription products', 'woocommerce-subscriptions' ),
'desc' => __( 'This will change the "add to cart" label shown on single product page of subscription product type', 'wc-add-to-cart-labels' ),
'id' => 'subs_button_text_single',
'type' => 'text',
'placeholder' => 'Sign up now',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Variable subscription products', 'woocommerce-subscriptions' ),
'desc' => __( 'This will change the "add to cart" label shown on the single product page of variable subscription product type', 'wc-add-to-cart-labels' ),
'id' => 'subs_var_button_text_single',
'type' => 'text',
'placeholder' => 'Sign up now',
'css' => 'min-width:350px;',
);
$settings[] = array( 'type' => 'sectionend', 'id' => 'wc_atc_change' );
$settings[] = array( 'title' => __( 'Change the "add to cart" button label on archive / shop page (per product type)', 'wc-add-to-cart-labels' ), 'type' => 'title', 'id' => 'wc_atc_change' );
$settings[] = array(
'title' => __( 'Simple products (archive)', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label on simple products that are shown on the archive page', 'wc-add-to-cart-labels' ),
'id' => 'simple_button_text',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Grouped products (archive)', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label on grouped products that are shown on the archive page', 'wc-add-to-cart-labels' ),
'id' => 'grouped_button_text',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'External products (archive)', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label on external products that are shown on the archive page', 'wc-add-to-cart-labels' ),
'id' => 'external_button_text',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Variable products (archive)', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label on variable products that are shown on the archive page', 'wc-add-to-cart-labels' ),
'id' => 'variable_button_text',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Bookable products (archive)', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label on bookable products that are shown on the archive page', 'wc-add-to-cart-labels' ),
'id' => 'booking_button_text',
'type' => 'text',
'placeholder' => 'Add to cart',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Subscription products (archive)', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label on subscription products that are shown on the archive page', 'wc-add-to-cart-labels' ),
'id' => 'subs_button_text',
'type' => 'text',
'placeholder' => 'Sign up now',
'css' => 'min-width:350px;',
);
$settings[] = array(
'title' => __( 'Variable subscription products (archive)', 'wc-add-to-cart-labels' ),
'desc' => __( 'This will change the "add to cart" label on variable subscription products that are shown on the archive page', 'wc-add-to-cart-labels' ),
'id' => 'subs_var_button_text',
'type' => 'text',
'placeholder' => 'Sign up now',
'css' => 'min-width:350px;',
);
$settings[] = array( 'type' => 'sectionend', 'id' => 'wc_atc_change' );
}
return $settings;
}
add_filter( 'woocommerce_get_settings_products','catcl_settings', 10, 2 );
function custom_woocommerce_product_single_add_to_cart_text($text, $product) {
$custom_text = '';
switch ( $product->get_type() ) {
case 'simple':
$custom_text = catcl_get_settings( 'simple_button_text_single');
break;
case 'grouped':
$custom_text = catcl_get_settings( 'grouped_button_text_single');
break;
case 'external':
$custom_text = catcl_get_settings( 'external_button_text_single');
break;
case 'variable':
$custom_text = catcl_get_settings( 'variable_button_text_single');
break;
case 'booking':
$custom_text = catcl_get_settings( 'booking_button_text_single');
break;
case 'subscription':
$custom_text = catcl_get_settings( 'subs_button_text_single');
break;
case 'variable-subscription':
$custom_text = catcl_get_settings( 'subs_var_button_text_single');
break;
}
return '' !== $custom_text ? $custom_text : $text;
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_woocommerce_product_single_add_to_cart_text', 10, 2 );
add_filter( 'woocommerce_booking_single_add_to_cart_text', 'custom_woocommerce_product_single_add_to_cart_text', 10, 2 );
function custom_woocommerce_product_add_to_cart_text($text, $product) {
$custom_text = '';
switch ( $product->get_type() ) {
case 'simple':
$custom_text = catcl_get_settings( 'simple_button_text');
break;
case 'grouped':
$custom_text = catcl_get_settings( 'grouped_button_text');
break;
case 'external':
$custom_text = catcl_get_settings( 'external_button_text');
break;
case 'variable':
$custom_text = catcl_get_settings( 'variable_button_text');
break;
case 'booking':
$custom_text = catcl_get_settings( 'booking_button_text');
break;
case 'subscription':
$custom_text = catcl_get_settings( 'subs_button_text');
break;
case 'variable-subscription':
$custom_text = catcl_get_settings( 'subs_var_button_text');
break;
}
return '' !== $custom_text ? $custom_text : $text;
}
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text', 10, 2 );
function catcl_get_settings( $key ) {
return get_option( $key, '' );
}
`
]]>It says it hasn’t been tested with the latest version of WP. I don’t know if that’s why it’s not working or not. But I installed it and tried to put “request appointment” instead of “proceed to checkout” and it didn’t do anything at all.
]]>I am using Mahogany theme but its not working https://prnt.sc/u5dof1
]]>Hi,
How can we change the text of the button on a Downloadable product? the simple Product button now says Book course on the site in question, but we really need it to say ‘Download’ or just ‘Add to Basket’
Thanks
]]>Hi there.
Thanks for the plugin its working great except for sold out products.
Instead of the read more is also showing the custom add to cart tag. I have a function that i change the read more to sold out, how can i achive that with your plugin? It’s weird to have a add to art on a sold out product.
Look forwar for your reply
My best regards
Used to be ok, but it was not updated in 7 month and it’s not working anymore with the latest versions of Woo and WP. Guess it should better be discontinued if not maintained anymore …
]]>Call to a member function get_type() on null in /home/xxxxxxx/public_html/wp-content/plugins/wc-custom-add-to-cart-labels/wc-custom-add-to-cart-labels.php
]]>Hi!
Wonderful plugin, but it crashes when visiting the My Membership –> Discounts page under My Account. Both the Membership and Subscription plugins are installed.
Can you please check this out?
Thanks in advance!
Tom
Hi,
I have been running this plugin with no problem for the past couple of years.
However, recently, when this plugin is active, my homepage breaks & I get a fatal error message on my site homepage. Rest of the pages work, and the plugin does what it’s supposed to on the catalog page. When I deactivate the plugin, the homepage loads alright. Please help!!!
Thanks,
Sneha
I am using the 9Seeds Jessica theme: https://9seeds.com/product/jessica/
it looks like the Jessica theme has this code lines 44-46 in the “/themes/jessica/lib/shop/woocommerce.php file” file:
// Change add to cart button text
add_filter( 'add_to_cart_text', 'wsm_woo_custom_cart_button_text' ); // < 2.1
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wsm_woo_custom_cart_button_text' ); // 2.1+ Single
add_filter( 'woocommerce_product_add_to_cart_text', 'wsm_woo_custom_cart_button_text' ); // 2.1 + Archives
function wsm_woo_custom_cart_button_text() {
return __( 'Buy', 'jessica' );
}
In THEORY, this code snippet should have removed these filters and allowed this plugin to work:
// Remove Jessica add to cart button filter (See /themes/jessica/lib/shop/woocommerce.php file lines 44-46 for the original button filter code)
remove_filter( 'add_to_cart_text', 'wsm_woo_custom_cart_button_text' ); // < 2.1
remove_filter( 'woocommerce_product_single_add_to_cart_text', 'wsm_woo_custom_cart_button_text' ); // 2.1+ Single
remove_filter( 'woocommerce_product_add_to_cart_text', 'wsm_woo_custom_cart_button_text' ); // 2.1 + Archives
Unfortunately, adding and activating that snippet doesn’t work, but commenting out the code on lines 44-46 in the “/themes/jessica/lib/shop/woocommerce.php file” allows this plugin to work. It’s not ideal because now I have to keep track of this change EVERY time I update this theme.
I really want to use this plugin with THIS theme. The atheme author believes the issue is the priority for this plugin.
]]>Plugin is working for me only on the Shop page but not on the individual product page once I add a picture to the product. It works fine if product doesn’t have a picture. It seems plugin is breaking the code somehow as page will only show the top navigation bar and nothing else… below the navigation bar is just a blank page.
]]>I’m using WP Multilang to offer the ability to switch between English and French on my clients site. I thought since the EN and FR were showing up on my settings for WC Custom Add to Cart labels, switching back and forth either only provided me with English exclusively or French exclusively.
Any plans to truly make this compatible with WP Multilang?
]]>I am using Woocommerce. The plugin works great and helps me change the text on the variable products archive pages. But when you click on the quickview button from the archive page, the button also says “see options” and I’d like for it to stay the same “add to cart.” Do you plan on addressing the quick view button at all?
]]>Hi there! First of all, thanks for making this plugin. Unfortunately though setting the add to cart button labels per product type does not quite fit with our needs. As our shop is not selling goods but advertisements, I changed the label to “Add booking to cart” which suits for most products which are allowed to buy only once per order.
Some procucts however can be booked several times and the the customer can choose a number of bookings. I am having real problems to make it sound right for plural!
To make the button gramatically working, it should change to a plural text version (“Add bookings to cart”) as soon as the customer increases the quantity above 1.
The product type variants do not help because some of products which should have another label are simple products, others are variable.
I think it might be more helpful to set the labels per product category, however it could get complicated as one product can be in several categories.
]]>Hi there, the Add to cart labels plugin is working well on our site, but it does not care for language. We are using WPML, WPML String Translation and WooCommerce Multilingual.
With WPML String Translation I can find the strings saved for button labels and edit their translations, however the translations will not be used, instead the same text will be used for all languages.
Can you make WC Custom Add to Cart labels compatible with WPML?
]]>I’m using the latest version of WooCommerce, but upon installing this plugin I got this error and have been unable to activate the plugin:
`Fatal error: Cannot redeclare custom_woocommerce_product_add_to_cart_text() (previously declared in /wp-content/themes/accesspress-lite-child/functions.php:849) in /wp-
content/plugins/wc-custom-add-to-cart-labels/wc-custom-add-to-cart-labels.php on line 151′
Any tips?
]]>Neither the shopping page as the single products add-to-cart-text change with this app at the moment ??
Any ideas on how to solve this?
This works really well but when a product has ‘linked products’ it reverts to the standard ‘Add to cart’ wording. There is no facility to update this in the settings.
Anyone know if there a way to change this?
R
]]>Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘catcl_settings’ not found or invalid function name in /home/httpd/vhosts/xxx.com/httpdocs/wp-includes/class-wp-hook.php on line 298 Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/xxx.com/httpdocs/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-settings.php on line 200
Save changes
Hi, I installed this plugin. Works fine with Simple and Variable products… for some reason it displays “Read More” for product bundles. Please advise.
]]>I’m setting up a store for an antique dealer. Since all the products are one of a kind, I need to show out-of-stock items as sold on both the archive page and the single product page. Can that option be added to this plugin or is there a better solution?
]]>When I try to activate this plugin, an error shows.
]]>
This plugin needs to add support for bookable products. I spoke with WooCommerce and the case for bookable products is ‘booking’. Add it!
]]>This plugin is a catch all for Add to Cart and works fine except when you add the Woocommerce Subscription plugin and converts the Sign Up Now to Read More.
You will need to add to the array of your plugin these filters to correct this problem.
add_filter( ‘woocommerce_order_button_text’, __CLASS__ . ‘::order_button_text’ );
add_action( ‘woocommerce_subscription_add_to_cart’, __CLASS__ . ‘::subscription_add_to_cart’, 30 );
add_action( ‘woocommerce_variable-subscription_add_to_cart’, __CLASS__ . ‘::variable_subscription_add_to_cart’, 30 );
add_action( ‘wcopc_subscription_add_to_cart’, __CLASS__ . ‘::wcopc_subscription_add_to_cart’ ); // One Page Checkout compatibility
I love the plug in but I wanted to add a cart emoji next to the text. When I add the emoji and click save, the text saves but the emoji does not save and disappears.
]]>Hello,
This plugin is a very good idea!
But despite WC 3.1.1, WP 4.8 running and clearing the cache, the labels do not change.
Can you please help me with a cue of how to make it work (ideally aside from fooling in woocommerce.php file:-).
Many thanks.
This plugin does not work for me. If I want to change the Add to cart button I have to change it in the woocommerce.php because nothing happens with using this plugin.
]]>It is possible to add registrations labels too? I need to change the add-to-chard button for this label only. This is an add on of woocommerce: https://www.ads-software.com/plugins/registrations-for-woocommerce/
Thanks!
Hi,
I’m developing a website and I’ve just installed the plugin. After I activate the plugin, all the options in WooCommerce > Settings > Products are empty and gone. The option to change the label doesn’t appear at all neither.
Could you please help me understand why is this happening?
Thanks a mil,
Brenda