Beispiel #1
1
 /**
  * @return \DVDoug\BoxPacker\PackedBoxList
  */
 public function getPackages()
 {
     $packer = new ClerkPacker();
     $boxes = StoreClerkPackage::getPackages();
     foreach ($boxes as $box) {
         $packer->addBox($box);
     }
     $cartItems = StoreCart::getCart();
     foreach ($cartItems as $cartItem) {
         $product = StoreProduct::getByID((int) $cartItem['product']['pID']);
         $description = $product->getProductName();
         $width = StoreCalculator::convertToMM($product->getDimensions('w'));
         $length = StoreCalculator::convertToMM($product->getDimensions('l'));
         $depth = StoreCalculator::convertToMM($product->getDimensions('h'));
         $weight = StoreCalculator::convertToGrams($product->getProductWeight());
         $packer->addItem(new StoreClerkItem($description, $width, $length, $depth, $weight));
         //TODO: If an item doesn't fit in any box, make it it's own box.
     }
     return $packer->pack();
 }
Beispiel #2
0
 public function addOrUpdate($data, $package)
 {
     $package->setReference($data['reference']);
     $package->setOuterWidth(StoreCalculator::convertToMM($data['outerWidth']));
     $package->setOuterLength(StoreCalculator::convertToMM($data['outerLength']));
     $package->setOuterDepth(StoreCalculator::convertToMM($data['outerDepth']));
     $package->setEmptyWeight(StoreCalculator::convertToGrams($data['emptyWeight']));
     $package->setInnerWidth(StoreCalculator::convertToMM($data['innerWidth']));
     $package->setInnerLength(StoreCalculator::convertToMM($data['innerLength']));
     $package->setInnerDepth(StoreCalculator::convertToMM($data['innerDepth']));
     $innerVolume = $data['innerWidth'] * $data['innerLength'] * $data['innerDepth'];
     $package->setInnerVolume(StoreCalculator::convertToMM($innerVolume));
     $package->setMaxWeight(StoreCalculator::convertToGrams($data['maxWeight']));
     $package->save();
     return $package;
 }