array('rate'=>1000, 'sub'=>500), 'VendorB' => array('rate'=>999, 'sub'=>500), 'VendorC' => array('rate'=>1099, 'sub'=>500), ); $defaultrate = 500; $rate = 0; //go through cart and group by type foreach ($DATA['items'] as $item) { if (isset($config[$item['vendor']])) { if ($item['quantity'] > 1) { $rate += $config[$item['vendor']]['rate'] + $config[$item['vendor']]['sub']*($item['quantity']-1); } else { $rate += $config[$item['vendor']]['rate']; } } else { //default rate $rate += $defaultrate*$item['quantity']; } } //round up nearest cent $rate = ceil($rate); $_RATES[] = array( "service_name" => "Standard Shipping", "service_code" => "STANDARD", "total_price" => $rate, //in cents "currency" => "USD", ); return $_RATES; /* do not edit below this line */ }