Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1122505
    vchang
    Participant

    When viewing our Woocommerce Shop Page and positioning the mouse over a product image, some of them make a button appear that states “Select options” as shown in the attached pdf file. I’d like to fix this to match most of product images that make an “Add to cart” button appear instead.

    I’d appreciate any help to learn how to correct this.

    Thanks!

    #1122562
    Rahul
    Moderator

    Hey There,

    Thanks for writing in!

    Add this code at your child themeโ€™s functions.php with your own customization 🙂

    add_filter('woocommerce_loop_add_to_cart_link', function( $product ){
    
    return sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="x-btn %s product_type_%s">%s</a>',
    		esc_url( $product->add_to_cart_url() ),
    		esc_attr( $product->id ),
    		esc_attr( $product->get_sku() ),
    		esc_attr( isset( $quantity ) ? $quantity : 1 ),
    		$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
    		esc_attr( $product->product_type ),
    		esc_html( $product->add_to_cart_text() )
    	);
    
    });

    Hope this helps!

    #1124157
    vchang
    Participant
    This reply has been marked as private.
    #1125208
    Nico
    Moderator

    Hi There,

    He means about the “with your own customization” is that you will add the code above with your other codes in the funcion.php.

    Hope it is clear already and the code above will work ๐Ÿ™‚

    Let us know how it goes.

    Thanks.

    #1127571
    vchang
    Participant
    This reply has been marked as private.
    #1127672
    Joao
    Moderator

    You too ๐Ÿ™‚

    Let us know if you need help with anything else.

    Joao

  • <script> jQuery(function($){ $("#no-reply-1122505 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>