Question and error with limits

  • Posts: 176
  • Thank you received: 5
  • Hikashop Business
5 years 3 weeks ago #305431

-- HikaShop version -- : 4.0.3
-- Joomla version -- : 3.9.4
-- PHP version -- : 7.0.33

I would like to set up a limit for a specific user group to have a spending monthly spending limit for several categories and sub-categories.

Specifically, a $400 monthly limit on all the categories and sub-categories of a vendor (we are using HikaMarket). This would reset to $400 each month.

Few Questions:

1) Can this be done with Limits?
2) Is there a way the user can check how much of their Limit 'balance' they have used / how much is left for the month?
3) Is there a different/better way you would suggest accomplishing this functionality? (we are also using AWOcoupon on this website)

Also, when trying to set up a test Limit in Hikashop, I believe I ran into a bug.

Here are the steps I followed to produce the issue:

1) Hikashop > Products > Limit > New
2) "Type" defaults to "Quantity". As soon as I try changing the "Type" to "Price" or "Weight" the page refreshes and goes back to the Hikashop > Products > Limit page list. As a result, I cannot save any Limits unless they are set to Type: Quantity.

Please advise.

Thank you,
Dustin

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
5 years 3 weeks ago #305447

Hi,

1. Yes, this should be possible with limits.

2. There is no such capability. The limit system is only used to check the cart load and add to cart processes. That would require some development to be able to add such display, for example on the user control panel.

3. No, I think that the limit feature is the only way to achieve this unless you want to do some development.

4. Thank you for your feedback. There is indeed a bug here. You would have to save first the limit as "quantity" type and then you would be able to change its type the way it is done now. I've added a patch on our end for that. So you can download the install package on our website and install it on yours to get the patch for that problem.

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

  • Posts: 176
  • Thank you received: 5
  • Hikashop Business
5 years 3 weeks ago #305462

Thank you. Can you provide some insight into what value(s) would need to be pulled from the database to display the remaining balance?

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
5 years 2 weeks ago #305463

Hi,

The thing is that the limits are checked dynamically each time you add a product to the cart or load the cart.
So you would have to run a complex MySQL query between the tables hikashop_order, hikashop_order_product, hikashop_product, hikashop_product_category and hikashop_category (or several queries, because one query on 5 tables is quite a beast) in order to pull all the confirmed/shipped orders of all the products of all the categories you want in your limit for the current period and the sum up the price*quantity of each product in the orders and deduct it from the allowance.

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

  • Posts: 176
  • Thank you received: 5
  • Hikashop Business
5 years 2 weeks ago #305671

Would you be able to share the query that is run when the cart is loaded? Perhaps we could duplicate this in a custom dashboard, or have it display in the cart itself during checkout: "Your remaining balance for this month is ... "

Having access to this info is important for our uses. So, any further guidance you can provide would be greatly appreciated.

Thank you,
Dustin

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
5 years 2 weeks ago #305687

Hi,

The query is dynamic based on how your limit rules are configured.
You can look at the function getUserOrderProducts in the file administrator/components/com_hikashop/classes/limit.php
That's where the query is constructed to load the products data from the past orders so that you can then sum the prices and quantities already purchased in PHP and then check the limits rules.

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

Time to create page: 0.065 seconds
Powered by Kunena Forum