Badges based on stock range

  • Posts: 238
  • Thank you received: 29
  • Hikashop Business
2 days 1 hour ago #365760

-- HikaShop version -- : 5.1.3
-- Joomla version -- : 5.2.3
-- PHP version -- : 8.1

Hi
I was looking for a way to dispaly 3 badges based on stock
"enough quantity" when the stock is over lets say 20 - and more
"limited quantity" when the stock is 1-19
"no stock" when the stock is 0.
limited quantity I see that when I create a badge, there is an option for quantity, but the badge it is displayed only when that quantity is identical with that value.
Now, while I was writing this, I was thinking to use mass actions + cron job and to create 2 categories for the "enough quantity" and "limited quantity" and with the mass action and cron job to add any of the category to the products.
Doing that, I can link the badge to the category.
But for that I would have to run a cron job quite often for all products, it seems a bit overkill to me.
That's why I think using a range would be more useful.

And I would also have a suggestion for badges, maybe custom fields can be brought into the discussion here as a future feature :whistle:
Thank you, and have a nice day!

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

  • Posts: 83296
  • Thank you received: 13466
  • MODERATOR
1 day 20 hours ago #365764

Hi,

If your mass actions are properly configured I don't see a problem with that.
For example, you can have a mass action with :
- a trigger "every minute" (it will actually run each time the cron task is triggered)
- a filter on product_quantity > 0
- a filter on product_quantity < 20
- a filter on category_id != XX (where XX is the id of the category for products with stock between 1 and 20 )
- an action "update the categories" "add" category with the id XX
- an action "update the categories" "remove" category with the id YY (where YY is the id of the category for products with stock above 20 )
This way, the mass action will filter out the products to process only the products for which the category is missing and it should be there.

Regarding the reason why it's not a range:
That's because we thought that badges were used mainly to promote products or easily see that products are one of stock.
So we tought that having only a matching value would be enough. But thanks for your feedback. We'll take it into account for future improvements.

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

Time to create page: 0.056 seconds
Powered by Kunena Forum