Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1060470

    Timmy
    Participant

    Hi, First of all awesome theme, I absolutely love it!

    I’m trying to change the ‘Add to cart’ button text when the product is added through essential grid, they use link to add it to the cart, like this: http://web.timanity.se/funktioner/?add-to-cart=526

    I used a code to change but it doesn’t work, here’s the code:

    add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text');
    function woo_custom_cart_button_text() {
      
      foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
        $_product = $values['data'];
      
        if( get_the_ID() == $_product->id ) {
          return __('Redan Tillagd', 'woocommerce');
        }
      }
      
      return __('Add to cart', 'woocommerce');
    }

    Thank you in advance!
    best regards,
    Timmy

    #1060737

    Rue Nel
    Moderator

    Hello Timmy,

    Thanks for writing in! The code will only work in changing the button text upon loading the page. The add to cart button text change that you wanted will require JS event triggers upon clicking on add to cart button. As this is all custom development, regretfully we won’t be able to assist further. Custom development is outside the scope of our support. We’re happy to provide advice and get you started in the right direction, but you would still be responsible for the implementation.

    Thank you for your understanding.

    #1060932

    Timmy
    Participant

    No problem, I’ll figure it out 🙂

    Thank you!

    #1060948

    Rue Nel
    Moderator

    You’re welcome.
    If you need anything else we can help you with, don’t hesitate to open another thread.