Home › Forums › WoodMart support forum › Related products are not showing on some categories
Related products are not showing on some categories
- This topic has 10 replies, 2 voices, and was last updated 10 months ago by Hung Pham.
-
AuthorPosts
-
February 15, 2024 at 3:39 pm #540431
refaParticipantI 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,
February 17, 2024 at 11:15 am #540909
Hung PhamKeymasterHi 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,
February 19, 2024 at 10:19 am #541256
refaParticipantI 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.
February 20, 2024 at 11:04 am #541666
Hung PhamKeymasterHi refa,
I’ve passed this topic to one of our developers, and I will let you know once get an answer.
Regards,
February 20, 2024 at 3:17 pm #541787
Hung PhamKeymasterHi 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,
February 20, 2024 at 3:36 pm #541800
refaParticipantI 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
February 21, 2024 at 11:06 am #542189
Hung PhamKeymasterHi 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,
February 21, 2024 at 11:29 am #542203
refaParticipantI 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.
February 21, 2024 at 2:04 pm #542311
Hung PhamKeymasterHi 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; });
February 21, 2024 at 2:12 pm #542321
refaParticipantThank you so much. Now the issue has been resolved.
February 22, 2024 at 5:59 am #542568
Hung PhamKeymasterHi 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,
-
AuthorPosts
Tagged: related products
The topic ‘Related products are not showing on some categories’ is closed to new replies.
- You must be logged in to create new topics. Login / Register