Post by stijnman » Wed Sep 11, 2019 2:35 am

I have products that can be ordered with a choice of extra options.
Stock quantity = 1
there are 3 options

The customer can select option1 + add to cart, next option2 + add to cart, and option3 +add to cart. The card will then list 3 items, all with availability. But there is only 1!

Only if the customer adds the same option 2x, it will show a warning.

This is the case regardless of option quantity settings.

Is there any extension/ code available to correct the stock availability warning / disconnect from options.

thanks a lot for any suggestion

Newbie

Posts

Joined
Mon Jun 20, 2016 7:54 pm

Post by letxobnav » Wed Sep 11, 2019 12:56 pm

Had the same issue some time ago:
find in system/library/cart/cart.php

Code: Select all

				// Stock
				if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
					$stock = false;
				}
change it to

Code: Select all

				// CHANGE[F8665] find all occurrences of product in cart line items
				$ptotal = 0;
				foreach ($cart_query->rows as $cart_3) {
					if ($cart_3['product_id'] == $cart['product_id']) $ptotal = $ptotal + $cart_3['quantity'];
				}
				// CHANGE[F8665] Stock
				if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity']) || ($product_query->row['quantity'] < $ptotal)) {
					$stock = false;
				}

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by stijnman » Wed Sep 11, 2019 7:21 pm

Thanks a lot, that did it!
:)

Newbie

Posts

Joined
Mon Jun 20, 2016 7:54 pm
Who is online

Users browsing this forum: No registered users and 21 guests