Post by jclaudii » Wed Jul 27, 2011 11:57 pm

This is a hot one, any help would be appreciated. Version 1.4.9.4

I have code that will allow the add to cart button to be "hidden" until the time I specify, this allows me to control when an item drops. Problem is a item may be a very hot and sought after item and I will only have 1 of them with 20 people trying to add it to the cart when the item drops. Currently all 20 people can add it to their cart, it's the first person to successfully check out that will get the item. I originally thought one transaction will go in before the other and the others will get denied because it is NOW out of stock. THIS IS NOT THE CASE, it shows up as quantity -2, so it obviously does not work like I described. IS this a bug, can it be fixed?

Here is a test that we performed, please see if anyone else can duplicate:
made a coupon code for a buck off and free shipping
made a test product for 1 dollar with a qty of 1 and set out of stock to be displayed when item is out of stock
have you and a buddy both add it to their cart and then check out within the same time frame

both orders should have gone through
both orders showed up successful in your admin panel
the qty should now be -1


Thanks for help on this!

Newbie

Posts

Joined
Thu Jul 21, 2011 12:04 am

Post by Xsecrets » Thu Jul 28, 2011 1:39 am

yes the system isn't designed for this type of transaction. Currently it checks the stock when you add the item to the cart then doesn't check it again and simply decrements the stock once the order is completed. This works for most people. In order to get what you want it will be some work. There are a couple of ways to do it.

1) go ahead and decrement the stock when it's added to the cart. This could be a problem though as someone could come along and add everything in your store to their cart and essentially shut down your store.

2) is more complicated, but probably the best way. check the stock again after clicking the confirm button just before sending it off to the processor and decrement the stock then. Of course you would then have to keep track and check it again when the processor returns information so you can add it back in if the process fails. This code would have to be added to every payment module in order to work efficiently.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by jclaudii » Thu Jul 28, 2011 2:58 am

My customer has been wanting option 1, but with a TTL tied to it of like 5 min. This would allow people enough time to add it to their cart and then check out with it, if they just add it and don't check out within 5 min, it removes the item from their cart

I currently have no idea on how to do the above, if you have any idea on where to start. Also, I have setup 1.5.1 as a playground to see if it performs the exact same way.

right now we are only using the paypal module.

Newbie

Posts

Joined
Thu Jul 21, 2011 12:04 am

Post by jclaudii » Thu Jul 28, 2011 10:47 pm

any help on where to look for either one of the above examples and I may be able to figure it out. I just need some guidance. Thanks!

Newbie

Posts

Joined
Thu Jul 21, 2011 12:04 am

Post by jclaudii » Fri Jul 29, 2011 12:46 am

Is the deducting from cart handled in the catalog/model/chekcout/order.php? That is where the below snipit is from. If this *IS* the code, where do I put it so it deducts it as soon as the "add to cart" button is clicked. Also, Where can I set the session timer so I can make sure that if it is not active for more than 5 min it gets ADDED back to the stock for someone else to checkout with.

thanks!

Code: Select all

foreach ($order_product_query->rows as $order_product) {
				$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");
				
				$order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product['order_product_id'] . "'");
			
				foreach ($order_option_query->rows as $option) {
					$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");
				}
			}

Newbie

Posts

Joined
Thu Jul 21, 2011 12:04 am

Post by Xsecrets » Fri Jul 29, 2011 1:28 am

well yes that's where it does it currently, but that is not tied to the cart. You will have put that code in the cart stuff. It would take even me quite a bit of time to track it all down and do it, and I do not have any customers who need it, so that's why I haven't responded.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by jclaudii » Thu Sep 22, 2011 5:43 am

I am still needing this, if anyone has some time to help out I'm sure some money could be handed your way for a hack like this to work.

I have had several promises for some help and lots of failed attempts on my side of trying to get this code to work. If you don't have the time to do it all, just help me out by letting me know where I need to put high lvel code and what needs to happen.

I have looked at other shopping carts like zen cart and a few others and they use the same type of paypal transfer method and some have reported having this same delayed check and comeout with overselling a product. Again...any help would be appreciated!

Newbie

Posts

Joined
Thu Jul 21, 2011 12:04 am

Post by MikeSCC » Wed Apr 10, 2013 9:36 pm

I would also appreacite some help or advice on how to reduce the stock level on 'Add to Cart', then add the stock back on if checkout isn't completed within a certain time period.

Thanks

Active Member

Posts

Joined
Tue Nov 20, 2012 5:55 pm
Who is online

Users browsing this forum: No registered users and 330 guests