• Resolved totallywp

    (@panatapattu)


    My WooCommerce category structure is like:

    • Parent Category
    • Parent Category
      • First Level Sub Category
        • Third Level Sub Category
        • Third Level Sub Category
      • First Level Sub Category
        • Third Level Sub Category
        • Third Level Sub Category
    • Parent Category

    I just want to show related products from the current category. Ex: if user is in third level sub category show related products from that category only. If user in second level products from second level and third level.

    Currently, related products for third level sub category also showing from parent categories. Is there any filters or hooks I can use to achieve this?

    Thanks in advance

Viewing 12 replies - 1 through 12 (of 12 total)
  • Saif

    (@babylon1999)

    Hello @panatapattu,


    I’m not sure if I fully understand your request here.

    On my test, if a product is from a subcategory, then only products from that subcategory are in the “Related products” section.


    Link to image: https://d.pr/i/IHV9wl


    Link to image: https://d.pr/i/CW6CJu

    Could you please elaborate more and attach your system status report? You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”.? Once you’ve done that, paste it here in your response.

    Look forward to hearing back from you.

    Thread Starter totallywp

    (@panatapattu)

    Hi @babylon1999,

    Yes, you’re correct. I am exactly looking for this. If the product is from a subcategory, then only products from that subcategory are in the “Related products” section.

    ### WordPress Environment ###
    
    WordPress address (URL): https://example.com
    Site address (URL): https://example.com
    WC Version: 7.4.0
    REST API Version: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img> 7.4.0
    WC Blocks Version: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img> 9.4.3
    Action Scheduler Version: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img> 3.5.4
    Log Directory Writable: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    WP Version: 6.1.1
    WP Multisite: –
    WP Memory Limit: 1 GB
    WP Debug Mode: –
    WP Cron: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    Language: en_US
    External object cache: –
    
    ### Server Environment ###
    
    Server Info: LiteSpeed
    PHP Version: 8.1.15
    PHP Post Max Size: 1 GB
    PHP Time Limit: 1500
    PHP Max Input Vars: 2000
    cURL Version: 7.84.0
    OpenSSL/1.1.1p
    
    SUHOSIN Installed: –
    MySQL Version: 10.3.37-MariaDB-cll-lve
    Max Upload Size: 1 GB
    Default Timezone is UTC: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    fsockopen/cURL: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    SoapClient: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    DOMDocument: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    GZip: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    Multibyte String: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    Remote Post: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    Remote Get: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    
    ### Database ###
    
    WC Database Version: 7.4.0
    WC Database Prefix: wpno_
    Total Database Size: 36.39MB
    Database Data Size: 30.16MB
    Database Index Size: 6.23MB
    wpno_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    wpno_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    wpno_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wpno_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wpno_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_actionscheduler_actions: Data: 1.47MB + Index: 0.95MB + Engine InnoDB
    wpno_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_actionscheduler_logs: Data: 0.19MB + Index: 0.14MB + Engine InnoDB
    wpno_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
    wpno_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_litespeed_url: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_litespeed_url_file: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
    wpno_options: Data: 22.02MB + Index: 1.11MB + Engine InnoDB
    wpno_postmeta: Data: 3.52MB + Index: 2.02MB + Engine InnoDB
    wpno_posts: Data: 1.52MB + Index: 0.36MB + Engine InnoDB
    wpno_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_term_relationships: Data: 0.48MB + Index: 0.30MB + Engine InnoDB
    wpno_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    wpno_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wpno_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wpno_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    wpno_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    wpno_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    wpno_wc_product_attributes_lookup: Data: 0.08MB + Index: 0.06MB + Engine InnoDB
    wpno_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_wc_product_meta_lookup: Data: 0.08MB + Index: 0.13MB + Engine InnoDB
    wpno_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    wpno_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    wpno_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    
    ### Post Type Counts ###
    
    acf-field: 72
    acf-field-group: 7
    attachment: 773
    nav_menu_item: 27
    page: 13
    post: 1
    product: 518
    product_variation: 472
    project: 13
    revision: 75
    wpcf7_contact_form: 2
    yith_wcan_preset: 1
    
    ### Security ###
    
    Secure connection (HTTPS): <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    Hide errors from visitors: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    
    ### Active Plugins (8) ###
    
    Advanced Custom Fields PRO: by WP Engine – 6.0.7
    Breadcrumb NavXT: by John Havlik – 7.2.0
    Contact Form 7: by Takayuki Miyoshi – 5.7.4
    Custom Post Type UI: by WebDevStudios – 1.13.4
    Show Current Template: by JOTAKI Taisuke – 0.4.6
    Variation Swatches for WooCommerce: by Emran Ahmed – 2.0.18
    WooCommerce: by Automattic – 7.4.0
    YITH WooCommerce Ajax Product Filter: by YITH – 4.19.0
    
    ### Inactive Plugins (3) ###
    
    Akismet Anti-Spam: by Automattic – 5.0.2
    Hello Dolly: by Matt Mullenweg – 1.7.2
    LiteSpeed Cache: by LiteSpeed Technologies – 5.3.2
    
    ### Settings ###
    
    API Enabled: –
    Force SSL: –
    Currency: USD ($)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    Connected to WooCommerce.com: –
    Enforce Approved Product Download Directories: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    Order datastore: WC_Order_Data_Store_CPT
    
    ### WC Pages ###
    
    Shop base: #113 - /shop/
    Cart: #114 - /cart/
    Checkout: #115 - /checkout/
    My account: #116 - /my-account/
    Terms and conditions: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/274c.svg"></img> Page not set
    
    ### Theme ###
    
    Name: Theme Name
    Version: 1.0
    Author URL: 
    Child Theme: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/274c.svg"></img> – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
    WooCommerce Support: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    
    ### Templates ###
    
    Overrides: theme-name/woocommerce/archive-product.php version - is out of date. The core version is 3.4.0
    theme-name/woocommerce/checkout/form-checkout.php
    theme-name/single-product.php version - is out of date. The core version is 1.6.4
    
    Outdated Templates: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/274c.svg"></img>
    					
    					
    						Learn how to update
    
    ### Admin ###
    
    Enabled Features: activity-panels
    analytics
    coupons
    customer-effort-score-tracks
    import-products-task
    experimental-fashion-sample-products
    shipping-smart-defaults
    shipping-setting-tour
    homescreen
    marketing
    multichannel-marketing
    mobile-app-banner
    navigation
    new-product-management-experience
    onboarding
    onboarding-tasks
    remote-inbox-notifications
    remote-free-extensions
    payment-gateway-suggestions
    shipping-label-banner
    subscriptions
    store-alerts
    transient-notices
    woo-mobile-welcome
    wc-pay-promotion
    wc-pay-welcome-page
    
    Disabled Features: minified-js
    product-variation-management
    settings
    
    Daily Cron: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img> Next scheduled: 2023-02-22 04:02:53 +00:00
    Options: <img draggable="false" role="img" class="emoji" alt="?</img>" src="https://s.w.org/images/core/emoji/14.0.0/svg/2714.svg"></img>
    Notes: 52
    Onboarding: skipped
    
    ### Action Scheduler ###
    
    Complete: 3,057
    Oldest: 2023-01-23 02:38:39 +0000
    Newest: 2023-02-21 08:12:26 +0000
    
    Failed: 1
    Oldest: 2023-02-15 03:43:29 +0000
    Newest: 2023-02-15 03:43:29 +0000
    
    Pending: 1
    Oldest: 2023-02-22 08:12:26 +0000
    Newest: 2023-02-22 08:12:26 +0000
    
    
    ### Status report information ###
    
    Generated at: 2023-02-21 11:20:15 +00:00
    `

    Hi there @panatapattu

    Thank you for reaching out, with further information on this. From what I gather, while the behavior is as expected at my colleague’s test site, on yours is not.

    I am investigating the site’s System Status Report (SSR) and, it appears that there might be custom functionality affecting this.

    Could you go ahead with trying the following, and let us know how it goes, please?

    • Deactivate all plugins, other than WooCommerce
    • Switch to the Storefront theme
    • Make sure all server-side, CDN, and browser cache are cleared and disabled

    Tools to help with troubleshooting

    Meks Quick Plugin Disabler will remember what plugins you had active when you switch it back on.

    You can clone your site to a staging environment and perform tests without modifying your live site or impacting customers. Many hosts provide staging facilities, so it’s worth checking in with them. It’s also possible to do it using the free WP Staging plugin.

    Looking forward to your response. Thank you. ??

    Thread Starter totallywp

    (@panatapattu)

    Is it possible for you to mention the custom functionality to disable it?

    Hi @panatapattu

    As mentioned by Pepe above, there might be a third-party plugin or your theme that is causing the conflict on your site as to why the behavior or related products are not showing properly.

    Hence, to this out, please try to switch to the default Storefront theme and only WooCommerce plugin is enabled and see if this works?

    If so, then this kind of problem is usually caused by your theme or a third-party plugin present on your site. We can run a conflict test to verify this. I’d recommend cloning your site to a staging environment and performing the tests described on this guide without modifying your live site or impacting customers. Many hosts provide staging facilities, so it’s worth checking in with them. It’s also possible to do it using the free WP Staging plugin.

    If this was caused by a third-party plugin present on your site, it would be best to reach out to the developers for further assistance here.

    If this did not resolve the issue, please provide the fatal error logs (if any) under WooCommerce > Status > Logs.

    You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.

    Let us know how it goes!

    Roxy

    (@roxannestoltz)

    Hi @panatapattu ,

    Have you managed to identify the cause of the issue after performing a full conflict test as suggested above?

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if you need any further help with this.

    Cheers!

    Thread Starter totallywp

    (@panatapattu)

    Hi, I couldn’t identify the error so far. I have few action hooks related to WordPress/WooCommerce theme.

    Thread Starter totallywp

    (@panatapattu)

    Hi all, I did the same as you’ll have instructed me to do. I created a staging site and activated the StoreFront theme and tested it. But I am getting the same result here as well. Not all related products are from the current product category. It’s showing related products apart from the current product category as well.

    If need to access my website or the cloned website I can give you a login if required. Please let me know a way to share the credentials with you.

    Regards,

    Saif

    (@babylon1999)

    Hello @panatapattu,

    Thank you for trying our suggestions so far.

    Have you tried making sure only the child product is selected?


    Link to image: https://d.pr/i/XODBiY


    It’s also worth checking if there are any shared tags between the products.

    In the example below, the t-shirt product is not part of the sub-category but it’s rendering because it’s sharing a tag with the product I’m reviewing.


    Link to image: https://d.pr/i/6nw0qD

    Let us know how it goes!

    Thread Starter totallywp

    (@panatapattu)

    @babylon1999

    Thank you for your prompt feedback on this. As I said in the initial question there is a flow of 3 levels.

    • Parent Category
    • Second Level Category
    • Third Level Category

    These mentioned not related products belong to third-level categories. They’re attached to their parents because they’re listed in mentioned categories on some pages.

    Saif

    (@babylon1999)

    Hello @panatapattu,

    These mentioned not related products belong to third-level categories. They’re attached to their parents because they’re listed in mentioned categories on some pages.

    Just to make sure if I understand this correctly, these products have two levels selected, parent and child but want to limit related products depending on the child selected only.

    As I explained above, you can achieve this by selecting the child category only. With both category levels selected, that’s not possible.

    You can alter the behaviour of the related products sections using this hook woocommerce_output_related_products but I’m afraid that’s not within our scope of support.

    Since this is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.


    Cheers!

    Thread Starter totallywp

    (@panatapattu)

    @babylon1999,

    Thank you for your response. As you mentioned in your response there are 3 categories. I can’t limit it to exactly one category.

    Thanks & Regards,

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Related products not showing in correct way’ is closed to new replies.