/** * Add a shipping method to this collection. * * @param MethodInterface $method The shipping method to add * * @return MethodCollection Returns $this for chainability * * @throws \InvalidArgumentException If a shipping method with the same name * has already been set on this collection */ public function add(MethodInterface $method) { if (isset($this->methods[$method->getName()])) { throw new \InvalidArgumentException(sprintf('Shipping method `%s` is already defined', $method->getName())); } $this->_methods[$method->getName()] = $method; return $this; }
/** * Set the shipping method to use for the order. * * @param Shipping\MethodInterface $option Shipping method to use */ public function setShipping(Shipping\MethodInterface $option) { $this->_order->shippingName = $option->getName(); $this->_order->shippingDisplayName = $option->getDisplayName(); $this->_order->shippingListPrice = $option->getPrice(); return $this->dispatchEvent(); }