protected function getShippingForItem(\Pimcore\Model\Object\CoreShopCartItem $item) { $product = $item->getProduct(); /* Standardbrief C5 / C6 max. 23,5 x 16,2 x 0,5 cm bis 20 g EUR 0,68 Brief Maxi C4 max. 32,4 x 22,9 x 2 cm bis 500 g EUR 1,60 Großbrief L max. 50 cm / L + B + H max. 90 cm bis 2 kg EUR 4,00 Standardpaket 100 cm L max. 100 cm / L + 2B + 2H max. 360 cm bis 2 kg EUR 4,60 Standardpaket 100 cm L max. 100 cm / L + 2B + 2H max. 360 cm 2-4 kg EUR 5,80 EMS Standardsendung 100 cm L max. 100 cm / L + 2B + 2H max. 360 cm bis 2 kg EUR 9,92 Online Paketmarke PM 45 45 cm (Längste + kürzeste Seite bis max. ) bis 31,5 kg EUR 3,90 */ $height = $product->getHeight(); $width = $product->getWidth(); $length = $product->getLength(); $weight = $product->getWeight(); if ($length <= 235 && $width <= 162 && $height <= 5 && $weight <= 20) { return 0.68; } if ($length <= 234 && $width <= 229 && $height <= 20 && $weight <= 500) { return 1.6; } if ($length <= 500 && $length + $width + $height <= 900 && $weight < 2000) { return 4; } return false; }
public function modifyAction() { $cartItem = $this->getParam("cartItem", null); $amount = $this->getParam("amount"); $item = CoreShopCartItem::getById($cartItem); $isAllowed = true; $result = Plugin::getEventManager()->trigger('cart.preModify', $this, array("cartItem" => $item, "cart" => $this->cart, "request" => $this->getRequest()), function ($v) { return is_bool($v); }); if ($result->stopped()) { $isAllowed = $result->last(); } unset($this->session->order); if ($isAllowed) { if ($item instanceof CoreShopCartItem) { $this->cart->modifyItem($item, $amount); Plugin::getEventManager()->trigger('cart.postModify', $this, array("item" => $item, "cart" => $this->cart)); $this->_helper->json(array("success" => true, "cart" => $this->cart->toArray())); } } else { $this->_helper->json(array("success" => false, "message" => 'not allowed')); } $this->_helper->json(array("success" => false, "cart" => $this->cart->toArray())); }
/** * Modifies the quantity of a CartItem * * @param CoreShopCartItem $item * @param $amount * @return bool|CoreShopCartItem * @throws \Exception */ public function modifyItem(CoreShopCartItem $item, $amount) { return $this->updateQuantity($item->getProduct(), $amount); }