Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1359537

    Dear Support Members, I am curious if there is a way to set a default setting for the hover effect on overview pages? On every product page I have a meta_box with settings for the hover effect:

    Hover effect on Overview Pages
    Do you want to display a hover effect on overview pages and replace the default thumbnail with the first image of the gallery?
    • Default: No hover effect
    • The other option is: Yes – show first gallery image …

    For my pages I use a altered code form your documentation (mentioned in #1341086):

    add_action( 'after_setup_theme', 'ava_enfold_builder_layout_mod' );
    function ava_enfold_builder_layout_mod(){
      if ( is_page() ) {
    	add_filter('avf_builder_elements', 'avf_enfold_builder_layout_settings_mod');
      }
    }
    
    function avf_enfold_builder_layout_settings_mod($elements)
    {
      $counter = 0;
        foreach($elements as $element)
        {
        if($element['id'] == 'header_transparency')  {
                $elements[$counter]['std'] = 'header_transparent';
            }
            $counter++;
        }
      return $elements;
    }

    So could I write something like:

    add_action( 'after_setup_theme', 'ava_enfold_builder_layout_mod' );
    function ava_enfold_builder_layout_mod(){
      if ( is_product() ) {
    	add_filter('avf_builder_elements', 'avf_enfold_builder_layout_settings_mod');
      }
    }
    
    function avf_enfold_builder_layout_settings_mod($elements)
    {
      $counter = 0;
        foreach($elements as $element)
        {
        if($element['id'] == 'product_hover')  {
                $elements[$counter]['std'] = 'hover_active';
            }
            $counter++;
        }
      return $elements;
    }

    I already did some tests, but with no success. My goal is to set the default to “yes” for all new products. Any chance to do that?

    Cheers, Daniel

    #1359636

    Hey spooniverse,

    Thank you for the inquiry.

    Please try to use this script instead of the avf_builder_elements filter.

    function avia_set_hover_active() {
        global $current_screen;
    
        if( $current_screen->post_type =='product' && $current_screen->action == 'add')
        {
        ?>
            <script>
                (function($) {
                    $(document).ready(function() {
                        $('#_product_hover').val("hover_active").change();
                    });
                })(jQuery);
            </script>
        <?php
        }
    }
    add_action( 'admin_head', 'avia_set_hover_active' );
    

    This should set the value of the #_product_hover select element to hover_active when creating a new product.

    Best regards,
    Ismael

    #1359641

    Hey Ismael, I appreciate your help. And the code works like charm – as always. So thanks a lot!

    All the best,
    Daniel

    #1359662

    Hi,

    Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

    #1359665

    Hi Rikard, you may close this. Thanks!

    #1359672

    Hi,

    Thanks for letting us know, I’ll close this thread for now then. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Set a default hover effect on overview pages (WooCommerce)’ is closed to new replies.