/** * Any boxes that aren't filled up go here * Deprecated * @param unknown_type $multiplierItems */ private function finaliseMultiplierBoxes(&$finishedBoxes, $multiplierItems) { if (Mage::helper('shipusa')->isDebug()) { Mage::helper('wsalogger/log')->postDebug('usashipping', 'multiplier boxes', $multiplierItems); } $innerMultiplierItems = array(); // let's grab the saved item details foreach ($multiplierItems as $itemBx) { if (empty($itemBx)) { continue; } $alternateFound = false; // first see if we will add this one in. if (array_key_exists('save_item_details', $itemBx)) { $alternateFound = true; foreach ($itemBx['save_item_details'] as $savedDetails) { $altBoxedId = $savedDetails['alt_box_id']; if ($altBoxedId == '' || $altBoxedId == 'X') { $alternateFound = false; break; } } } if ($alternateFound) { foreach ($itemBx['save_item_details'] as $savedDetails) { // let's push together on alternative boxes $savedDetails['params']['ship_box_id'] = $savedDetails['alt_box_id']; $savedDetails['params']['alt_box_id'] = 'X'; // so doesn't loop Webshopapps_Shipusa_Model_Calculation_Boxsettings::populateBoxSettings($savedDetails['params'], false); $testPackagedBoxes = array(); $savedMultiplierItems = $innerMultiplierItems; $this->processMultiplierItems($innerMultiplierItems, $testPackagedBoxes, $savedDetails['params']); if (count($testPackagedBoxes) > 0 && !array_key_exists($altBoxedId, $savedMultiplierItems)) { $alternateFound = false; if (array_key_exists($altBoxedId, $innerMultiplierItems)) { $innerMultiplierItems[$altBoxedId] = array(); } } else { foreach ($testPackagedBoxes as $finishedBox) { $finishedBoxes[] = $finishedBox; } } } } if (!$alternateFound) { $finishedBoxes[] = array('height' => $itemBx['height'], 'width' => $itemBx['width'], 'length' => $itemBx['length'], 'weight' => Mage::helper('shipusa')->getWeightCeil($itemBx['weight'] + $itemBx['packing_weight']), 'price' => Mage::helper('shipusa')->toTwoDecimals($itemBx['price']), 'qty' => $itemBx['qty'], 'handling_fee' => $itemBx['handling_fee']); } } return $innerMultiplierItems; }
protected function getProductParams($item, $qty, $weight, $price) { $product = null; if (Mage::helper('shipusa')->isDebug()) { Mage::helper('wsalogger/log')->postDebug('shipusa', 'Settings', 'Use Parent:' . $this->_useParent); } if ($item->getParentItem() != null && $this->_useBundleParent && $item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { // must be a bundle/configurable $product = $item->getParentItem()->getProduct(); } else { if ($item->getParentItem() != null && $this->_useConfigurableParent && $item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) { $product = $item->getParentItem()->getProduct(); } else { if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && !$this->_useConfigurableParent) { if ($item->getHasChildren()) { foreach ($item->getChildren() as $child) { $product = $child->getProduct(); break; } } } else { $product = $item->getProduct(); } } } $params = array(); // This will divide the qty by the shipCaseQty to get a qty to be used for shipping // e.g. So for example if I have a casepack that holds 12 and I have 36 of that item in the cart then the shipping case qty is 3. $shipCaseQty = $product->getData('ship_case_quantity'); if (is_numeric($shipCaseQty) && $shipCaseQty > 0) { $params['case_qty'] = $shipCaseQty; $qty = $qty / $shipCaseQty; } $params['id'] = $product->getId(); $params['sku'] = $product->getData('sku'); //DIMSHIP-103 $params['multiple_boxes'] = $this->getShipBoxes($params['sku']); $params['single_boxes'] = $this->getSingleBoxes($params['sku']); $params['flat_boxes'] = $this->getFlatBoxes($params['sku']); $params['weight'] = $weight; $params['orig_weight'] = $weight; $params['qty'] = $qty; $params['orig_qty'] = $qty; $params['price'] = $price; $params['length'] = Mage::helper('shipusa')->toTwoDecimals($product->getData('ship_length')); $params['width'] = Mage::helper('shipusa')->toTwoDecimals($product->getData('ship_width')); $params['height'] = Mage::helper('shipusa')->toTwoDecimals($product->getData('ship_height')); $params['shared_max_qty'] = $product->getData('ship_shared_max_qty'); // deprecated $params['alt_box_id'] = $product->getData('ship_alternate_box'); // deprecated $params['ship_algorithm'] = $product->getData('ship_algorithm'); $params['ship_separate'] = $product->getData('ship_separately'); $params['num_boxes'] = $product->getData('ship_num_boxes'); $params['split_product'] = $product->getData('split_product') == 1 ? true : false; if (Mage::helper('shipusa')->isHandlingProdInstalled()) { $params['shipping_addon'] = $product->getData('handling_addon'); $params['shipping_percent'] = $product->getData('handling_is_percent'); $params['shipping_price'] = $product->getData('handling_price'); } else { $params['shipping_addon'] = 0; $params['shipping_percent'] = 0; $params['shipping_price'] = 0; } $params['ship_box_id'] = $product->getData('ship_box'); if ($params['ship_box_id'] == '' && (empty($params['length']) || $params['length'] <= 0 || empty($params['width']) || $params['width'] <= 0 || empty($params['height']) || $params['height'] <= 0)) { if (empty($params['single_boxes']) && empty($params['flat_boxes']) && Mage::getStoreConfig('shipping/shipusa/default_box_size') != '') { // push in single box logic $this->_getDefaultBox($params); } } if (empty($params['length']) || empty($params['width']) || empty($params['height'])) { Webshopapps_Shipusa_Model_Calculation_Boxsettings::populateBoxSettings($params, true); } else { Webshopapps_Shipusa_Model_Calculation_Boxsettings::populateBoxSettings($params, false); } if ($item->isShipSeparately() || $item->getParentItem() != null && $this->_useBundleParent && $item->getParentItem()->isShipSeparately()) { $params['ship_separate'] = true; } if (!is_numeric($params['num_boxes']) || $params['num_boxes'] < 1) { $params['num_boxes'] = 1; } // best_fit packing_logic $params['possible_ship_boxes'] = $product->getData('ship_possible_boxes'); // best_fit tolerance level $params['ship_box_tolerance'] = $product->getData('ship_box_tolerance'); if (Mage::helper('shipusa')->isDebug()) { Mage::helper('wsalogger/log')->postDebug('usashipping', 'product sku:' . $params['sku'], $params); } return $params; }