How to increase value after every 7 days

Hello everyone,
I am working on a project in which I need to increase the price of a product +$5 after every seven days. Product initial price is $100. I am not an expert in php, is there anyone to help me, how to go about this? Appreciate sample code.



Does your hosting provider let you set up cronjobs?

If so, you could write a PHP script that increases the price of the product in the database by $5 and schedule it to run every seven days (assuming you have the price stored in a database, that is).

Hi Pullo,
Thanks for your reply. I guess i can set up cronjobs from my hosting provider. Can you provide me a sample code how to run schedule script for this.


It’s probably best to use one of the cron generators (example) to generate the correct syntax.

Also depending on the system you’re using, you may simply be able to do some math at runtime.

$price = 10;
$diff = DateTime(somedate)->diff(DateTime());
$days = (int) $diff->format(‘a’);
$price += (floor($days / 7) * 5);

Where somedate is the start date of the pricing (i.e., when it’s $100)

Thank you very much StarLion & ScallioXTX. It helped me a lot.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.