Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #874732

    Hi, I found the following piece of code on a related thread. It fixes the issue described in the previous thread for category pages, but at the same time it seems to remove the banner image for the main shop page. How could this code be adjusted to not remove the banner image (set in Enfold > Shop) on the main shop page?

    // Fix Enfold from using 1500px wide image and use the full-size image instead
    add_action( 'init', 'ssi_woocommerce_full_width_category_images', 50 );
    function ssi_woocommerce_full_width_category_images()
    {
    	remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
    	add_action( 'ava_after_main_container', 'avia_woocommerce_parallax_banner_child_theme', 11);
    
    	function avia_woocommerce_parallax_banner_child_theme($bg, $overlay, $opacity, $description, $font)
    	{
    
    		if(is_numeric($bg))
    		{
    			$bg = wp_get_attachment_image_src($bg, 'full');
    			if(is_array($bg) && $bg[0] != "") $bg = $bg[0];
    		}
    
    		if($font) $font = "style='color:{$font};'";
    		if($bg) $bg = "background-image: url(".$bg.");";
    
    		$output = "";
    
    		$output .='<div id="av_product_description" class="avia-section main_color avia-section-large avia-no-border-styling avia-full-stretch av-parallax-section av-section-color-overlay-active avia-bg-style-parallax container_wrap fullsize" data-section-bg-repeat="stretch" '.$font.'>';
    		$output .='<div class="av-parallax  avia-full-stretch" data-avia-parallax-ratio="0.3">';
    		$output .='<div class="av-parallax-inner" style="'.$bg.' main_color background-attachment: scroll; background-position: 50% 50%; background-repeat: no-repeat;">';
    		$output .='</div>';
    		$output .='</div>';
    
    		$output .='<div class="av-section-color-overlay-wrap">';
    		if(!empty($overlay))
    		{
    			$output .='<div class="av-section-color-overlay" style="opacity: '.$opacity.'; background-color: '.$overlay.'; "></div>';
    		}
    
    		$output .='<div class="container">';
    		$output .='<main class="template-page content av-content-full alpha units">';
    		if($description) $output .= "<h1>".$description."</h1>";
    		$output .='</main></div></div></div>';
    
    		return $output;
    	}
    
    	remove_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner', 11 );
    	add_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner_child_theme', 11 );
    
    	function avia_woocommerce_big_cat_banner_child_theme()
    	{
    		if(is_product_category())
    		{
    			global $wp_query, $avia_config;
    
    			if(isset($wp_query->query_vars['taxonomy']))
    			{
    				$term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']);
    				if(!empty($term->term_id))
    				{
    					$description 	= term_description() ;
    					$style 			= get_woocommerce_term_meta($term->term_id, 'av_cat_styling');
    					$attachment_id 	= get_woocommerce_term_meta($term->term_id, 'thumbnail_id');
    
    					$overlay 	= get_woocommerce_term_meta($term->term_id, 'av-banner-overlay');
    					$font 		= get_woocommerce_term_meta($term->term_id, 'av-banner-font');
    					$opacity 	= get_woocommerce_term_meta($term->term_id, 'av-banner-overlay-opacity');
    
    					if(!empty($style))
    					{
    						remove_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 );
    						echo avia_woocommerce_parallax_banner_child_theme($attachment_id, $overlay, $opacity, $description, $font);
    						$avia_config['woo-banner'] = true;
    					}
    				}
    			}
    		}
    	}
    }
    
    #875916

    Hey Andrius,

    Thank you for using Enfold.

    How could this code be adjusted to not remove the banner image (set in Enfold > Shop) on the main shop page?

    Please remove the following line.

    remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
    

    Best regards,
    Ismael

    #876563

    Hi @Ismael,
    thanks for your reply. However, removing the line seems to duplicate the banners. On the main shop page I get a single shop banner (set in Enfold > Shop), but in the category pages I get both – the main shop banner as well as the category banner. I’d like to have the main banner (Enfold > Shop) only displayed on the main shop page and on category pages I’d like to see only the category-specific banner.

    Screenshot

    • This reply was modified 6 years, 5 months ago by Andrius.
    #877195

    Hi @Ismael, I was just wondering if you have any updates on my message above?

    #877348

    Hi,

    I’m sorry for the late response. Please replace it with the following code instead.

    if( is_tax( 'product_cat' ) && ! is_shop() ) {
       remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
    }

    Best regards,
    Ismael

    #877483

    Hi @ismael, many thanks for your response. However, the issue persists. The banners are still doubled on the category page.

    Here’s the full code I’m using:

    // Fix Enfold from using 1500px wide image and use the full-size image instead
    add_action( 'init', 'ssi_woocommerce_full_width_category_images', 50 );
    function ssi_woocommerce_full_width_category_images()
    {
    	if( is_tax( 'product_cat' ) && ! is_shop() ) {
        remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
        }
    	add_action( 'ava_after_main_container', 'avia_woocommerce_parallax_banner_child_theme', 11);
    
    	function avia_woocommerce_parallax_banner_child_theme($bg, $overlay, $opacity, $description, $font)
    	{
    
    		if(is_numeric($bg))
    		{
    			$bg = wp_get_attachment_image_src($bg, 'full');
    			if(is_array($bg) && $bg[0] != "") $bg = $bg[0];
    		}
    
    		if($font) $font = "style='color:{$font};'";
    		if($bg) $bg = "background-image: url(".$bg.");";
    
    		$output = "";
    
    		$output .='<div id="av_product_description" class="avia-section main_color avia-section-large avia-no-border-styling avia-full-stretch av-parallax-section av-section-color-overlay-active avia-bg-style-parallax container_wrap fullsize" data-section-bg-repeat="stretch" '.$font.'>';
    		$output .='<div class="av-parallax  avia-full-stretch" data-avia-parallax-ratio="0.3">';
    		$output .='<div class="av-parallax-inner" style="'.$bg.' main_color background-attachment: scroll; background-position: 50% 50%; background-repeat: no-repeat;">';
    		$output .='</div>';
    		$output .='</div>';
    
    		$output .='<div class="av-section-color-overlay-wrap">';
    		if(!empty($overlay))
    		{
    			$output .='<div class="av-section-color-overlay" style="opacity: '.$opacity.'; background-color: '.$overlay.'; "></div>';
    		}
    
    		$output .='<div class="container">';
    		$output .='<main class="template-page content av-content-full alpha units">';
    		if($description) $output .= "<h1>".$description."</h1>";
    		$output .='</main></div></div></div>';
    
    		return $output;
    	}
    
    	remove_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner', 11 );
    	add_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner_child_theme', 11 );
    
    	function avia_woocommerce_big_cat_banner_child_theme()
    	{
    		if(is_product_category())
    		{
    			global $wp_query, $avia_config;
    
    			if(isset($wp_query->query_vars['taxonomy']))
    			{
    				$term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']);
    				if(!empty($term->term_id))
    				{
    					$description 	= term_description() ;
    					$style 			= get_woocommerce_term_meta($term->term_id, 'av_cat_styling');
    					$attachment_id 	= get_woocommerce_term_meta($term->term_id, 'thumbnail_id');
    
    					$overlay 	= get_woocommerce_term_meta($term->term_id, 'av-banner-overlay');
    					$font 		= get_woocommerce_term_meta($term->term_id, 'av-banner-font');
    					$opacity 	= get_woocommerce_term_meta($term->term_id, 'av-banner-overlay-opacity');
    
    					if(!empty($style))
    					{
    						remove_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 );
    						echo avia_woocommerce_parallax_banner_child_theme($attachment_id, $overlay, $opacity, $description, $font);
    						$avia_config['woo-banner'] = true;
    					}
    				}
    			}
    		}
    	}
    }
    
    #877949

    Hi,

    Thank you for the update.

    Please try this instead.

    if( is_tax( 'product_cat' ) ) {
       remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
    }

    If it’s still not working, please post the WP and FTP details in the private field so that we can test it.

    Best regards,
    Ismael

    #878218

    Hi @ismael, I’ve added your adjusted code and it completely stopped the website from rendering (no error, but renders a blank white page). Could you please log in to the site and have a look? I have commented out the code snippet so the site loads now.

    #878452

    Hi mazeika!

    Can you please check server log for error?

    Cheers!
    Victoria

    #879929

    Hi @victoria, which server log should I check and for what kind of error? the problem is clearly in the code snippet provided by @ismael as the site works once it’s commented out and worked with previous versions of his snippet. However, I really need to be able change the category page banners per category yet keep the main shop banner (set in Enfold > Shop). I provided the admin logins in the post below.

    #881005

    Hi,

    Did you set the “e-parduotuve/” page as the base shop page in the Woocommerce > Settings > Products panel?

    Best regards,
    Ismael

    #881063

    @ismael, yes, that’s correct

    #881804

    Hi,

    Please provide a link to the “e-parduotuve” page. I can’t find it in the Pages panel. The base shop page is set to “Geles namus”.

    Best regards,
    Ismael

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.