Hello,
I need to modify the products model before decrementing its stock. This is because I have a product with multiple sku's referencing to the same stock. So I have an event "Punch and Judy show" with different price categorys as "child" and "parent". The skus are like "dd.mm.yyyy M:H parent" to show at the bill, the cart view form and on the report page.
For stock managment for every date (multiple dates are possible per event/node) one entry is made to "uc_product_stock"-table with sku "dd.mm.yyyy M:H [nid]".

If someone buys a ticket of this event at this date at any price category the stock has to be decremented.

Hope, this was a good explanation ;)

I think the solution is this:
1. trigger at "uc_checkout_complete"
2. call action "my_module_myaction" and pass $order (same way how uc_stock module goes)
3. pass products to own mymodule_decrement_product_stock() function, change the model temporary in the functions local copy of $product and $order and decrement the stock
4. proceed the standard wordflow (i.e. uc_stock_decrement_product_stock() gets called but shouldn't do anything since the sku it gets should not exist in uc_product_stock - table.

Sounds well. But here is my problem:
The product->model is not changed temporary. Need realy some help at this point. I posted it in the forum at http://drupal.org/node/674390
But I think here are some more people working at this task. Hope someone can help me!

Thanks and greetz,
haggins

Comments

haggins’s picture

Workaround is to set the model - as it is in the stock table - at my action function and let the orginial uc_stock_decrement_product_stock() function decrement the stock. Disadvantage is, that the wrong/modified model is used in uc_order_comment_save().

I would be much luckier if I would understand what happens at my first "solution" and why it doesn't work :/

tr’s picture

Issue tags: +uc_stock

Tagging

longwave’s picture

Status: Active » Closed (won't fix)

Old issue, and I don't really see a way of fixing this easily, it's kind of abusing the SKU/stock system a bit. There are lots of other open stock bugs/feature requests which would hopefully accommodate this when they are fixed.