Display Random Products in Related Products

This topic has 11 replies, 3 voices, and was last updated 2 years, 3 months ago ago by Rose Tyler

  • Avatar: Krishan
    Krishan
    Participant
    June 1, 2022 at 16:15

    Hi Team,

    I want the following changes in related products.

    1. Related products should show Random Products
    2. Want another related products that show related products using Attribute – Color. For e.g., Current product is Color – Yellow, so related should show same category yellow color products

    Both these functions were available in my previous theme. I used to show 48 Related Products by Color and 48 Random Related Products. But I am not able to make those changes in this theme.

    Kindly help me or let me know how to make these changes.

    Thanks

    10 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    June 1, 2022 at 16:54

    Hello,

    Related Products is a section that pulls products from your store that share the same tags or categories as the current product https://woocommerce.com/document/related-products-up-sells-and-cross-sells/#section-3

    So, if you want to change products that display there you can implement this by additional customization only. You can submit customization request here.

    Regards

    Avatar: Krishan
    Krishan
    Participant
    June 1, 2022 at 17:58

    I just want to display related products in random order

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    June 2, 2022 at 06:56

    Hello,

    Try to contact the support of WooCommerce plugin.
    Please note that additional customization is outside the scope of our basic support.

    Regards

    Avatar: Krishan
    Krishan
    Participant
    June 2, 2022 at 09:44

    Why so vague answer?

    How come this customization is outside the scope of your basic support.
    You are showing related products in ASC order. I am saying to change it to RAND.

    Just this much work and you are saying its out of basic support.

    My previous theme has this feature inbuilt, yours dosen’t have.

    If this is your support then its worst. Believe it.

    Regretting purchasing this theme. Would like to get my money back instead of wasting time here.

    Thanks

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    June 2, 2022 at 10:52

    Hello,

    We’ve checked more deeply, Related products are displayed in our theme randomly, by default. But on your site it is not, so check if you did any changes in files that may affect it, for example changes in xstore-child/woocommerce/single-product/related.php, or maybe something from 3rd party plugins affects related products.
    You can try to add the next code in functions.php of the child theme:

    add_filter('woocommerce_related_products_args', function($args) {
        $args['orderby'] = 'rand';
        return $args;
    }, 9999);

    If you need any further assistance with this, provide temporary wp-admin and FTP access, so we can take a closer look.

    Regards

    Avatar: Krishan
    Krishan
    Participant
    June 2, 2022 at 12:07

    This code is already added but still not working, sharing site access

    Please contact administrator
    for this information.
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    June 2, 2022 at 14:08

    Hello,

    https://prnt.sc/goVdRvI5oC_E – first load
    https://prnt.sc/_Sbq3nhp-MK_ – the same product after refresh, page shows other products randomly
    Please clear cache and check one more time, provide URL of product where it doesn’t work correctly.

    Regards

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    June 2, 2022 at 14:44

    https://k***eals.com/product/men-cargo-grey/?swcfpc=1 – when URL is like this all is fine. This parameter comes from Super Page Cache for Cloudflare plugin on your site.
    Please follow our previous recommendations: Try to disable all the third-party plugins (including cache plugins), that do not come bundled with XStore https://www.8theme.com/documentation/xstore/plugins/included-plugins/ , clear the cache of the browser and CDN cache, and check then.

    Regards

    Avatar: Krishan
    Krishan
    Participant
    July 28, 2022 at 17:19

    I am using the following code in child function.php but it is not working:

    add_filter(‘woocommerce_related_products_args’, function($args) {
    $args[‘orderby’] = ‘title’;
    $args[‘order’] = ‘ASC’;
    return $args;
    }, 9999);

    Please help,
    Thanks

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    July 29, 2022 at 13:07

    Hello,

    Please note that we are not responsible for custom changes that you do in the child theme.

    1/ your admin access is out of working state
    2/ the code we sent you above is different from the one you sent in last topic. Do you want to show them in rand order or sorted by title because there is only one param that could show either by title or by rand ?

    our code:

    add_filter('woocommerce_related_products_args', function($args) {
    $args['orderby'] = 'rand';
    return $args;
    }, 9999);

    your code:

    add_filter(‘woocommerce_related_products_args’, function($args) {
    $args[‘orderby’] = ‘title’;
    $args[‘order’] = ‘ASC’;
    return $args;
    }, 9999);

    Regards

  • Viewing 11 results - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.