[Resolved] Add to cart button text

Home Forums Support [Resolved] Add to cart button text

Home Forums Support Add to cart button text

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #942461
    Pedro

    Hello! I would like to change the text of the “add to cart” button for variable products.

    I see that Generatepress places the text “Select options”, instead of “Add to cart” when a product has variations.

    How can I do it?

    Thank you!

    #942473
    Leo
    Staff
    Customer Support

    Hi there,

    I believe the first 2 snippets are what you are after:
    https://metorik.com/blog/change-the-add-to-cart-text-in-woocommerce

    #942484
    Pedro

    Hi leo! Thanks for answering.

    I think I was not specific, I want to change the text to sticky add to cart for variable products.

    Since it currently shows “Select options”, and I would like it to say “Add to cart”

    I’m sorry I did not say it was the sticky add to cart.

    #943018
    Tom
    Lead Developer
    Lead Developer

    The link Leo posted has the answer.

    For example:

    add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) {
        global $product;
    	
        $product_type = $product->product_type;
    
        if ( 'variable' === $product_type ) {
            $text = 'Add to cart';
        }
    
        return $text;
    } );
    #943382
    Pedro

    Thank so you mucho Leo and Tom!! You have the best support in the world!!

    #943910
    Tom
    Lead Developer
    Lead Developer

    Glad we could help 🙂

    #961370
    Christine

    Hi, I am Looking for similar thing. On my website homepage (https://staging.gartersandco.com.au/)

    here is a woocommerce product slider and there SELECT OPTIONS I want to change to BUY NOW.

    I tried the snippets from https://metorik.com/blog/change-the-add-to-cart-text-in-woocommerce but these are not working.

    
    function woo_custom_product_add_to_cart_text() {
      
         return __( 'Buy Now', 'woocommerce' );
      
     };
    

    This is changing the text only for 2 products in the slider. Please help.

    #961418
    Leo
    Staff
    Customer Support

    Any chance you can open a new topic for your question?

    Also I don’t see Select Options in the product slider in the home page.

    Thanks 🙂

    #2057114
    Éva

    Hi,

    I would like to rename the button on the archive pages to “Buy now”. For the single products a plugin to make the checkout a onestep process takes care of it, however 2 products are for free, hence it makes no sense naming their button “Buy now”, instead of “Download”. Unfortunately, I wasn’t successful in adjusting the codes offered via the link.
    Your help would be greatly appreciated.

    Thank you.

    Regards
    Éva

    #2057216
    Elvin
    Staff
    Customer Support

    Hi Éva

    Try this:

    add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) {
        global $product;
    	
        if ( $product->is_type( 'variable' ) ) {
            $prices = $product->get_variation_prices( true );
            $min_price = current( $prices['price'] );
            if ( 0 == $min_price ) {
                $max_price = end( $prices['price'] );
                $min_reg_price = current( $prices['regular_price'] );
                $max_reg_price = end( $prices['regular_price'] );
                if ( $min_price !== $max_price ) {
                    $text = 'Download';
                } elseif ( $product->is_on_sale() && $min_reg_price === $max_reg_price ) {
                    $text = 'Download';
                } else {
                    $text = 'Download';
                }
            }
        } elseif ( 0 == $product->get_price() ) {
            $text = 'Download';
        }  
    
        return $text;
    } );
    #2057425
    Éva

    Hi Elvin,

    worked like a charm! Thank you so much and merry christmas.

    Regards
    Éva

    #2061323
    Elvin
    Staff
    Customer Support

    No problem. 😀

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.