Want to give a discount on all products or category on every wednesday

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
5 months 2 weeks ago #356526

-- 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

Please Log in or Create an account to join the conversation.

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
5 months 2 weeks ago #356530

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:

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();
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.

Please Log in or Create an account to join the conversation.

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
5 months 2 weeks ago #356541

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

Please Log in or Create an account to join the conversation.

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
5 months 2 weeks ago #356542

forgot to sent allong my settings :)

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
5 months 2 weeks ago #356543

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:

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.

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
5 months 2 weeks ago #356554

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..

Please Log in or Create an account to join the conversation.

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
5 months 2 weeks ago #356555

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.

Please Log in or Create an account to join the conversation.

Time to create page: 0.073 seconds
Powered by Kunena Forum