public function splitShipping() { global $user, $order; expHistory::set('viewable', $this->params); // get all the necessary addresses..shipping, billing, etc $address = new address(null, false, false); $addresses_dd = $address->dropdownByUser($user->id); if (count($addresses_dd) < 2) { expHistory::set('viewable', $this->params); flash('error', gt('You must have more than 1 address to split your shipment. Please add another now.')); redirect_to(array('controller' => 'address', 'action' => 'edit')); } // setup the list of orderitems $orderitems = array(); foreach ($order->orderitem as $item) { if ($item->product->requiresShipping == true) { for ($i = 0; $i < $item->quantity; $i++) { $orderitems[] = $item; } } } if (count($orderitems) < 2) { flashAndFlow('error', 'You must have a minimum of 2 items in your shopping cart in order to split your shipment.'); } expHistory::set('viewable', $this->params); assign_to_template(array('addresses_dd' => $addresses_dd, 'orderitems' => $orderitems, 'order' => $order)); }