Limit all products to one per customer

  • Posts: 324
  • Thank you received: 4
  • Hikamarket Multivendor Hikashop Business
1 year 1 day 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: 83022
  • Thank you received: 13403
  • MODERATOR
1 year 21 hours 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: 324
  • Thank you received: 4
  • Hikamarket Multivendor Hikashop Business
1 year 11 hours 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: 83022
  • Thank you received: 13403
  • MODERATOR
1 year 6 hours 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: 324
  • Thank you received: 4
  • Hikamarket Multivendor Hikashop Business
1 year 6 hours 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: 83022
  • Thank you received: 13403
  • MODERATOR
11 months 3 weeks 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.

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
6 months 3 weeks ago #361277

Nicolas, i'm using Products>Limits to limit just one purchase per product for customer. So if customer wants to order another one same product, Hikashop cart notification plugin shows message for small time (defined in plugin) and disappears. So in my case user just sees that message for 1s and that's it. Is it possible to notify customer in different notification way in this case? Like the same way "The cart is empty" notification in bredcrumbs.

Last edit: 6 months 3 weeks ago by arnask.

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

  • Posts: 83022
  • Thank you received: 13403
  • MODERATOR
6 months 3 weeks ago #361282

Hi,

There is no option for this. However, it's possible with some custom coding.
HikaShop provides javascript events, including cart.updated in order to process what the server-side returns after the user clicks on add to cart:
www.hikashop.com/support/documentation/6...ocumentation.html#js
The HikaShop cart notification plugin actually implements this event in order to display the notification box.
It is done in the file plugins/hikashop/cartnotify/media/notify.js
Also, since Joomla 4, it's possible to use javascript code to dynamically display error messages via the Joomla message system:
joomla.stackexchange.com/questions/20579...mla-using-javascript
So, if you're a developer, you can combine all this to add your own error messages to the pages as needed.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
6 months 3 weeks ago #361326

unfortunately i'm not developer, so its impossible for me to notify customer in descent way :(

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

  • Posts: 83022
  • Thank you received: 13403
  • MODERATOR
6 months 3 weeks ago #361328

Hi,

You could hire a developer to work on this for you.
If that's something you would like us to work on for you, you can request a quote via our contact form:
www.hikashop.com/support/contact-us.html

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

Time to create page: 0.080 seconds
Powered by Kunena Forum