-
AuthorPosts
-
May 6, 2022 at 11:09 am #1350783
Hi there
I have a shop build but am experiencing issues with prev/next when scrolling through the shop. I have various category pages and when an item is selected for purchase/viewing the next/previous scroll through brings up items outside of the category of the item selected. I saw on a previous post that items are set in date form, but can this be set as category instead?
I hope you can help as my client is not happy about this issue.
Thanks, Silvio
May 9, 2022 at 5:54 am #1350985Hey Silvio,
Thank you for the inquiry.
You can try this code in the functions.php file to limit the post or product navigation to the same category, but it might not work as expected if the products belong to multiple categories. It works best if the products have a single category.
function avf_post_nav_settings_mod($settings) { if($settings['type'] == 'product') { $settings['taxonomy'] = "product_cat"; $settings['same_category'] = true; } return $settings; } add_filter( 'avf_post_nav_settings', 'avf_post_nav_settings_mod', 10, 2);
Best regards,
IsmaelMay 13, 2022 at 8:16 am #1351640Hi this has no affect at all…
May 16, 2022 at 5:49 am #1351895Hi,
Thank you for the update.
Did you replace the navigation, or use a different plugin? Looks like you are now using a custom navigation in the product pages with this markup.
<div class="tpnpb_prev_next_buttons tpnpb_prev_next_buttons_top tpnpb_prev_next_buttons_desktop tpnpb_prev_next_buttons_display"><a href="https://site.plesk.page/product/rare-silver-mounted-thai-or-burmese-lance/" rel="next">← Previous</a><a href="https://elated-tereshkova.149-255-60-157.plesk.page/product/rare-sulawesi-shield/" rel="prev">Next →</a></div>
The filter above should work on the default post navigation with limitations that we mentioned previously.
Best regards,
IsmaelMay 16, 2022 at 12:09 pm #1351924Don’t know if this is totaly different to ismaels snippet – but can you try:
function enfold_customization_postnav($settings){ if('product' == $settings['type'] ) { $settings['same_category'] = true; $settings['is_fullwidth'] = false; $settings['skip_output'] = false; } return $settings; } add_filter('avf_post_nav_settings','enfold_customization_postnav', 10, 1);
And think of caching and merging etc. to refresh.
May 16, 2022 at 12:27 pm #1351927Thanks Guenni007 – this has made a slight difference, but wrong categories still appear..
May 17, 2022 at 9:44 am #1352033I think the problem is not that Ismael’s snippet does not work. I have tested Ismael’s snippet – and it works here on my test installation.
But the problem occurs when you have multiple “product categories” for a product.
See e.g. the shop demo there are “men” and “women” products – but they both have : “casual” as another category.
( here again ismaels snippet)function avf_post_nav_settings_mod($settings){ if($settings['type'] == 'product'){ $settings['taxonomy'] = "product_cat"; $settings['same_category'] = true; } return $settings; } add_filter( 'avf_post_nav_settings', 'avf_post_nav_settings_mod', 10, 2);
If now a men’s product is called, which is also sorted with casual, then it can be that also women’s products are displayed.
I removed all product categories from men products. By that you only have men product post navigation.May 17, 2022 at 1:30 pm #1352075Hi,
I have now removed any products with 2 categories and I still have total chaos whilst using prev/next in the shop, I even get out of stock items even though out of stock is selected in the product grid, it’s a mess…in some cases it only shows 3 or 4 items out of many 10’s whilst using the prev/next…
Silvio
May 19, 2022 at 8:35 am #1352251Hi,
For out of stock products, you may need to adjust the Out of stock visibility option and tick the Hide out of stock items from the catalog checkbox in the Woocommerce > Settings > Products > Inventory panel.
// https://rudrastyh.com/woocommerce/hide-out-of-stock-products.html
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.