Jump to content

Using attributes to customize a single product


Recommended Posts

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

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

  • 3 weeks later...

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...