Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #900451

    Hi Kriesi,

    I know we have Hover image option on single product page that changes main image with first gallery image. But we have 500 products and we can’t do this manually. We need some code or css that can do this for products?

    Please see website URL in private content area.

    Thanks
    Aadil

    #901868

    Hey danielromanin,

    Thank you for using Enfold.

    Do you want to set the second option of the “Hover effect on Overview Pages” as default? You have to modify the config-woocommerce > admin-options.php file, look for this code around line 174:

    $elements[] = array("slug"	=> "avia_product_hover",
                "name" 	=> "Hover effect on <strong>Overview Pages</strong>",
                "desc" 	=> "Do you want to display a hover effect on overview pages and replace the default thumbnail with the first image of the gallery?",
                "id" 	=> "_product_hover",
                "type" 	=> "select",
                "std" 	=> "",
                "class" => "avia-style",
                "subtype" => array("Yes - show first gallery image on hover" => 'hover_active', "No hover effect" => ''));

    .

    Set the “std” parameter to “hover_active”.

    "std" 	=> "hover_active",
    

    Best regards,
    Ismael

    #1219826

    Hello!!

    Can you bring me a piece of code to add via Child theme, please?
    To avoid forget it when main theme will be update.

    Thanks in advance!

    #1220783

    Hi,

    You can copy the whole avia_woocommerce_product_elements function in the child theme, rename the function and do your own modifications.

    remove_filter( 'avf_builder_elements', 'avia_woocommerce_product_elements', 500, 1 );
    add_filter( 'avf_builder_elements', 'avia_woocommerce_product_elements_mod', 500, 1 );
    
    function avia_woocommerce_product_elements_mod( $elements )
    {
    	$posttype = avia_backend_get_post_type();
    
        if( ! empty( $posttype ) && $posttype == 'product' )
        {
            $elements[] = array("slug"	=> "avia_product_hover",
                "name" 	=> "Hover effect on <strong>Overview Pages</strong>",
                "desc" 	=> "Do you want to display a hover effect on overview pages and replace the default thumbnail with the first image of the gallery?",
                "id" 	=> "_product_hover",
                "type" 	=> "select",
                "std" 	=> "",
                "class" => "avia-style",
                "subtype" => array("Yes - show first gallery image on hover" => 'hover_active', "No hover effect" => ''));
    
            $counter = 0;
            foreach( $elements as $element )
            {
                if( $element['id'] == 'sidebar' ) 
    			{
    				$elements[ $counter ]['required'] = '';
    			}
                else if( $element['id'] == 'layout' ) 
                {
    	            $elements[ $counter ]['builder_active'] = true;
    	           // unset($elements[$counter]);
                }
                $counter++;
            }
        }
    
    	return $elements;
    }
    

    Best regards,
    Ismaele

    #1220812

    Hello Ismaele!

    Well, works but,,, now appears two times….
    Snapshop

    Can you check it, pelase?
    Thanks again!

    ____
    Ummm,,,
    For future theme updates, you may want to consider adding this feature (activate on all new products), maybe in theme settings > Shop Options.

    #1221670

    Hi,

    Try to wrap the remove_filter line inside an after_setup_theme hook.

    add_action('after_setup_theme', function() {
        remove_filter( 'avf_builder_elements', 'avia_woocommerce_product_elements', 500, 1 );
    }, 10);
    

    And if you want to enable the option by default, look for this line:

    "std" 	=> "",
    

    .. and replace it with:

    "std" 	=> "hover_active",
    

    Best regards,
    Ismael

    #1221958

    Hi Ismael,

    Now works fine!
    You can close this issue.

    Thanks!!!

    ***
    For future theme updates, you may want to consider adding this feature (activate on all new products), maybe in theme settings > Shop Options.

    #1222014

    Hi,

    Glad it worked! We’ll forward the request to our channel.

    Thank you for your patience.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Change single product image on hover with gallery first image’ is closed to new replies.