Un-publish a Product Variation When Stock Reaches 0 Using "Rules"
Hey Everyone, thanks for looking at this post. I've been struggling for days to find the right combination of Event's, Conditions, and Actions, to un-publish a product variation when the variation's stock value reaches 0.
For instance, if I have a t shirt style that comes in Small, Medium, and Large, and the Small's sell out. I would like to create a Rule that un-publishes just that Small t shirt of that style. The other's should remain for sale.
I'm sure there's a way to do this using Rules. Can anyone please tell me the correct combination or configuration to achieve this?
Thanks so much,
Jason
Comments
Disable
I think what you are looking for is to disable the product. I think there is a disable/enable component in rules that you should be able to use. Here is the disable component from mine.
{ "rules_disable_product" : {
"LABEL" : "Disable product",
"PLUGIN" : "action set",
"OWNER" : "rules",
"TAGS" : [ "commerce_vbo_views" ],
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "commerce_product" : { "label" : "Commerce Product", "type" : "commerce_product" } },
"ACTION SET" : [
{ "data_set" : { "data" : [ "commerce-product:status" ], "value" : "0" } }
]
}
}
and the enable component
{ "rules_enable_product" : {
"LABEL" : "Enable product",
"PLUGIN" : "action set",
"OWNER" : "rules",
"TAGS" : [ "commerce_vbo_views" ],
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "commerce_product" : { "label" : "Commerce Product", "type" : "commerce_product" } },
"ACTION SET" : [
{ "data_set" : { "data" : [ "commerce-product:status" ], "value" : "1" } }
]
}
}
Then you would need to create a rule that used this component when your stock value = 0
Thanks so much for this info...
Thank you so much for this, however, I'm such a newb, I'm not sure how to apply this. Also, I'm not sure that I could create a rule that works when using the component. Can you give me any more pointers? Thanks so much!!
Jason
Clarification
So are you using Commerce Kickstart? I just need to know where you are starting from to know where to point you.
I'm a newbie
Hi, thanks for your response, I'm a real newbie when it comes to Drupal. Can you clarify this?
"Then you would need to create a rule that used this component when your stock value = 0"
Can you help me create a rule?
Thanks so much,
Jason
Commerce Kickstart ?
What are you using for commerce? Commerce Kickstart? Vanilla Drupal with Commerce?
Commerce Kickstart 2.0
Hi, I'm using Commerce Kickstart 2.0. I'm having issues with products not un-publishing automatically when the stock reaches zero. I think it's not good business to subject your potential customers to products that you don't have anymore. My only solution was to go through each order, as it happens, and if stock reached zero, then just manually un-publish the product. I'd rather have it done automatically, however, using Rules, etc.
Thanks so much, Sher1
Jason