Assuming you're using commerce_stock, you'll want to create a rule that does that.
After an order has been saved,
if the order status is cancelled and the original order status was complete,
loop through the line items
decrement stock on the related products by the quantity in the line item.
3. Add action "Increase stock when canceling the order process" the same way as rule "Decrease stock when completing the order process" do it.
4. Profit! :)
But if I need doing this thing when order has been deleted? If I understand correctly, when order is deleted I can't get data from it. What can I do in this case?
Thanks, rfay )
Now I'm going to build a set of rules for stock level updating in other use cases, for example, when store manager change products number in some order and so on.
But I think, why there is no predefined set of rules for this more complex stock management? I saw several discussions on drupal.org related to such problems, so I think this feature can be useful...
Can you tell me how you add this condition for checking if order is cancelled.
How you implement this condition, because at condition there is not any option for check order status.
It'll be very helpful for me, Thanks.
Comments
Assuming you're using
Assuming you're using commerce_stock, you'll want to create a rule that does that.
After an order has been saved,
if the order status is cancelled and the original order status was complete,
loop through the line items
decrement stock on the related products by the quantity in the line item.
Yes, I'm using commerce_stock
Yes, I'm using commerce_stock and I've tried to create this rule before, but it didn't work.
Then I created this rule another way and it works fine, here the checklist:
1. Add event "After updating an existing commerce order"
2. Add condition:
if("[commerce-order:status]" == "canceled" && "[commerce-order-unchanged:status]" != "[commerce-order:status]") {
return TRUE;
}
else {
return FALSE;
}
3. Add action "Increase stock when canceling the order process" the same way as rule "Decrease stock when completing the order process" do it.
4. Profit! :)
But if I need doing this thing when order has been deleted? If I understand correctly, when order is deleted I can't get data from it. What can I do in this case?
Don't delete orders...
Mostly, Commerce is built around the idea that orders won't be deleted after they're through checkout. So don't do that :-)
Thanks, rfay )Now I'm going
Thanks, rfay )
Now I'm going to build a set of rules for stock level updating in other use cases, for example, when store manager change products number in some order and so on.
But I think, why there is no predefined set of rules for this more complex stock management? I saw several discussions on drupal.org related to such problems, so I think this feature can be useful...
Transactional stock feature
z-buffer, this feature does what you need : http://drupal.org/sandbox/liupascal/1360184
Can you tell me how you add
Can you tell me how you add this condition for checking if order is cancelled.
How you implement this condition, because at condition there is not any option for check order status.
It'll be very helpful for me, Thanks.