WordPress.org

Forums

WooCommerce Customizer
[resolved] Add to Cart Button on Variable Products (8 posts)

  1. mattswan
    Member
    Posted 1 year ago #

    I've been using and enjoying this plugin for a while but after a useability study suggested we make some changes, I wanted to change the Add to Cart Button text. Cool I thought, I can do that with WooCommerce Customizer, so I trundle over to the Product Page tab and drop my desired text into the Add to Cart Button Text > All product types field and hit save.
    Our shop contains a mixture of simple and variable products - the plugin over-ride worked fine on the simple products but completely not for the variable ones.
    I've actually tried manually changing it with the following:

    add_filter('variable_add_to_cart_text', 'woo_custom_cart_button_text1');
    
    function woo_custom_cart_button_text1() {
    
    		return __('Buy Now - Free Shipping', 'woocommerce');
    
    }

    But that didn't work either - possibly a fix for an older version of WooComm?

    Any ideas?

    https://wordpress.org/plugins/woocommerce-customizer/

  2. Max Rice
    Member
    Plugin Author

    Posted 1 year ago #

    This should work in the latest version of the customizer, which version of WC are you using? The filter in 2.1+ is here: https://github.com/woothemes/woocommerce/blob/master/includes/abstracts/abstract-wc-product.php#L478-L486

    so your code would need to hook into that and return your add to cart text :)

  3. mattswan
    Member
    Posted 1 year ago #

    The Variable Product entry field in the Shop Loop tab works fine, it's the Add To Cart button text on the Product Page for variable products - in our case surfboard lengths - that is resisting the input from the plugin.

    By way of example, here's a variable product with 7 available lengths:

    http://www.surfindustries.com/shop/us/surf/shortboards/haydenshapes-hypto-krypto-ff-shortboard/

    which shows "Add to Cart", while a simple product with no variations:

    http://www.surfindustries.com/shop/us/surf/paddles/trident-childs-adjustable-paddle/

    happily showing our modified Product Page > Add To Cart Button Text > All Product Types entered text.

    We're rolling with WC 2.1.9, WP 3.9.1 and plugin v 1.2.1

  4. Max Rice
    Member
    Plugin Author

    Posted 1 year ago #

    Try adding this code to your theme's functions.php and see if it changes the button text:

    add_filter( 'woocommerce_product_single_add_to_cart_text', function() { return 'Add me to cart!'; } );

  5. SidianMSJones
    Member
    Posted 9 months ago #

    Hi there. I've got the same issue (changing the add to cart text not working).

    I added your code to the functions.php and that does indeed work.

    Any next steps we could take to figure it out?

    Thanks much!

  6. wellnix52
    Member
    Posted 5 months ago #

    Same problem here. Changing the add to cart text works only on single products displays and not variable products. My theme has no overrides in their functions.php file.

  7. Max Rice
    Member
    Plugin Author

    Posted 4 months ago #

    Can you submit a ticket at https://www.skyverge.com/contact/ so I can take a deeper look? thanks :)

  8. wellnix52
    Member
    Posted 4 months ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce Customizer
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.