JohnsonZA Posted March 4, 2010 Share Posted March 4, 2010 I have a store where the customer can choose 2 attributes to customize an order, but the product is unique and once it has been bought it must be listed as out of stock.Attributes allow for setting stock levels of each combination, but I want the whole product with all combinations to be listed as out of stock once any of the combinations have been ordered.Is it possible to do this out the box or will it require some hacking and if so where do I start? Link to comment Share on other sites More sharing options...
tomerg3 Posted March 4, 2010 Share Posted March 4, 2010 It will require some hacking.Clean way: Create a new module, and hook it to NewOrder, that will let you run you code whenever a new order is placed, you will need to check the product id, and set the quantity to 0 in the database.Dirty way: Do the same without a module and hook, just add the code to set the quantity to 0 in /classes/PaymentModule.php Link to comment Share on other sites More sharing options...
JohnsonZA Posted March 5, 2010 Author Share Posted March 5, 2010 I decided to go a slightly different route.I hooked into updateQuantity and set active = 0 for the product_id. This seemed to work well. Any ideas on this approach? Link to comment Share on other sites More sharing options...
vezy Posted March 25, 2010 Share Posted March 25, 2010 Hi JohnsonZA - I have been searching the forum in both English and French and your topic is the closest to an answer as I have gotten.I too create single products (jewellery) and offer colour variations on those unique products. I am having the exact same problem as you described above and from what I read, you have found a solution. Could you be a little more explicit at what exactly you did to get this to work? I understand that I need to change the hook in the DB - ok fine - but what do you hook there? As far as I know, variations are not a module so how do you hook it to updatQuantity? I am no good at coding so if you could supply the code and the file sources I would be very appreciative and I am sure it might help some others too.Very kind regards and hope you can help me,V. Link to comment Share on other sites More sharing options...
JohnsonZA Posted March 25, 2010 Author Share Posted March 25, 2010 Hi vezyI have created a "custom products" module. I have attached the file. Just install it and all products in your store are disabled when they are purchased. This means they will not appear in your store any more, but are still in the catalogue on the back end.Hope that helps. customproducts.zip Link to comment Share on other sites More sharing options...
vezy Posted March 25, 2010 Share Posted March 25, 2010 Ok - I found another thread with you answer here:http://www.prestashop.com/forums/viewthread/43828/configuring___using_prestashop/combination_quantity_helpYou created a module? could you possibly share it? You would be helping a desperate PS user! Thanks in advance for your help/advice.V. Link to comment Share on other sites More sharing options...
JohnsonZA Posted March 25, 2010 Author Share Posted March 25, 2010 You created a module? could you possibly share it? You would be helping a desperate PS user! It's attached to my previous post above. Link to comment Share on other sites More sharing options...
vezy Posted March 25, 2010 Share Posted March 25, 2010 Hi Johnson ZA!Our posts crossed!Thanks a lot for your module - however, I only need this to apply to a certain category of products and not all of the shop? Is there a way to configure it?Thanks a million, getting closer to the answer! Link to comment Share on other sites More sharing options...
JohnsonZA Posted March 25, 2010 Author Share Posted March 25, 2010 As it stands, to configure it you would have to edit the source manually.If the custom products are in a certain category, you could change the hookUpdateQuantity() function as follows: public function hookUpdateQuantity( $params ) { $product = $params['product']; if (intval($product['id_category_default']) != 10) { return true; } Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'product` SET `active` = 0 WHERE `id_product` = '.intval($product['id_product'])); return true; } where 10 is the category ID of the custom products. Something like that anyway.Hope that puts you on the right track. Link to comment Share on other sites More sharing options...
vezy Posted March 25, 2010 Share Posted March 25, 2010 Thanks so much for your help - I figured that I could maybe enter the concerned categories in here, but no being very code wise, I had no idea where to start - I will try this out and see how it goes - I'll post my findings on here for those interested.Thanks a million once again -V. 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