We're using Commerce Shipping and Commerce UPS to calculate shipping rates. We want to round the calculated rate displayed during checkout up to the nearest dollar.
Just to be clear we want to update the value of each Radio option on the Shipping Options page of checkout; NOT the Commerce Line Items.
I thought it might be possible via Rules but I cannot figure out a starting place. All the Commerce Shipping Rules seem to be about altering the line item; not the calculated value.
I tried the following which does not work. Do the callback functions override what I was trying to do? If so, is there an easy way to STOP the callback from recalculating the shipping after the page loads?
Or is this some obvious mistake?
TIA,
function MYMODULE_form_commerce_checkout_form_shipping_alter(&$form, &$form_state, $form_id) {
foreach($form['commerce_shipping']['shipping_rates']['#value'] as $values) {
dpm($values);
$newval = 100*(commerce_round(COMMERCE_ROUND_HALF_UP, $values->commerce_unit_price['und']['0']['amount']/100) );
$values->commerce_unit_price['und']['0']['amount'] = $newval;
$values->commerce_unit_price['und']['0']['data']['components'][0]['price']['amount'] = $newval;
}
}
$values
to&$values
in theforeach
...as &$values)