Products disappearing from My Downloads on price change

Posted by: Amber Elliot

5th May 2021, 10:27 pm

Amber Elliot

@anelliot

5 May 2021
10:27 pm

My use case requires that once customers have downloaded a free product, they should always be able to access that product in the My Downloads section of their account. However, the products are only free for a month (using a scheduled sale); then they revert back to a paid price. It seems that the default behavior with this plugin is to remove the download in My Downloads when the price has been changed and is no longer free. Is there a setting that allows previously downloaded products to persist in My Downloads, even if the product itself is no longer free? Apologies if there is and I've missed it; I just haven't found a way to do this.

  • Developer
    Richard Webster

    @rwebster

    6 May 2021
    6:00 am

    Hi Amber, before getting into it I should advise that download history logs are stored in the DB and if those logs were ever cleared out, the user's download history, and subsequently showing it on their account page, would also disappear.

    The simplest way to achieve what you want would also have the side effect of allowing those users to download the files from the product page again. Is that going to be an issue?

  • Amber Elliot

    @anelliot

    6 May 2021
    6:43 pm

    Thanks so much for your response. The download logs makes perfect sense, and I don't plan to clear those out.

    It's completely fine if the users who have already downloaded the products to be able to download them again from the product page; the users who have already downloaded them once can always have free access to them.

  • Developer
    Richard Webster

    @rwebster

    7 May 2021
    2:41 pm

    Hi Amber, if you use a plugin called Code Snippets you can add the following snippet:

    add_filter('somdn_is_product_valid', 'custom_somdn_product_valid_if_downloaded', 99, 2);
    function custom_somdn_product_valid_if_downloaded($valid, $product_id)
    {
        $downloaded = somdn_has_user_downloaded_product($product_id, get_current_user_id());
        
        if ($downloaded == true) {
            return true;
        }
        
        return $valid;
    }

    Let me know how you get on.

  • Amber Elliot

    @anelliot

    8 May 2021
    10:13 pm

    This worked perfectly! Thank you so much for your help, I really appreciate it.

  • Developer
    Richard Webster

    @rwebster

    9 May 2021
    6:39 am

    No problem 🙂