HI @aviaggarwal ,
Can you suggest me how can I add download permission programmatically for an order? I have a button which triggers a function to download the file. I can easily add a code which by default re-generates the permission to download the product every time the button is clicked.
Thanks for adding that additional information; you are free to add the code if you’d like but without your system status it’s hard for us to understand your site settings and what might be causing your customers to lose download permissions after a few short days and whether or not a code snippet is necessary or not!
As @maykato mentioned, if you prefer to share your system status with us without the site URL or any other sensitive information, please feel free to delete the parts you don’t want to post on the forum. You can find your system status by going to WooCommerce–>Status–>Get System Status–>Copy Status for Support.
The above step is important for us in regards to troubleshooting since, after looking at your product settings, it does seem like you are using a plugin that allows users to use credits to pay for orders. This isn’t something that is built into WooCommerce Core and it could potentially be one of the reasons that the download permissions keep expiring for your customers (if you have the download set to unlimited and no expiry
, the expected behaviour is that those links don’t expire).
Additionally, this could also be connected to a setting on the file itself. Sometimes, cloud-sharing systems (ex: Google Drive or Dropbox) have configuration options that allow you to limit the amount of time that someone has access to a file; it might be worth it to take a look at those settings where you host the file and ensure that they are set properly as well.
Alternatively, as @maykato mentioned in the previous response, you can also perform a conflict test to see if one of the plugins you have installed might be the cause of your downloads expiring.
Additionally, I’d also recommend running a conflict test to check if the issue is coming from a conflict with your theme or another plugin – please temporarily switch your theme back to Storefront and disable all plugins except for WooCommerce. If that resolves the issue, then re-enable plugins one-by-one until you find the one that’s causing the conflict.
If you don’t want to test on your live site, you can create a staging site using a plugin called WP Staging: https://www.ads-software.com/plugins/wp-staging/
You can find a more detailed explanation on how to do a conflict test here: https://docs.woocommerce.com/document/how-to-test-for-conflicts/
I hope that helps! Let us know how that goes and if we can help further.
Best,
Sarah G.
Happiness Engineer–WooCommerce.com