Important:
This support area is for Kalium 3 users only.
Support for Kalium 4 has moved to our new platform at support.laborator.co.
If you’re using Kalium 4, please create a new account there using your email and license key. A password will be sent to you automatically.
I loved this theme. I built my eshop nice and quick. I have only one stupid question. Somehow single products page show only a variation of 30-40 RELATED PRODUCTS. I have a bookstore with more of 7000 (more are coming). I need the RELATED PRODUCTS section to pick random products from the same category as the single one.
e.g. If the product is a children's book under 12 y.o., I want random related books from that category. if it is a horror book, the same etc.
I know how to fix manually the linked / cross selling product section. I just need that on related.
Thank you very much.
Hi Martin,
I have researched about this issue and it seems to be a WooCommerce issue that it does not show products from the same category only, I found some plugins such as Related Products for WooCommerce or some code which shows items only from a specific category where the product is, but for that I would need your login credentials.
Can you please share your site credentials here, because we need to login to your site and see this issue live. Your information is safe (private) in this thread.
To include your credentials click Insert Credentials button in the editor toolbar. (See how)
Best regards,
Laborator Team
Hi Martin,
I was trying to login to your site but the credentials wasn't working. However can you please try this code snippet which will narrow the related products query to only the same sub category:
/** * Only show products in the same sub categories in the related products area * * @param $terms - Terms currently being passed through * @param $product_id - Product ID of related products request * @return $terms/$subcategories - Terms to be included in related products query */ function blz_filter_related_products_subcats_only($terms, $product_id) { // Check to see if this product has only one category ticked $prodterms = get_the_terms($product_id, 'product_cat'); if (count($prodterms) === 1) { return $terms; } // Loop through the product categories and remove parent categories $subcategories = array(); foreach ($prodterms as $k => $prodterm) { if ($prodterm->parent === 0) { unset($prodterms[$k]); } else { $subcategories[] = $prodterm->term_id; } } return $subcategories; } add_filter( 'woocommerce_get_related_product_cat_terms', 'blz_filter_related_products_subcats_only', 20, 2 );The above code should be added in functions.php file of the theme (preferably on child theme).