[Resolved] Add to cart hover in niche missing

Home Forums Support Add to cart hover in niche missing

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1508660
    nik9

    Hello,

    We just noticed that the “Add to cart” button does not show up after hovering over a product on product archive. (See link)
    We did not change some thing in CSS or so,,, thanks. 🙂

    #1508673
    Elvin
    Staff
    Customer Support

    Hi,

    I’m not sure I understand what you mean.

    I don’t see any “Add to cart” button even when I’m hovering on the products.

    Did you mean the price that fades up when hovered? Ex: “CHF 4.70”

    A wise man once said:
    "Have you cleared your cache?"

    #1508865
    nik9

    Hi Elvin, Yes that is exactly the problem. The price that fades up when hovering is missing…. 🙁

    #1508927
    nik9

    Update: I was able to solve this. Was a CSS issue but I do not understand why this was a problem now haha.. That was working for weeks.. 🙂

    But I have now a following question..

    I know I can use this code below to change the Add to cart text.

    add_filter( 'woocommerce_product_add_to_cart_text', function() {
        return 'Hinzufügen';
    } );

    Question: Is there a way, that we can change the label text ONLY from products that are sold out?

    #1509007
    David
    Staff
    Customer Support

    Hi there,

    Try this:

    add_filter( 'woocommerce_product_add_to_cart_text', 'change_sold_out_product_button_text_label', 10, 2 );
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'change_sold_out_product_button_text_label', 10, 2 );
    function change_sold_out_product_button_text_label( $button_text, $product ) {
    
       $stock = array();
    
        // Only for variable products on single product pages
        if ( $product->is_type('variable') )
        {
            foreach ($product->get_available_variations() as $key => $value){
                $stock[] = isset( $value['is_in_stock'] ) ? $value['is_in_stock'] : true;
            }
            
            if( empty( array_filter( $stock ) ) ){
                $button_text = __( "Hinzufügen", "woocommerce" );
            }
        }
        // For all other cases (not a variable product on single product pages)
        elseif ( ! $product->is_type('variable') && !$product->is_in_stock() ) 
        {
            $button_text = __( "Hinzufügen", "woocommerce" );
        }
        return $button_text;
    }
    #1509044
    nik9

    great! Thanks 🙂

    #1509059
    David
    Staff
    Customer Support
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.