Limit all products to one per customer

  • Posts: 306
  • Thank you received: 4
  • Hikaauction Standard Hikamarket Multivendor Hikashop Business
4 months 1 week ago #357766

Hi there,

Is there some way to limit ALL products to one per customer?

I am using calcbuilder to create "products" which are actually leads. There are three leads generated by default, based on the PHP code in the calculator, which is: $hk_quantity=3;

Is there an option (either by means of a setting or by using PHP code on the calculator, to limit every lead to one per user?

I plan to create three leads for each calculation and then have contractors offering a service "claim" them in the backend. But I want to make them available to three separate companies.

Hope that makes sense!

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
4 months 1 week ago #357770

Hi,

In the menu Products>Limits, you can create limits on purchases. So you can configure a limit for a product so that each users won't be able to purchase that product more than once (it won't even work with different orders). The only solution for them would be to create several user accounts.
So I think it fits your needs.
The downside though is that you need to create one limit per product. Because if you create a limit for all the products, then the users will only be able to purchase a product once and not anymore after that.
You can read more about limits here:
www.hikashop.com/support/documentation/2...limits-tutorial.html

So one solution would be to have a way to generate the limit in the hikashop_limit table each time a product is created. Supposing that Calcbuilder generates the products via the save function of class.product of HikaShop, then you can interface a mass action with an INSERT MySQL query to automatically create the entry in the hikashop_limit table. So it's quite simple, even without coding knowledge. Or maybe Calcbuilder offers some kind of PHP code execution capability where you could have it run the MySQL query for you ?

Otherwise, you could always create a plugin to interface with the add to cart process to check that the product being added to the cart by the current user is possible or not based on the previous orders of the user and if not, cancel the add to cart.
That's for example something we do in the 'cart reservation' plugin: www.hikashop.com/marketplace/product/208...art-reservation.html
In it, we check that the products being added to the cart are not already reserved by other users in their carts and if that's the case, we cancel the add to cart with the appropriate message. So it's the same mechanism, but with another condition.
Of course, in the case of a custom plugin, you have more leeway to have it work exactly the way you want, but it requires a PHP developer to work on it...

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

  • Posts: 306
  • Thank you received: 4
  • Hikaauction Standard Hikamarket Multivendor Hikashop Business
4 months 1 week ago #357796

Hi again,

Okay, that sort of makes sense. So if I added the code

$hk_limit=1;

to the Calcbuilder code that creates the product after calculation, that should limit each product to 1 per customer?

Thanks!

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
4 months 1 week ago #357798

Hi,

I don't know. What is $hk_limit ? Is it something from Calcbuilder ? I would recommend you check with Calcbuilder what they recommend as I don't know how it works at all.

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

  • Posts: 306
  • Thank you received: 4
  • Hikaauction Standard Hikamarket Multivendor Hikashop Business
4 months 1 week ago #357799

Hi,

Sorry - that's my fault. I don't quite know how to figure out the names for these things.

I've attached a screenshot showing some of the PHP code that is creating the Hikashop products from Calcbuilder results.

So, for instance, it uses the code $hk_quantity to limit the quantity of each "product" to three.

I want to add a line of code that works on the "limit" you mentioned, and limit it to one. I tried just using $hk_limit, but since it doesn't work, I assume that's not right.

Instead of $hk_quantity, what would I start that line of code with to ensure that the quantity on the created product is limited to one?

Attachments:

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
4 months 4 days ago #357815

Hi,

Ok.
You won't be able to create the limit in there.
To be able to create the limit, you need the product id. And in this code, you have yet to create the product, and thus, the product is not yet known.
As I said, the first thing is to check with the support of Calcbuilder to see what they recommend on how to proceed with this based on what I wrote previously.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum