WooCommerce send email on a scheduled date - php

I am working on a custom Wordpress / WooCommerce plugin development, the point is: customer orders a medical treatment and schedules treatment date (for an instance, he orders today and schedules his treatment in 16 days 2/28/2021), plugin should check that date in the db table (let's assume that we fetch that from wp_usermeta table under meta_key => 'treatment_date') and set a trigger mail function 7 days before the treatment date. Mail function should e-mail customer that he's left 7 days until his treatment.
This is going to be developed as a custom plugin.
Any ideas how should look like that mail trigger function?

Related

WooCommerce - Send monthly emails based on monthly orders recap

I need to send a monthly invoice to customers every month with all the orders from the last month.
suppose a customer comes to your site 4 times in a month. he places different items in the orders and you want to send him a report with all 4 orders and items. quantity, the total amount.
I took a look to this solution: WooCommerce - Send monthly emails based on order date

How to implement tour/activity availability management backend easiest way

I am implementing some travel product booking project with codeigniter framework & mysql database.
The problem is there are different availability to those products and i want to save & fetch availability of product easily
When user searches by date i need to fetch available tours & activities on that date
Ex:
Experiences
Themeparks - It available everyday with opening & closing timing. User has to select date only to book it (for some parks one of the weekday will be holiday)
Cooking Classes - these will have slots, user has to book particular date & time slot on that day to book it
Tours
Group Tours - Provider will give fixed dates, user has to select from those dates to book it
Individual Tours - User can select any date to book it
I had to work on two individual scheduling solutions for experiences & tours. Please help me to do it
Just use RRule to create scheduling like that
https://medium.com/#ScullWM/design-and-manage-recurring-events-fb43676e711a

Gravity forms date based price calculation

I'm a WP newbie and am amazed so far by what it can do. I am currently using Gravity forms to charge my customers for a monthly subscription plan. However I give my users option to choose the months they want to enrol for and charge them for it as they enrol.
FromDate = Date entered by the user in From Date field (in days)
ToDate = Date entered by the user in To date field (in days)
So my formula for price calculation is:
(ToDate - FromDate)* (cost per day of my subscription)
However, I don't know how to implement this. Any help would deeply be appreciated.
The Gravity Forms Date Time Calculator plugin will allow you do to all sorts of date-based calculations. It's available by request to Gravity Perks users.

PHP:update table automatically in mysql

I am building a simple coupon code buying application with apis.
Here is the work flow
User can select a coupon (getcoupon api)
If a coupon is obtained and its marked as pre_book then go the payment api for the payment.
If payment is success then coupon marked as booked
This works fine but i need help in the following:
If user is prebooked the coupon and aborted the payment i want to mark coupon code status as avaliable after sometime (say its 15 min) this should also happens when payment fails.
Structrue of coupon_code table
1.id-PK
2.coupon_code
3.status
Can i use a crone job for this?? but i don't think its possible because its not a periodic update .
Save the datetime of the payment attempt in the database
Create a cronjob that runs every minute
Update the table and set the payment_date as NULL using the following WHERE in your update query WHERE payment_date < DATE_SUB(NOW(),INTERVAL 15 MINUTE)

Programming logic - update the database only one time after specific time interval

I am developing ecommerce store in php and I have some problem in creating a logic. The problem is I have a store page where I am showing some products. all the products have some time interval,after interval passes the products will no longer be display there.
For example
Product: jeans
time left: 10 days.
after 10 days jeans product will no longer be there. in database I have a set a field with the name active_status which accepts Y or N..
I know that I can simply run the update query and set the status to "N" after time passes. here in this example after 10 days
BUT the question is WHEN DO I RUN THIS UPDATE QUERY ?
should I always check time and run again and again update query and set STATUS TO 'N'??? IS that is the only solution ?
I mean usually we do like for example if customer logins we set some status or any other event but here we are setting the status against checking the time. Hopefully you have understand my question
In the db I am saving the start time and number of days which user puts through the admin panel
My first shot would be cron, php script and properties table (if needed, because for simple uses you could just store expiration date inside business entity).
Cron runs php script periodically (e.g. once a day),
scripts checks if there is anything to delete, based on properties table, or entity properties.
If there is anything to delete, script performs deletion of selected content.
That's all and it is in fact very popular scenario.
More on cron: http://www.pantz.org/software/cron/croninfo.html
Here is my logic i hope it will helps i think
While Publishing the product we have to maintain the time interval of that product for example if you want to display the product for 10 days give 10 days and date of publish product.
By comparing with that date and number of days given for time interval with the present date i.e today's date
Can you check with this

Categories