Site logo

Archived topic

Add to cart hover in niche missing

6 replies · Started by nik9 on October 28, 2020

Viewing posts 1–7 of 7

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. :)

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"

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

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?

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;
}

great! Thanks :)

You're welcome

This archived topic is closed to new replies.