I'd like my shipping method to be able to add details to the line item, based on the shipping method selected (and based on the shipping method's calculations). (This is with http://drupal.org/project/commerce_shipping_weight_tariff, where I'd like to put the shipping tariff SKU into the shipping line item in some way).

But commerce_shipping_service_rate_calculate() creates a new line item entity with only ($service, $price, $order_id) parameters. I could use hook_commerce_shipping_calculate_rate(), but that feels a little bit far removed from my hook_commerce_shipping_service_info() rate callback.

Comments

joachim’s picture

Only thing I can see so far is adding data to the price returned by the rate callback, and then picking that out again in hook_commerce_shipping_calculate_rate(). Which feels like a hack :/

googletorp’s picture

I'll give this some thought.

Ryan do you have any feelings on this matter?

rszrama’s picture

Status: Active » Fixed

Easy enough to accommodate with a simple alter hook at the bottom of commerce_shipping_line_item_new(). This gets invoked after commerce_shipping_line_item_populate(), so the original service name and unit price can be found in the $line_item object passed to the hook.

Commit: http://drupalcode.org/project/commerce_shipping.git/commitdiff/f0af1a1

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.