Reputation: 1036
I am not sure whether this a bug or not. I have one shipping method that includes two shipping services. One of the shipping services is available only if the ordered items include Arabic language books; in such a case the user is represented with two shipping options instead of one.
Apparently for no obvious reason, one the shipping services becomes broken and the rules component suddenly disappears.
I didn't create the rule myself, I found out that the rule "Collect rates: IPS" is created. Also, the rules components are created on the fly.
The shipping services I am referring to is called "kkkkkkk". Please find below some screenshots and my code for more info:
function myips_commerce_shipping_method_info() {
$shipping_methods = array();
$shipping_methods['ippppps'] = array(
'title' => t('IPS'),
'description' => t('IPS commerce shipping'),
);
commerce_shipping_services_reset();
//entity_defaults_rebuild();
//rules_clear_cache(TRUE);
return $shipping_methods;
}
function myips_commerce_shipping_service_info() {
$contains_arabic=arabic_books_contained();
$shipping_services = array();
$shipping_services['ppppp'] = array(
'title' => 'Express Mail - DHL',
//'description' => 'Express Mail - DHL',
'display_title' => t('Express Mail - DHL'),
'shipping_method' => 'ippppps',
'price_component' => 'shipping',
'callbacks' => array(
'rate' => 'commerce_ipppppls_service_rate_order',
),
);
if($contains_arabic=='true') {
$shipping_services['kkkkkkk'] = array( //arbitrary name w/ 'service' in there
'title' => 'kkkkkkk', //title for the interface
// 'description' => 'Lebanon Shipment option for books shipped from lebanon',
'display_title' => t('Registered Mail'),
'shipping_method' => 'ippppps',
'price_component' => 'shipping',
'callbacks' => array(
'rate' => 'commerce_ipppppsssss_service_rate_order',
),
);
}
return $shipping_services;
}
my shipping rule:
{ "commerce_shipping_method_ippppps" : {
"LABEL" : "Collect rates: IPS",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "commerce_shipping" ],
"ON" : { "commerce_shipping_collect_rates" : [] },
"DO" : [
{ "commerce_shipping_method_collect_rates" : {
"shipping_method_name" : "ippppps",
"commerce_order" : [ "commerce-order" ]
}
}
]
}
}
my shipping rule component for one of the shipping services, the second appears abruptly:
{ "commerce_shipping_service_ppppp" : {
"LABEL" : "Rate Express Mail - DHL",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "commerce_shipping" ],
"USES VARIABLES" : { "commerce_order" : { "type" : "commerce_order", "label" : "Order" } },
"DO" : [
{ "commerce_shipping_service_rate_order" : {
"shipping_service_name" : "ppppp",
"commerce_order" : [ "commerce-order" ]
}
}
]
}
}
Am I missing something, should I add something in my code, should any custom rules be created?
Thank you!
Upvotes: 3
Views: 112