function commerce_usps_get_shipment_value in Commerce USPS 7.2
Produce the shipping value for each line item.
1 call to commerce_usps_get_shipment_value()
- commerce_usps_intl_rate_v2_request in includes/
commerce_usps.xml.inc - Builds an international USPS rate request.
File
- ./
commerce_usps.module, line 285 - Defines the USPS shipping method and services for Drupal Commerce.
Code
function commerce_usps_get_shipment_value($order) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$shipment_value = 0;
// Loop over each line item on the order.
foreach ($order_wrapper->commerce_line_items as $line_item_wrapper) {
if (commerce_physical_line_item_shippable($line_item_wrapper
->value())) {
$line_item_total = $line_item_wrapper->commerce_total
->value();
// Increment the insurance value from the line items value.
$shipment_value += $line_item_total['amount'];
}
}
return $shipment_value;
}