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
Related
I need to set subscription billing to 1st of every month in stripe. I have followed doc https://stripe.com/docs/billing/subscriptions/billing-cycle, but not exactly cleared how to set it for per month.
Thanks in Advance
For Stripe Subscriptions to bill on the 1st of every month you need to do the following:
Use a recurring Price that bills monthly
Set billing_cycle_anchor to a timestamp on the 1st of the month
From the documentation you linked to in your question:
For example, a customer with a monthly subscription set to cycle on the 2nd of the month will always be billed on the 2nd.
So it sounds like you're on the right track!
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?
i want to get users from table that have atleast total of 20,000 $ buy in 50 days.
for example -> a user may have bought a service 200 days ago with amount of 5,000 and bought another service with amount of 10,000 180 days ago and , another service he bought was 160 days ago with amount of 5,000.
so the time between these are less than 50 and total amount is atleast 20,000 then he is the user that should be returned.
another example -> a user bought a service 80 days ago with amount of 10,000 and another service with amount of 5,000 in 40 days ago and, last service was 5,000 in 20 days ago
so the amount is 20,000 but he couldn't fill it in 50 days because his last buy was 60 days after the first on , so he can't be the user we want.
however if this user bought another service in 10 days ago with amount of 10,000 then he can be the user because his second , third and fourth buy was in 50 days and had atleast 20,000 .
i explained as much as i could.
the point is that the date can be a day of 2 years ago and maybe the user filled 20,000 with 5 product .
i'm attaching my table picture here so if u write query for this table it would be very good .
its just 1 table.
invoice table
the total column in my table is the price for 1 specific buy.
and the column for date is date column.
EDIT
this is the query i got , its just getting total and my problem is with time .
SELECT invoice.userid, Sum(invoice.total) AS totsam
FROM invoice
GROUP BY table.userid
HAVING totsam > 20000
something along the lines of
SELECT * FROM table WHERE days < 50 AND totalAmount > 20000
SELECT *
FROM invoice_table
WHERE
(DATEDIFF(CURDATE(),invoice_table.date)<50
AND SUM(total)>20000)
I am planning to develop a cash back module in the following scenario:
There will be test cases that admin can set a cash back for one product whose date range conflicts with previously defined cashbacks on the same product.
For example:
admin set a cash back for a product P1 as (possibilities):
26-Dec-2016 to 29-Dec-2016 10%
25-Dec-2016 to 30-Dec-2016 10%
24-Dec-2016 to 31-Dec-2016 10%
How to handle the date range so that cashback date range does not overlap with other dates?
Or admin can not set a new cash back if a date range falls in previously defined cash back for a specific date range. If we can go with this then how to manage (how to check date range is falls in another one).
I'm assuming, Inside database you are storing the cashback as a row with the CashbackStartDate and CashbackEndDate as columns.
When ever setting a new date range, say newStartDate and newEndDate, first search for all the cashbacks with CashbackStartDate less than newEndDate and then CashbackEndDate grater than newStartDate.
This will grab all the cashback with the overlapping dates, for you.
Back to your question, just check if any rows are returned, if yes then .....you know what to do.
Sample SQL code:
... WHERE newStartDate < CashbackEndDate
AND newEndDate > CashbackStartDate;
This should get you all the overlapping dates with partial and total overlap.
I am creating a generation of reports per month and per year. There are 15 types of fees that I want to display the total sales per month. I have a date column in my database table with the format of (ex. 2014-09-27). I don't know how to order by it per month (from Jan-Dec) then add all the total of each fee. I have a drop down list to select the year so that I will display the reports per year and per month that depends to my selected year. Each fee in the database has a price.
database name: Registration
table name: Application
columns: DATE_APPLICATION, Barangay_Business_Permit, Business_Plate, Sanitary_Inspection_Fee, Environmental_Clearance, Barangay_Development, Building_Permit, Electrical_Inspection, Mechanical_Inspection, Plumbing_Inspection, Health_Certificate, Signage_Fee, Penalty, Barangay_Clearance, Barangay_Certification, Construction_Clearance
Based on the updated information, You would need to pull a select based on the dates and then sum the columns grouping by the Date_Application if you want to calculate the totals for the applications by month or year. So for a monthly listing:
Select SUM(Barangay_Business_Permit), SUM(Business_Plate), SUM(Sanitary_Inspection_Fee),
SUM(Environmental_Clearance), SUM(Barangay_Development), SUM(Building_Permit),
SUM(Electrical_Inspection), SUM(Mechanical_Inspection), SUM(Plumbing_Inspection),
SUM(Health_Certificate), SUM(Signage_Fee), SUM(Penalty), SUM(Barangay_Clearance),
SUM(Barangay_Certification), SUM(Construction_Clearance)
from Registration.application GROUP BY MONTH(DATE_APPLICATION);
For a yearly listing:
Select SUM(Barangay_Business_Permit), SUM(Business_Plate), SUM(Sanitary_Inspection_Fee),
SUM(Environmental_Clearance), SUM(Barangay_Development), SUM(Building_Permit),
SUM(Electrical_Inspection), SUM(Mechanical_Inspection), SUM(Plumbing_Inspection),
SUM(Health_Certificate), SUM(Signage_Fee), SUM(Penalty), SUM(Barangay_Clearance),
SUM(Barangay_Certification), SUM(Construction_Clearance)
from Registration.application GROUP BY YEAR(DATE_APPLICATION);
If you want to use the names for the months you would use MONTHNAME(DATE_APPLICATION) instead.