• Resolved minsuwai

    (@minsuwai)


    I add the “Add to cart” text using this following code

    button.single_add_to_cart_button.button.alt.wooaddtocart-shopping-cart.disabled.wc-variation-selection-needed:before{
    	content: "Add to cart";
    	color: red;
    }
    
    button.single_add_to_cart_button.button.alt.wooaddtocart-shopping-cart:before{
    	content: "Add to cart";
    }
    
    There can see the color blur of the text
    • This topic was modified 1 year, 4 months ago by minsuwai.
Viewing 4 replies - 1 through 4 (of 4 total)
  • I think you’ll do better using the filter:
    https://woocommerce.com/document/change-add-to-cart-button-text/

    If you want to do it with css, please post a link to a relevant page so your markup and styles can be examined with browser tools.

    Thread Starter minsuwai

    (@minsuwai)

    https://kariyarnantawstationery.com/shop/

    Here is the page, I was added the add to cart text of the simple product using filter but that filter did not change the add to cart of the variable product. Therefore I was added using css.

    In the above link, I was added add to cart text using css for variable product that is the third product in my page.

    The css that you have used looks good, but I don’t think it will deal with the two cases for the variable button – “Select Options” (product can be purchased) or “Read More” (product cannot be purchased or is out of stock)

    Try this modified version of the add-to-cart filter for simple and variable add-to-cart buttons.

      // change add to cart text on product archives page
      add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_add_to_cart_button_text_archives', 10, 2 );  
      function woocommerce_add_to_cart_button_text_archives( $text, $product ) {
        if( $product->is_type( 'simple' ) ) {
          if( $product->is_purchasable() && $product->is_in_stock() ) {
            return 'Add to cart'; // simple product, can be purchased
          } else {
            return 'Read more'; // simple product, cannot be purchased
          }
        }
        if( $product->is_type( 'variable' ) ) {
          if( $product->is_purchasable() ) {
            return 'Select options'; // variable product, can be purchased
          } else {      
            return 'Read More'; //  variable product, cannot be purchased
          }
        }
        // grouped
        // external
      }
    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can not add the Add to cart button text’ is closed to new replies.