Page 1 of 1

Product Per Option Limit

Posted: Thu Apr 25, 2024 5:10 am
by johnp
Hi all,

Does any one know how to get around this problem.

I have an OC site selling event tickets. I have assigned an option to the ticket for the event attendees name. For each ticket that is added to the basket the name option must be filled in. The problem I'm having is sometimes the event ticket number is going up for the same attendee. Here's an example.

Ticket price £10 - Attendee name = Steve. This is correct.

If there are say two Steves on the same booking I should get this:

Ticket price £10 - Attendee name = Steve.
Ticket price £10 - Attendee name = Steve.

What I'm getting is:

Ticket price £10 - Attendee name = Steve with quantity of 2 in the cart @£20.

I have removed the quantity option from the product page. I have also removed it from the cart page. Still no luck. What I'm looking to do is have OC limit each ticket to the value of 1 each time. Each time another ticket is added it creates a new line in the cart for it and not double up on the original ticket.

I should be able to fix this but sadly I'm stuck. All help is appreciated.

OC 1.5.6.5. OC Bootstrap Pro theme. PHP 7.4

Re: Product Per Option Limit

Posted: Thu Apr 25, 2024 5:31 am
by ADD Creative
The bit of code you want to look at is in system/library/cart.php.
https://github.com/opencart/opencart/bl ... #L318-L340

The add function adds the option to the product ID and uses this as the key in the cart. You would need to somehow make the key unique without changing the data, such as maybe adding a time.

Re: Product Per Option Limit

Posted: Thu Apr 25, 2024 5:56 am
by johnp
ADD Creative wrote:
Thu Apr 25, 2024 5:31 am
The bit of code you want to look at is in system/library/cart.php.
https://github.com/opencart/opencart/bl ... #L318-L340

The add function adds the option to the product ID and uses this as the key in the cart. You would need to somehow make the key unique without changing the data, such as maybe adding a time.
Many thanks. I'll take a look but I think that is a bit above me. I may have to post in the commercial forum. :)

Re: Product Per Option Limit

Posted: Thu Apr 25, 2024 5:58 am
by johnp
FYI this is the site:

https://alternativeview.co.uk

You'll see the problem if you add two of the same products to the cart with two attendee names the same.