Out of stock notification:just one mail when only a product stock drops to cero?

  • Posts: 16
  • Thank you received: 2
1 year 11 months ago #341086

-- HikaShop version -- : 4.5.0
-- Joomla version -- : 3.9.24
-- PHP version -- : 7.2.34

Hi Nicholas and the Hikashop team:

I have set up an "out of stock notification" and it works. Everyday I receive a report with all the products out of stock in the same message.

But, is there any way to configurate this notification to work individually and only when a product is out of stock or below X unities. I mean, instead of receiving everyday the "same" mail, I would like to receive just an e-mail informing me that the product "whatever" is now out of stock, and that's all. This mail will trigger just once, when the product is out of stock or drops below X unities.

Thank you once and again for your great support and congratulations for your top position in the last "CMS Awards" contest.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 11 months ago #341090

Hi,

Thanks.

You can configure a threshold in the settings of the out of stock plugin via the Joomla plugins manager.
But there is no mechnism to only provide the products without stock once.
That would require some development with an extra column in the database to set a flag for each product notified.
A simpler solution would be to create a mass action via the menu System>Mass actions like so:
- a trigger "every day"
- a filter on the product_quantity column being equal to zero
- a second filter on the product_sale_end date being equal to zero
- an action "update the values" on the product_sale_end column with the mode "operation" and the value UNIX_TIMESTAMP()
That will trigger the mass action once a day. It will get all the products without stock with a "sale end date" not set and set automatically that "sale end date" to the current date so that the product is not available anymore.
Then, in the settings of the out of stock plugin, you need to adjust the "last cron update" value to the unix timestamp of the UTC date and time just before the mass action runs every day. That way, every day, the plugin will send the notifications for the new products out of stock and then this mass action will set a sale end date on these products so that the plugin will skip the products on the next day.
Out to get a unix timestamp from a date: www.epochconverter.com/

The following user(s) said Thank You: Udo, Galle43

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

  • Posts: 220
  • Thank you received: 8
1 year 5 months ago #345701

Hi,

I also very much miss the opportunity to receive a notification when a product gets out of stock. Preferably immediately after the last ordering of this product, otherwise once a day. an overview of all products getting sold out that day.

For me the out of stock plugin is of no use since it mails about all products out of stock. And there are a lot of them in the shop...

I've tried to find a way getting it done using the mass actions. Hopeful I tried the trigger 'after a product is updated' and a filter on the product_quantity column being 0. But to my disappointment that trigger only refers to updates done in the backend, not to changes as a result of an order.

Nicolas suggests a creative solution. The disadvantage is that all out of stock products get a sale end date. In our shop we never use the sale start date and sale end date.
So when adding new stock you not only have to update the quantity field but also cancel the end of sale date. You can predict that this will sometimes go wrong in practice. So I hesitate using this solution.

And I wonder: does it also work for product variants?

regards,
Udo

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 5 months ago #345709

Hi,

You could have a second mass action with an "after a product is updated" trigger and an filter on the product_quantity column being greater than 0 and an action update the values on the product_sale_end column set to empty. That way, when add stock back to a product, it would automatically clear the sale_end_date. That way, no worries of forgetting about reseting it.

And yes, it also works with variants.

The following user(s) said Thank You: Udo

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

  • Posts: 220
  • Thank you received: 8
1 year 4 months ago #346105

Hi Nicolas,

Good idea! I did some testing and the proposed second mass action works fine.

However, this mass action has a limitation: it only works when manually changing the stock in the backend.
If an order of a product that has stock 1 is canceled after a few days this massa action is not triggered. The stock is being restored from 0 to 1.
but the the sale_end_date is not removed.

Is there a way to handle that situation?

Thanks,
Udo

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 4 months ago #346106

Hi,

That's complex. The normal product update triggers are not called when this happens. That's because the MySQL is optimized so that even if you have a 100 different products in the order, the system will be able to update the stock of all the products involved without the processing crashing in the middle because too much things is being done for each product.
So we do ahve specific triggers there onBeforeProductStockUpdate and onAfterProductStockUpdate but each is triggered only once for all the products of the order, and the massaction system cannot be plugged there.

An alternative would be to add a second trigger "every minute" to the second mass action. That way, on top of changing the sale_end_date when a product is saved, it would also check the products at each cron task tic to update the sale_end_date if necessary. So the product would be back on the frontend a few minutes after the order would have been cancelled.

The following user(s) said Thank You: Udo

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

  • Posts: 220
  • Thank you received: 8
1 year 4 months ago #346244

Hi,

Thanks, adding a second trigger is a fine solution .
The second trigger doesnot need to be "every minute". The specific situation doesnot happen that often.
The trigger every day will do.

Now there are two mass actions with trigger every day.
In hikashop_config I've set the key "massaction_last_trigger_days" in a way that the first mass action is triggered just after the out of stock plugin.
The second mass action daily trigger will use this same date and time, I suppose.

However, I understand it is not allowed to have two cron processes running at the same time; The second massa action should be triggered at least 15 minutes later. But that is not possible since it uses the same massaction_last_trigger_days.

How two avoid that? What will happen if there are two triggers at the same time?

I hope my explanation is clear. Setting trigger date and time is very confusing for me, especially because the frequency chosen in the Hikashop cron task influences the actual timing of the mass actions.


regards,
Udo

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
1 year 4 months ago #346245

Hi,

Several mass actions can be processed in the same cron task trigger as long as their "every **" is the same.

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

  • Posts: 220
  • Thank you received: 8
1 year 4 months ago #346269

Hi,

Ah, that 's nice.

A small improvement of the filter in the second mass action for out of stock products getting new stock.

You proposed using the filter product quantity column being greater than 0.
In that way product quantity -1 (unlimited) is not selected.
That is why I use the filter !=0

Thanks for the great support

Udo

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

Time to create page: 0.076 seconds
Powered by Kunena Forum