Home Forums WoodMart support forum Related products are not showing on some categories

Related products are not showing on some categories

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #540431

    refa
    Participant

    I am unable to see the related products from the single product page on some categories, it is showing empty.
    I attached the screenshot for your reference, please find it from the below private content area.

    Please check and fix this issue ASAP.

    Thank you,

    #540909

    Hung Pham
    Keymaster

    Hi refa,

    Thanks for reaching to us and take our apologies for the long delay in answering.

    Related Products is a section on some templates that pulls products from your store that share the SAME tags or categories as the current product.

    Please read about related products here – https://woocommerce.com/document/related-products-up-sells-and-cross-sells/

    Regards,

    #541256

    refa
    Participant

    I know the same tags/category products will only appear. The products which I am telling will come under the same category. I have 2 categories there one category related products are showing, but the other one is not showing.

    Please find the attached screenshot below.

    #541666

    Hung Pham
    Keymaster

    Hi refa,

    I’ve passed this topic to one of our developers, and I will let you know once get an answer.

    Regards,

    #541787

    Hung Pham
    Keymaster

    Hi refa,

    I kindly request you to conduct a check by activating the default WordPress Theme, such as Storefront or Twenty Twenty-Three (Appearance > Themes) and keep WoodMart Core and Elementor or WPBakery plugins activated. This is to ascertain whether the issue you are experiencing is due to our theme or not.

    Regards,

    #541800

    refa
    Participant

    I did like you said. The related products are showing with the default WordPress “twenty-twenty-four theme”. It’s not working with the woodmart theme.

    I attached the screenshot from both themes below

    #542189

    Hung Pham
    Keymaster

    Hi refa,

    Please add the below code to the functions.php file into the Child theme, and let me know how it goes.

    add_filter('woocommerce_related_products', function ($related_posts) {
    	if ( $related_posts && woodmart_get_opt( 'hide_variation_parent' ) ) {
    		foreach ( $related_posts as $related_post ) {
    			$current_product = wc_get_product( $related_post );
    
    			if ( 'variable' === $current_product->get_type() ) {
    				$related_posts = array_merge( $related_posts, $current_product->get_children() );
    			}
    		}
    	}
    
    	return $related_posts;
    });

    Regards,

    #542203

    refa
    Participant

    I added the code. Now, one or two products are showing in the related products area. I had a product category which I mentioned in the previous message, it was working perfectly now that the category’s related product also showing with 2 or 3 products. I attached the screenshots for your reference.

    I set the related products slider with 5 products.

    Please check and resolve this ASAP.

    #542311

    Hung Pham
    Keymaster

    Hi refa,

    Please remove previous code and use below one, let me know how it goes:

    add_filter('woocommerce_related_products', function ($related_posts) {
    	if ( $related_posts && woodmart_get_opt( 'hide_variation_parent' ) ) {
    		foreach ( $related_posts as $key => $related_post ) {
    			$current_product = wc_get_product( $related_post );
    
    			if ( 'variable' === $current_product->get_type() ) {
    				if ( ! $current_product->get_children() ) {
    					continue;
    				}
    
    				unset( $related_posts[ $key ] );
    				foreach ( $current_product->get_children() as $child_id ) {
    					$related_posts[] = $child_id;
    				}
    			}
    		}
    	}
    
    	return $related_posts;
    });
    #542321

    refa
    Participant

    Thank you so much. Now the issue has been resolved.

    #542568

    Hung Pham
    Keymaster

    Hi refa,

    Glad to hear your issue has been resolved. Keep us in mind for future questions and concerns, we’re always here to help!

    If you have a quick minute we always appreciate a 5-star rating on our theme!

    https://themeforest.net/item/woodmart-woocommerce-wordpress-theme/reviews/20264492

    Your feedback is the motivation to improve our work and services.

    Regards,

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

The topic ‘Related products are not showing on some categories’ is closed to new replies.