Roggie Posted November 24, 2010 Share Posted November 24, 2010 For exampleSuppose I have a theatre with 40 seatsEach seat can be sold for either £10, £15 or £20, the price selected depending on whether they are for child, student or adult.If I enter these as a price group and add them as combinations then the basic 40 seats is overwritten and I have to input the quantities in the combinations. This makes it impossible to manage my stock of 40 seats because I have no idea how many tickets I will sell at each price point.Anyone know a workaround? Failing that, is there another way I can add different price levels for the same product and successfully manage my stock levels? Link to comment Share on other sites More sharing options...
Roggie Posted January 14, 2011 Author Share Posted January 14, 2011 Can anyone help on this please?I've tried to find a solution but failed. I'm not a programmer but I imagine that there is a flag set that forces combination quantities to override the base product quantity. I just need a check box in the admin that reverses this and uses the quantity in the product information page as the default. I evaluated Zen Cart before switching to Prestashop and the only thing I miss is that Zen Cart allows me to do this.Any modules out there that do it or programmers prepared to have a go? Link to comment Share on other sites More sharing options...
tomerg3 Posted January 15, 2011 Share Posted January 15, 2011 You can see a solution here http://www.prestashop.com/forums/viewthread/43828/ it reduces the quantity from all the attributes (of the product) whenever you purchase it with any attribute. Link to comment Share on other sites More sharing options...
Roggie Posted January 16, 2011 Author Share Posted January 16, 2011 Thanks for the link. I've read through the thread and it seems to provide a solution. I'll have a go and report back!Thanks again. Link to comment Share on other sites More sharing options...
Roggie Posted January 16, 2011 Author Share Posted January 16, 2011 I understand that your product.php code:Decreases the quantity of every combination when any one of the combinations is selected.Includes logic based on the product location field on the products page. If this is set to 1 than the special stock management is implemented else it uses the the Prestashop default.I was going to do a cut and paste but the code for the function is different in my version of Prestashop.Your version: public static function updateQuantity($product) { if (!is_array($product)) die (Tools::displayError()); if (Pack::isPack(intval($product['id_product']))) { $products_pack = Pack::getItems(intval($product['id_product']), intval(Configuration::get('PS_LANG_DEFAULT'))); foreach($products_pack AS $product_pack) { $tab_product_pack['id_product'] = intval($product_pack->id); $tab_product_pack['id_product_attribute'] = self::getDefaultAttribute($tab_product_pack['id_product'], 1); $tab_product_pack['cart_quantity'] = intval($product_pack->pack_quantity * $product['cart_quantity']); self::updateQuantity($tab_product_pack); } } $result = Db::getInstance()->getRow(' SELECT `quantity` FROM `'._DB_PREFIX_.($product['id_product_attribute'] ? 'product_attribute' : 'product').'` WHERE `id_product` = '.intval($product['id_product']).($product['id_product_attribute'] ? ' AND `id_product_attribute` = '.intval($product['id_product_attribute']) : '')); if (!Configuration::get('PS_STOCK_MANAGEMENT')) return true; if (self::isAvailableWhenOutOfStock($product['out_of_stock']) AND intval($result['quantity']) == 0) return -1; if ($result['quantity'] < $product['cart_quantity']) { Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.($product['id_product_attribute'] ? 'product_attribute' : 'product').'` SET `quantity` = 0 WHERE `id_product` = '.intval($product['id_product']).($product['location'] == 1 && $product['id_product_attribute'] ? ' AND `id_product_attribute` = '.intval($product['id_product_attribute']) : '')); return false; } Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'product'.($product['id_product_attribute'] ? '_attribute' : '').'` SET `quantity` = `quantity`-'.intval($product['cart_quantity']).' WHERE `id_product` = '.intval($product['id_product']). ($product['location'] == 1 && $product['id_product_attribute'] ? ' AND `id_product_attribute` = '.intval($product['id_product_attribute']) : '')); return true; } The version I'm using (1.3.2.3) has extra code tagged on to the end of the function (the if statement with a db update) and I don't understand the code well enough to go in and start editing. I would really appreciate your help.1.3.2.3 code: public static function updateQuantity($product) { if (!is_array($product)) die (Tools::displayError()); if (Pack::isPack(intval($product['id_product']))) { $products_pack = Pack::getItems(intval($product['id_product']), intval(Configuration::get('PS_LANG_DEFAULT'))); foreach($products_pack AS $product_pack) { $tab_product_pack['id_product'] = intval($product_pack->id); $tab_product_pack['id_product_attribute'] = self::getDefaultAttribute($tab_product_pack['id_product'], 1); $tab_product_pack['cart_quantity'] = intval($product_pack->pack_quantity * $product['cart_quantity']); self::updateQuantity($tab_product_pack); } } $result = Db::getInstance()->getRow(' SELECT `quantity` FROM `'._DB_PREFIX_.($product['id_product_attribute'] ? 'product_attribute' : 'product').'` WHERE `id_product` = '.intval($product['id_product']).($product['id_product_attribute'] ? ' AND `id_product_attribute` = '.intval($product['id_product_attribute']) : '')); if (!Configuration::get('PS_STOCK_MANAGEMENT')) return true; if (self::isAvailableWhenOutOfStock($product['out_of_stock']) AND intval($result['quantity']) == 0) return -1; if ($result['quantity'] < $product['cart_quantity']) { Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.($product['id_product_attribute'] ? 'product_attribute' : 'product').'` SET `quantity` = 0 WHERE `id_product` = '.intval($product['id_product']).($product['id_product_attribute'] ? ' AND `id_product_attribute` = '.intval($product['id_product_attribute']) : '')); return false; } Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'product'.($product['id_product_attribute'] ? '_attribute' : '').'` SET `quantity` = `quantity`-'.intval($product['cart_quantity']).' WHERE `id_product` = '.intval($product['id_product']). ($product['id_product_attribute'] ? ' AND `id_product_attribute` = '.intval($product['id_product_attribute']) : '')); if ($product['id_product_attribute']) Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'product` SET `quantity` = ( SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product` = '.intval($product['id_product']).' ) WHERE `id_product` = '.intval($product['id_product'])); return true; } 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