Home Forums WoodMart support forum Theme Update Product Layout Affected

Theme Update Product Layout Affected

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #613983

    ignitionstudio
    Participant

    I have been leveraging the “extra content” placed “before” on products so that the category title carries over so the user sees consistent page flow… The issue after the latest update to the theme has the content being slightly rearranged. The extra content before is not being placed before the sidebar and so now the sidebar is moved slightly higher and over the content. My ask in support is how do we resolve this because simple css position options are not working. But also, if it would be easier to add the category title to the single product page instead of using the extra content to display an html block is an option, that would be greatly appreciated solution. Then the category titles carry over into the products and I can eliminate the extra content. You can see in my screenshots the current live site has the extra content bar above the main content and sidebar. But following the update to the theme, the other screenshot shows now how the sidebar is over the extra content.

    Attachments:
    You must be logged in to view attached files.
    #614135

    Artem Temos
    Keymaster
    Xtemos team

    Hello,

    Try to remove the extra content and add the following code snippet to the functions.php file in the child theme instead

    add_action( 'woodmart_after_header', function () {
    	global $product;
    
    	if ( ! $product ) {
    		return;
    	}
    
    	$terms = get_the_terms( $product->get_id(), 'product_cat' );
    
    	if ( ! $terms ) {
    		return;
    	}
    
    	$terms_array = array();
    	$parent      = array();
    	$child       = array();
    
    	foreach ( $terms as $term ) {
    		$terms_array[ $term->term_id ] = $term;
    
    		if ( ! $term->parent ) {
    			$parent[ $term->term_id ] = $term->name;
    		}
    	}
    
    	foreach ( $terms as $term ) {
    		if ( $term->parent ) {
    			unset( $parent[ $term->parent ] );
    
    			if ( array_key_exists( $term->parent, $terms_array ) ) {
    				$child[ $term->parent ] = get_term( $term->parent )->name;
    			}
    
    			$child[ $term->term_id ] = $term->name;
    		}
    	}
    
    	$terms = $child + $parent;
    
    	$title_class  = '';
    	$title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' );
    	$title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' );
    	$title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' )
    
    	?>
    	<div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>">
    		<div class="container">
    			<h1 class="entry-title title"><?php echo array_shift( $terms ); ?></h1>
    		</div>
    	</div>
    	<?php
    } );

    Kind Regards

    #614432

    ignitionstudio
    Participant

    Excellent. That was the div that I identified as what was missing. However, this fix has now the category title showing twice on the category landing page. See screenshots. Also, I have a script that is replacing category titles with custom brand titles on specific products, so I will attach that script and would love it if you could help me figure out how to apply it to the code you just provided. Thanks much!!!

    Attachments:
    You must be logged in to view attached files.
    #614437

    ignitionstudio
    Participant

    custom script to change woocommerce titles attached…

    #614535

    Artem Temos
    Keymaster
    Xtemos team

    Try to replace the previous code with the following one

    add_action( 'woodmart_after_header', function () {
    		global $product;
    
    		if ( ! $product || ! is_singular( 'product' ) ) {
    			return;
    		}
    
    		$terms = get_the_terms( $product->get_id(), 'product_cat' );
    
    		if ( ! $terms ) {
    			return;
    		}
    
    		$terms_array = array();
    		$parent      = array();
    		$child       = array();
    
    		foreach ( $terms as $term ) {
    			$terms_array[ $term->term_id ] = $term;
    
    			if ( ! $term->parent ) {
    				$parent[ $term->term_id ] = $term->name;
    			}
    		}
    
    		foreach ( $terms as $term ) {
    			if ( $term->parent ) {
    				unset( $parent[ $term->parent ] );
    
    				if ( array_key_exists( $term->parent, $terms_array ) ) {
    					$child[ $term->parent ] = get_term( $term->parent )->name;
    				}
    
    				$child[ $term->term_id ] = $term->name;
    			}
    		}
    
    		$terms = $child + $parent;
    		$page_title = array_shift( $terms );
    
    		$title_class  = '';
    		$title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' );
    		$title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' );
    		$title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' );
    
    		if ( is_product_category('woods-c') ) {
    			$page_title = 'Woods® C';
    		}
    		if ( is_product_category('backhoes') ) {
    			$page_title = 'Groundbreaker® Backhoes';
    		}
    		if ( is_product_category('flex-wing-rotary-cutters') ) {
    			$page_title = 'Batwing® Cutters';
    		}
    
    		?>
    		<div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>">
    			<div class="container">
    				<h1 class="entry-title title"><?php echo $page_title; ?></h1>
    			</div>
    		</div>
    		<?php
    	} );

    Kind Regards

    #614790

    ignitionstudio
    Participant

    Oh man. So close. Thank you, but product-category replacement is not being recognized on the single product still. So this code fixed the duplicate header and when on a category landing page the replacement text appears just fine as before, but on single products it is echoing the default category term and not the custom text. I am not an experienced coder and by looking at your code I cannot see why that wouldn’t happen. I appreciate all the help on this. My agency uses your theme for several clients. Functionality is excellent. This site is perhaps our biggest one leveraging the woocommerce, and would love to keep the client happy with these category adjustments. Let me know if this is possible on the single product pages. Thanks!!!!!

    Attachments:
    You must be logged in to view attached files.
    #615427

    Artem Temos
    Keymaster
    Xtemos team

    Hello,

    Please send us your admin access so we can help you.

    Kind Regards

    #615682

    ignitionstudio
    Participant

    Thank you! login credentials in private content below…

    #615695

    Artem Temos
    Keymaster
    Xtemos team

    Here is a new code for this

    add_action( 'woodmart_after_header', function () {
    		global $product;
    
    		if ( ! $product || ! is_singular( 'product' ) ) {
    			return;
    		}
    
    		$terms = get_the_terms( $product->get_id(), 'product_cat' );
    
    		if ( ! $terms ) {
    			return;
    		}
    
    		$terms_array = array();
    		$parent      = array();
    		$child       = array();
    
    		foreach ( $terms as $term ) {
    			$terms_array[ $term->term_id ] = $term;
    
    			if ( ! $term->parent ) {
    				$parent[ $term->term_id ] = $term->name;
    			}
    		}
    
    		foreach ( $terms as $term ) {
    			if ( $term->parent ) {
    				unset( $parent[ $term->parent ] );
    
    				if ( array_key_exists( $term->parent, $terms_array ) ) {
    					$child[ $term->parent ] = get_term( $term->parent )->name;
    				}
    
    				$child[ $term->term_id ] = $term->name;
    			}
    		}
    
    		$terms = $child + $parent;
    		$page_title = array_shift( $terms );
    
    		$title_class  = '';
    		$title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' );
    		$title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' );
    		$title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' );
    	
    		$terms = get_the_terms(get_the_ID(), 'product_cat');
    		if ( $terms && !is_wp_error($terms) ) {
    			foreach ( $terms as $term ) {
    				if ( $term->slug === 'woods-c' ) {
    					$page_title = 'Woods® C';
    					break;
    				}
    				if ( $term->slug === 'backhoes' ) {
    					$page_title = 'Groundbreaker® Backhoes';
    					break;
    				}
    				if ( $term->slug === 'flex-wing-rotary-cutters' ) {
    					$page_title = 'Batwing® Cutters';
    					break;
    				}
    			}
    		}
    
    		?>
    		<div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>">
    			<div class="container">
    				<h1 class="entry-title title"><?php echo $page_title; ?></h1>
    			</div>
    		</div>
    		<?php
    	} );

    Kind Regards

    #616330

    ignitionstudio
    Participant

    Thank you. I am still not seeing the proper subcategory when on individual products. Your code appears to reference children of parent category but on single products the page title reverts to the parent category and not the subcategory (for example on BrushFighter Cutters it shows Rigid Rotary Cutters and or Disc Harrows it reverts to Tillage). There are a total of 7 categories that have subcategories and while the landing archive works the single products do not.

    Attachments:
    You must be logged in to view attached files.
    #616479

    Artem Temos
    Keymaster
    Xtemos team

    Hello,

    It looks like you changed the admin password and we can’t enter your dashboard now.

    Kind Regards

    #616737

    ignitionstudio
    Participant

    Hello! My mistake. It has been reset to previous access provided…

    #616758

    Artem Temos
    Keymaster
    Xtemos team

    Here is the new code for this

    add_action( 'woodmart_after_header', function () {
    		global $product;
    
    		if ( ! $product || ! is_singular( 'product' ) ) {
    			return;
    		}
    
    		$terms = get_the_terms( $product->get_id(), 'product_cat' );
    
    		if ( ! $terms ) {
    			return;
    		}
    
    		$terms_array = array();
    		$parent      = array();
    		$child       = array();
    
    		foreach ( $terms as $term ) {
    			$terms_array[ $term->term_id ] = $term;
    
    			if ( ! $term->parent ) {
    				$parent[ $term->term_id ] = $term->name;
    			}
    		}
    
    		foreach ( $terms as $term ) {
    			if ( $term->parent ) {
    				unset( $parent[ $term->parent ] );
    
    				if ( array_key_exists( $term->parent, $terms_array ) ) {
    					$child[ $term->parent ] = get_term( $term->parent )->name;
    				}
    
    				$child[ $term->term_id ] = $term->name;
    			}
    		}
    
    		$terms = $child + $parent;
    		$page_title = array_pop( $terms );
    
    		$title_class  = '';
    		$title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' );
    		$title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' );
    		$title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' );
    	
    		$terms = get_the_terms(get_the_ID(), 'product_cat');
    		if ( $terms && !is_wp_error($terms) ) {
    			foreach ( $terms as $term ) {
    				if ( $term->slug === 'woods-c' ) {
    					$page_title = 'Woods® C';
    					break;
    				}
    				if ( $term->slug === 'backhoes' ) {
    					$page_title = 'Groundbreaker® Backhoes';
    					break;
    				}
    				if ( $term->slug === 'flex-wing-rotary-cutters' ) {
    					$page_title = 'Batwing® Cutters';
    					break;
    				}
    			}
    		}
    
    		?>
    		<div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>">
    			<div class="container">
    				<h1 class="entry-title title"><?php echo $page_title; ?></h1>
    			</div>
    		</div>
    		<?php
    	} );

    Kind Regards

    #616771

    ignitionstudio
    Participant

    Excellent! Thanks so much for all of your efforts!!!!

    #616922

    Artem Temos
    Keymaster
    Xtemos team

    You are welcome. Feel free to contact us if you have any further questions.

Viewing 15 posts - 1 through 15 (of 15 total)

The topic ‘Theme Update Product Layout Affected’ is closed to new replies.