- Posts: 424
- Thank you received: 11
Want to give a discount on all products or category on every wednesday
- BluepointWebdesign
-
Topic Author
- Offline
Less
More
3 years 5 days ago #356526
by BluepointWebdesign
Want to give a discount on all products or category on every wednesday was created by BluepointWebdesign
-- url of the page with the problem -- :
07.bluepoint-concept.nl/feestdagen/pasen
-- HikaShop version -- : 5.0.0
-- Joomla version -- : 4.3.x
-- PHP version -- : 8.1.x
Hello,
I need some help with giving for example 10% discount on products or category. The discount is not a problem but i want to give the discount
on every Tuesday. How can i accomplish that?
Hope you can help.
Regards,
Mark
-- HikaShop version -- : 5.0.0
-- Joomla version -- : 4.3.x
-- PHP version -- : 8.1.x
Hello,
I need some help with giving for example 10% discount on products or category. The discount is not a problem but i want to give the discount
on every Tuesday. How can i accomplish that?
Hope you can help.
Regards,
Mark
Please Log in or Create an account to join the conversation.
3 years 5 days ago #356530
by nicolas
Replied by nicolas on topic Want to give a discount on all products or category on every wednesday
Hi,
You'll have to first create a discount via the menu Orders>Discounts and configure it to start and end on the next Wednesday.
Once that's done, you can create a mass action with a trigger "every day" and configure a filter so that it always match with exactly one element. For example, it could be a user data mass action with a filter on the user_id being equal to the id of your super admin, which should hopefully never change.
Then, add an action "run MySQL query" with such a MySQL query:
That way, it will increase the start and end dates of the discount by the number of seconds in a week if the end date is smaller than the current date (which means that the discount period ended).
Note that if you have other discounts with start and end dates set in the past, this mass action will also update these, so you might want to add a condition like discount_code = "xxx" so that you target only one specific discount.
You'll have to first create a discount via the menu Orders>Discounts and configure it to start and end on the next Wednesday.
Once that's done, you can create a mass action with a trigger "every day" and configure a filter so that it always match with exactly one element. For example, it could be a user data mass action with a filter on the user_id being equal to the id of your super admin, which should hopefully never change.
Then, add an action "run MySQL query" with such a MySQL query:
Code:
UPDATE #__hikashop_discount SET discount_start = discount_start*604800, discount_end = discount_end*604800 WHERE discount_end > 1 AND discount_start > 1 AND discount_end < UNIX_TIMESTAMP();
Note that if you have other discounts with start and end dates set in the past, this mass action will also update these, so you might want to add a condition like discount_code = "xxx" so that you target only one specific discount.
Please Log in or Create an account to join the conversation.
- BluepointWebdesign
-
Topic Author
- Offline
Less
More
- Posts: 424
- Thank you received: 11
3 years 4 days ago #356541
by BluepointWebdesign
Replied by BluepointWebdesign on topic Want to give a discount on all products or category on every wednesday
Hi thanks for this explaination.
I have made a discount for 10% then in mass action with these settings as you gave me.. But the date of discount will go from 2023-11-07 11.24 to 2106-02-07 07:28
What am i doing wrong? the time zone in Global configuration is on Amsterdam.
hope you can help me a little further..
Thanks in advance
I have made a discount for 10% then in mass action with these settings as you gave me.. But the date of discount will go from 2023-11-07 11.24 to 2106-02-07 07:28
What am i doing wrong? the time zone in Global configuration is on Amsterdam.
hope you can help me a little further..
Thanks in advance
Please Log in or Create an account to join the conversation.
- BluepointWebdesign
-
Topic Author
- Offline
Less
More
- Posts: 424
- Thank you received: 11
3 years 4 days ago #356542
by BluepointWebdesign
Please Log in or Create an account to join the conversation.
3 years 4 days ago #356543
by nicolas
Replied by nicolas on topic Want to give a discount on all products or category on every wednesday
Hi,
My bad, I was a bit fast when writing the MySQL query
I wrote * instead of +. Of course the seconds of 1 week ( 604800 ) need to be added to the existing date, and not multiplying it.
So the query should be:
My bad, I was a bit fast when writing the MySQL query
I wrote * instead of +. Of course the seconds of 1 week ( 604800 ) need to be added to the existing date, and not multiplying it.
So the query should be:
Code:
UPDATE #__hikashop_discount SET discount_start = discount_start+604800, discount_end = discount_end+604800 WHERE discount_end > 1 AND discount_start > 1 AND discount_end < UNIX_TIMESTAMP();
Please Log in or Create an account to join the conversation.
- BluepointWebdesign
-
Topic Author
- Offline
Less
More
- Posts: 424
- Thank you received: 11
3 years 4 days ago #356554
by BluepointWebdesign
Replied by BluepointWebdesign on topic Want to give a discount on all products or category on every wednesday
No problem.. I tested it with this and after processing mass action, the discount neatly went 7 days ahead.. yes to next week tuesday.
Does the mass action goes automaticly now? or do i have to make a cron job for this?
thanks..
Does the mass action goes automaticly now? or do i have to make a cron job for this?
thanks..
Please Log in or Create an account to join the conversation.
3 years 4 days ago #356555
by nicolas
Replied by nicolas on topic Want to give a discount on all products or category on every wednesday
Hi,
You need to cron job to be set up so that the query can run every day. And the query will only update the discount if the end date is in the past, so it's not a problem if it runs every day.
You need to cron job to be set up so that the query can run every day. And the query will only update the discount if the end date is in the past, so it's not a problem if it runs every day.
Please Log in or Create an account to join the conversation.
Time to create page: 0.059 seconds