Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Have a fix which I posted here: http://www.ubercart.org/forum/development/15619/stock_decrementing_not_w...
Comment | File | Size | Author |
---|---|---|---|
#15 | 771028-decrementing-by-attribute-sku.patch | 3.89 KB | paul.dambra |
#12 | 771028-decrementing-by-attribute-sku.patch | 3.83 KB | paul.dambra |
#10 | decrement_stock_attributes.patch | 4.17 KB | paul.dambra |
#9 | decrement_stock_attributes.patch | 4.25 KB | paul.dambra |
Comments
Comment #1
TR CreditAttribution: TR commentedCan you tell me whether you have stock tracking for the base SKU enabled? If you don't have tracking on the base SKU, I would consider this to be a bug. But if you *do* have tracking on the base SKU, I think this is more a side-effect of how uc_stock works, since there is now an ambiguity as to which SKU should be decremented, the adjusted one or the base one.
The "decrement twice" issue is almost certainly the same as #644538: Duplicate order notification e-mail, and duplicate stock decrement so please participate in the discussion in that thread.
Comment #2
TR CreditAttribution: TR commentedComment #3
fehin CreditAttribution: fehin commentedI have the same issue. How to you track your base SKU? All the SKUs are marked active, including the base SKU. I'm using the paypal module and the order status shows complete.
Comment #4
TR CreditAttribution: TR commentedComment #5
lance.gliser CreditAttribution: lance.gliser commentedHello Tr,
I'm not sure this one should be closed just yet. I'm still seeing this issue in Drupal 6.22, UC Stock 6.x-2.7.
The issue looks fairly straight forward.
In uc_cart.module:uc_cart_get_item(), the code loads the node, and sets the product->model equal to the main sku for the item:
The stock decrement code in uc_stock:uc_stock_adjust_product_stock(), then attempts to decrement the model's stock.
But, that may not be the model or sku that we actually wish to use. If you've turned on an attribute, and setup a separate stock sku for it's options, your sub-skus are the ones with he inventory.
Other modules need the main sku for things, I assume. So it makes sense to provide a sub-sku or just more accurate sku, in the product->data['sku']. It should be as simple as adding the sku to the product data, then using it in the uc_stock_adjust_product_stock function.
Any chance of getting that small piece added to the next version, and a patch we could all use until then?
Comment #6
longwaveAlso needs fixing in 7.x according #1281768: How do I make attribute adjustment SKU's decrement inventory
Comment #7
TR CreditAttribution: TR commentedWrong status - "needs review" is only used when there's a patch.
Comment #8
lance.gliser CreditAttribution: lance.gliser commentedTR, there won't really be a patch until the issue has some clear direction. Need a decision from the maintainers on how you'd like to handle the variation sku.
If that's what you want, speak up and someone can patch that way.
Comment #9
paul.dambra CreditAttribution: paul.dambra commentedI've fixed this for my use-case and so I thought I'd submit a patch...
I've left the $product object alone so as not to have to worry about side effects...
At the start of uc_stock:uc_stock_adjust_product_stock() this patch tries to load an sku using the
. Where an attribute / adjustment sku can be found that is used otherwise the $product->model is used.
Comment #10
paul.dambra CreditAttribution: paul.dambra commentedOops just realised that was a messy patch.
This is tidier...
P
Comment #12
paul.dambra CreditAttribution: paul.dambra commentedtrying again...
is it better to edit the failed ones with new attachments?
Comment #13
paul.dambra CreditAttribution: paul.dambra commentedchanging status
Comment #15
paul.dambra CreditAttribution: paul.dambra commentedadded check for undefined index....
Comment #16
TR CreditAttribution: TR commentedPlease pay attention to Drupal coding standards: http://drupal.org/coding-standards
Comment #17
paul.dambra CreditAttribution: paul.dambra commentedI'm happy to... I'm new to PHP and Drupal. Could you be more specific?
Comment #18
vdupom CreditAttribution: vdupom commentedThanks for your work.
I've tested patch in #15 and apparently works with an attribute but doesn't when more than one attributes are present in a product