simondavid Posted January 17, 2018 Share Posted January 17, 2018 Hello, I'm currently facing an issue on our webshop. For example: From product A, we have 1 item in stock. Customer A puts it in his shopping cart, and leaves the website. 2 days later, Customer B puts the same item in his shopping cart, and finishes his order. The next day Customer A comes back to the shop, sees his existing shopping cart, and finishes his order as well. Now we have sold that 1 item, 2 times. Is there any way that we can avoid this? Something like a product availability check everytime a customer goes to another page? This would be very, very helpful. Thanks in advance, Link to comment Share on other sites More sharing options...
MarcinO Posted March 22, 2018 Share Posted March 22, 2018 I am facing similar issue with 1.7.2. Is there a way to solve this problem? Link to comment Share on other sites More sharing options...
MarcinO Posted March 23, 2018 Share Posted March 23, 2018 Simondavid - not a perfect solution, but you can try: 1. creating outofstock.php file in your shop root directory 2. adding the code: <?php require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); $db = Db::getInstance(); $sql = "SELECT c.id_cart, c.id_product_attribute, c.id_product FROM ps_cart_product c LEFT JOIN ps_stock_available s ON s.id_product_attribute = c.id_product_attribute AND s.id_product = c.id_product LEFT JOIN ps_orders o ON o.id_cart = c.id_cart WHERE id_order IS NULL AND s.quantity <1 ORDER BY c.date_add DESC"; $results = Db::getInstance()->ExecuteS($sql); foreach ($results as $r) { $product_id = $r['id_product']; $attribute_id = $r['id_product_attribute']; $cart_id = $r['id_cart']; $sql = "DELETE FROM ps_cart_product WHERE id_cart = '$cart_id' AND id_product_attribute = '$attribute_id' AND id_product = '$product_id'"; $db->Execute($sql); } ?> 3. setting up a cron so it visits domain.com/outofstock.php every minute Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now