• Hi there,

    I want to hide related products (upsell/crossell) for non-login users.

    I found this hook.

    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );

    However, related products are still displayed.

    On the support thread I found this (link)

    // Disable OceanWP upsells
    add_filter('theme_mod_ocean_woocommerce_upsells_count', 'my_theme_mod_ocean_woocommerce_upsells_count', 10 );
    function my_theme_mod_ocean_woocommerce_upsells_count() {
      return '0';
    }

    it was successful to eliminate related products.

    So my question,

    1. How to hide related products for users who are not logged in?

    2. If there is no solution for point 1, how to make the above code snippet work for a user who is not logged in?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Please try to add the below CSS code from the Appearance > Customize > Custom CSS, and check.

    .single-product:not(.logged-in).woocommerce .related.products {
    display: none;
    }

    • This reply was modified 2 years, 10 months ago by Abhishek.
    • This reply was modified 2 years, 10 months ago by Abhishek.
    Thread Starter cimot456

    (@cimot456)

    it’s worked,

    Thank you very much

    • This reply was modified 2 years, 10 months ago by cimot456.

    You are most welcome and Glad to hear that issue has been resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide related products from non logged in users’ is closed to new replies.