I am building an e-commerce site with limited edition products.

Each Woocommerce product page has a custom attribute when the product will no longer be available to purchase.

When the product sale period completes, the 'add to cart button' is removed. If the original seller views their dashboard page, I can display a notification that their campaign has ended.

However, an admin needs to visualize the products that have been completed and their sale statistics. I can't rely on a function to send this data if it only runs when the original seller logs in.

Logically, do I run a daily WP-CRON job that queries all products, compares the current time to their completion date, and conditionally manipulate data if the conditions are true?

Is this bad practice, super slow, or is there a better approach?

Slowly learning, thank you in advance for any guidance.


This doesn't sound like a bad approach to me. The thing to keep in mind about WP_CRON is that it's not a "real" cron and is only triggered when someone visits the site.

To that end, you could also do the check when the product page loads and hide the button as needed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.