1
Answers
Vote up!
1
Vote down!

Shipping Rate

Sorry i'm newbie from Bogor,
I want to ask how to calculate between Shipping rate based on address and quantity of order. Because my shipping rate is pay per ton and it will be different for any place to shipping, for example... if the quantity of my order is Rp 2.000.000 for 1 ton to Jakarta so if the order is for 3 ton to Jakarta, it must be become Rp. 6.000.000...

Please help me...
tnks

Asked by: Ramdhan Pohan
on April 28, 2016

1 Answer

Vote up!
0
Vote down!

To be honest I have tried to find this answer on several communities but unfortunately this question did not get enough attention.

I did similar job a very lengthy way. Maybe following hints can help you.

I have divided all the countries in the zones. And then I have created lots of Flat Rate services like following

Zone 1 - 0.5KG (Machine name: zone_1_0_5kg)
edit configure component delete
Zone 1 - (10 to 19) KG (Machine name: zone_1_10_to_19_kg)
edit configure component delete
Zone 1 - 1.0KG (Machine name: zone_1_1_0kg)
edit configure component delete
Zone 1 - 1.5KG (Machine name: zone_1_1_5kg)
edit configure component delete
Zone 1 - 20+ KG (Machine name: zone_1_20_kg)
edit configure component delete
Zone 1 - 2.0KG (Machine name: zone_1_2_0kg)
edit configure component delete
Zone 1 - 2.5KG (Machine name: zone_1_2_5kg)
edit configure component delete
Zone 1 - 3.0KG (Machine name: zone_1_3_0kg)
edit configure component delete
Zone 1 - 3.5KG (Machine name: zone_1_3_5kg)
edit configure component delete
Zone 1 - 4.0KG (Machine name: zone_1_4_0kg)
edit configure component delete
Zone 1 - 4.5KG (Machine name: zone_1_4_5kg)
edit configure component delete
Zone 1 - 5.0 KG (Machine name: zone_1_5_0_kg)
edit configure component delete
Zone 1 - (6 to 9) KG (Machine name: zone_1_6_to_9_kg)
edit configure component delete
Zone 2 - 0.5KG (Machine name: zone_2_0_5kg)
edit configure component delete
Zone 2 - (10 to 19) KG (Machine name: zone_2_10_to_19_kg)
edit configure component delete
Zone 2 - 1.0KG (Machine name: zone_2_1_0kg)
edit configure component delete
Zone 2 - 1.5KG (Machine name: zone_2_1_5kg)
edit configure component delete
Zone 2 - 20+ KG (Machine name: zone_2_20_kg)
edit configure component delete
Zone 2 - 2.0KG (Machine name: zone_2_2_0kg)
edit configure component delete
Zone 2 - 2.5KG (Machine name: zone_2_2_5kg)
edit configure component delete
Zone 2 - 3.0KG (Machine name: zone_2_3_0kg)

Configured Each Flat Rate services like following

Order address component comparison
Parameter: Order: [commerce_order], Address: Address, Address component: Country, Operator: is one of, Value: AL ...
editdelete

AND
editdeleteAdd conditionAdd orAdd and

Order total weight comparison
Parameter: Order: [commerce_order], Operator: >=, Value: 2.6
editdelete

AND
editdeleteAdd conditionAdd orAdd and

Order total weight comparison
Parameter: Order: [commerce_order], Operator: <=, Value: 3.0

---

Created several rules like following

Calculate Shipping Amount by Weight 6 to 9 Zone 3
Machine name: rules_calculate_shipping_amount_by_weight_6_to_9_zone_3
Parameter: Line Item (line_item)
Provides variables: Shipping Cost For Line Item (shipping_cost_for_line_item)

export of this rule is pasted below

{ "rules_calculate_shipping_amount_by_weight_6_to_9_zone_3" : {
"LABEL" : "Calculate Shipping Amount by Weight 6 to 9 Zone 3",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "commerce_order", "rules", "commerce_physical" ],
"USES VARIABLES" : {
"line_item" : { "label" : "Line Item", "type" : "commerce_line_item" },
"shipping_cost_for_line_item" : {
"label" : "Shipping Cost For Line Item",
"type" : "decimal",
"parameter" : false
}
},
"IF" : [
{ "commerce_order_compare_address" : {
"commerce_order" : [ "line-item:order" ],
"address_field" : "commerce_customer_shipping|commerce_customer_address",
"address_component" : "country",
"operator" : "is one of",
"value" : "CA\r\nUS"
}
},
{ "entity_has_field" : { "entity" : [ "line-item" ], "field" : "commerce_product" } },
{ "entity_has_field" : { "entity" : [ "line-item:commerce-product" ], "field" : "field_weight" } },
{ "commerce_physical_rules_order_weight_comparison" : {
"commerce_order" : [ "line-item:order" ],
"operator" : "\u003E=",
"value" : "6",
"unit" : "kg"
}
},
{ "AND" : [
{ "commerce_physical_rules_order_weight_comparison" : {
"commerce_order" : [ "line-item:order" ],
"operator" : "\u003C=",
"value" : "9.9",
"unit" : "kg"
}
}
]
}
],
"DO" : [
{ "data_calc" : {
"USING" : {
"input_1" : [ "line-item:commerce-product:field-weight:weight" ],
"op" : "*",
"input_2" : [ "line-item:quantity" ]
},
"PROVIDE" : { "result" : { "weight_for_line_item" : "Weight for line item" } }
}
},
{ "data_calc" : {
"USING" : { "input_1" : [ "weight-for-line-item" ], "op" : "*", "input_2" : "5300" },
"PROVIDE" : { "result" : { "line_item_calculated_shipping_cost" : "Line item calculated shipping cost" } }
}
},
{ "data_set" : {
"data" : [ "shipping-cost-for-line-item" ],
"value" : [ "line-item-calculated-shipping-cost" ]
}
}
],
"PROVIDES VARIABLES" : [ "shipping_cost_for_line_item" ]
}
}

Answer by: digitalexperts
Posted: May 29, 2016
骚虎视频_骚虎app