Closed (fixed)
Project:
Commerce Shipping
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Oct 2012 at 12:56 UTC
Updated:
29 Nov 2012 at 02:10 UTC
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
Comment #1
joachim commentedOnly 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 :/
Comment #2
googletorp commentedI'll give this some thought.
Ryan do you have any feelings on this matter?
Comment #3
rszrama commentedEasy 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