When you sell virtual and downloadable products sometimes you need some time after payment to grant the customer a download access. However, WooCommerce does set the orders with only virtual and downloadable products directly to “Completed” status after payment, which can break your order fulfillment flow. Thankfully WooCommerce is also quite versatile and offers filters to set the order in “Processing” status even if it contains only virtual and downloadable items. Here is how we do it
1. Use the code below and add it to your “theme\functions.php” file(at the bottom is fine).
2. Go to WooCommerce > Settings > Products > Downloadable Products > Uncheck the checkbox “Grant access to downloadable products after payment” > Save
This process will make sure that the orders are marked as “Processing” after they are completed by your gateway and that your customers have access to the downloads only when the order is marked “Completed”
If you have any questions, please write them in the comments.
Comments 5
Thank you – is this code still current and correct as of Sept 2022 ? You dont have a date on this page, but I went to Github and see it is 4 years old.
Yes, the code is still valid
Awesome ! Thank you !
How do you make this product category based?
Well, you have the $product available in the function, so all you need to do is check the product categories and process based on them.
`$categories = $product->get_category_ids()` – will return the categories the product is in.