I have added multiple SKUs/attributes to a product and the stock isn't reducing on all of the SKUs after user completes checkout.

Was looking at http://www.ubercart.org/docs/user/5181/out_stock_solutions and not sure if there was just a simple workflow-ng method I should be using to make sure stock reduces. Seems to work fine in products that have a single SKU and no attributes, using I assume the "Decrement stock upon order submission" workflow.

CommentFileSizeAuthor
#1 uc_multi_stock.module.patch1.56 KBhanoii

Comments

hanoii’s picture

Priority: Normal » Critical
StatusFileSize
new1.56 KB

Got to the same issue and after extensive debugging I think I found the problem (and the solution).

There's a scenario which is not really considered in the uc_multi_get_sku() function, which is when some adjustments (if not all as per default) share the same SKU as the product. In that case no adjustment information is stored on the db, and then, the combination of attributes will not be found in the db. Further more, this function is supposed to return an SKU all the time, it's never checked against the return value (which is false in the event I just described) and thus leading to improperly set SKUs.

One of the places where this happen is on the uc_multi_stock_cart_item() hook, in which the function uc_multi_get_sku() is called, and if within the scenario above, it will return false and it will set the $item['model'] to false leading to no model information on the product's order and then no decrement of the stock level of the product (or adjustment).

Attached is my proposed and tested solution to the function in which an SKU is returned ALL the time, either the one found on the adjustments table or product's SKU. I also fixed the coding standards of that function. Hope this helps.

a.=

hanoii’s picture

Status: Active » Needs review
Vetkhy’s picture

I also want to note, that in 6.x-dev version the function uc_multi_get_sku also return FALSE if it cannot find adjustment so we can add to cart item with unknown adjustment.

hanoii’s picture

Status: Needs review » Fixed

Committed #1 to both branches.

@Vetkhy. Can you check the -dev version (check today's date) and see if this also fixes your issue on D6?

Thanks,
a.=

Vetkhy’s picture

@Vetkhy. Can you check the -dev version (check today's date) and see if this also fixes your issue on D6?

Yes. One little thing I want to say, that we should use active zero-level stock for product's SKU for this case.

hanoii’s picture

Also, you may want to look at http://drupal.org/project/uc_out_of_stock. I have just released a new D6 version that contains some ideas and work alike this module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.