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.
hi all,
I am facing a problem and need support of you.
I am using ubercart in one of my site. And I am performing a task to create shipping weightquote for the weight 1 lbs - 150 lbs.
I have created these weightquote simply by a query inserting quote in uc_weightquote_methods table and it is working fine. But after I am trying to add condition of weight and country to each of the weightquote. But the is not allowing me to import multiple components. Here is what I am trying to import: -
{ "get_quote_from_shipping_1" : {
"LABEL" : "1lbs conditions",
"PLUGIN" : "and",
"OWNER" : "rules",
"REQUIRES" : [ "php", "rules", "uc_order" ],
"USES VARIABLES" : { "order" : { "type" : "uc_order", "label" : "Order" } },
"AND" : [
{ "php_eval" : { "code" : "$weight = calculate_shipping_weight($order);\r\nreturn ($weight==1);" } },
{ "uc_order_condition_delivery_country" : {
"order" : [ "order" ],
"countries" : { "value" : {
"48" : "48",
"196" : "196",
"818" : "818",
"400" : "400",
"414" : "414",
"422" : "422",
"512" : "512",
"634" : "634",
"682" : "682",
"792" : "792",
"784" : "784"
}
}
}
}
]
},
"get_quote_from_shipping_2" : {
"LABEL" : "Aramex 2lbs conditions",
"PLUGIN" : "and",
"OWNER" : "rules",
"REQUIRES" : [ "php", "rules", "uc_order" ],
"USES VARIABLES" : { "order" : { "type" : "uc_order", "label" : "Order" } },
"AND" : [
{ "php_eval" : { "code" : "$weight = calculate_shipping_weight($order);\r\nreturn ($weight==2);" } },
{ "uc_order_condition_delivery_country" : {
"order" : [ "order" ],
"countries" : { "value" : {
"48" : "48",
"196" : "196",
"818" : "818",
"400" : "400",
"414" : "414",
"422" : "422",
"512" : "512",
"634" : "634",
"682" : "682",
"792" : "792",
"784" : "784"
}
}
}
}
]
}
...................... So On.....................................
}
Is there any way to import multiple components together?
Comments
Comment #1
sunnykasera3107 CreditAttribution: sunnykasera3107 commentedComment #2
TR CreditAttribution: TR commentedRules in D7 doesn't have a way to import multiple components at the same time. If you do it in the UI, you need to do it one at a time. Alternatively, you can set up a system using the Features module which will allow you to import all your Rules at once - see https://drupalize.me/videos/importing-and-exporting-rules?p=1157
The best way to do this WOULD be to add drush support for importing Rules - that way the import of multiple Rules could be easily scripted. That was never proposed that I know of, and no-one contributed a patch to do this. Since it is very late in the D7 development cycle, this feature is not going to be considered for inclusion into Rules at this time.
In Drupal 8, Reaction Rules and Rules Components are stored in configuration, so there are many ways to do this and many helper modules available.
Comment #3
TR CreditAttribution: TR commented