Hi,
Is it possible to apply flat rate shipping only when products of a certain variant (based on taxonomy term) are added to the shopping cart?
My scenario is that I have a Publication product type that has two terms available; eBook and Print. Printed products are shippable and eBooks obviously aren't.
I'm using the default Rule that comes with commerce_shipping when Flat Rate is enabled.
I've created a Rules component that defines which products are shippable (in this case, anything that isn't an eBook)
{ "rules_product_is_shippable" : {
"LABEL" : "Product is shippable",
"PLUGIN" : "and",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "product" : { "label" : "Product", "type" : "commerce_product" } },
"AND" : [
{ "data_is" : { "data" : [ "product:type" ], "value" : "publication" } },
{ "NOT data_is" : {
"data" : [ "product:field-taxonomy-publication-type:tid" ],
"value" : "391"
}
}
]
}
}
My problem then comes when I try to add this into the default rule (slightly modified title and price);
{ "commerce_shipping_plugin_flat_rate" : {
"LABEL" : "Flat rate - \u00a31.99",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "commerce_shipping" ],
"ON" : [ "commerce_shipping_methods" ],
"DO" : [
{ "commerce_shipping_enable_plugin-flat_rate" : {
"commerce_order" : [ "site:current-cart-order" ],
"shipping_method" : { "value" : {
"method_id" : "plugin-flat_rate",
"shipping_label" : "1st Class Royal Mail - \u00a31.99",
"settings" : {
"shipping_price" : "1.99",
"rate_type" : "order",
"label" : "Flat rate shipping - 1st Class"
}
}
}
}
}
]
}
}
If I then try to add my component (And: Product is shippable) as a condition I simply don't know which data selector to use as nothing seems appropriate.
Is it actually possible for me to do it this way or does a new shipping method module need to be written...or better still, is there anything on the horizon for some sort of shippable product module to tie in?
Thanks in advance for any feedback.
If it's any help I'm using http://drupalcode.org/project/commerce_shipping.git/commit/9b34b8c
Comments
Comment #1
jakonore commentedsubscribe
Comment #2
googletorp commentedYou can probably do this, but I'm not skilled enough with Rules to be able to tell you know.
What I did to solve a similar problem was to create an action that determines if the order is shippable by post or needs to be freighted:
The bulk of the code looks like this:
If you this doesn't work for you or you have problems with rules, I would suggest you ask for support in the Rules queue as they should be able to help you better.
Comment #3
axel pressbutton commentedGreat, many thanks for your response googletorp - I'll give this a try over the next few days when I'm back on the shop element of the site.