/** * Sets the attributes in the given service item. * * @param \Aimeos\MShop\Order\Item\Base\Service\Iface $orderServiceItem Order service item that will be added to the basket * @param array $attributes Attribute key/value pairs entered by the customer during the checkout process * @param string $type Type of the configuration values (delivery or payment) */ protected function setAttributes(\Aimeos\MShop\Order\Item\Base\Service\Iface $orderServiceItem, array $attributes, $type) { $manager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service/attribute'); foreach ($attributes as $key => $value) { $item = $manager->createItem(); $item->setCode($key); $item->setValue($value); $item->setType($type); $orderServiceItem->setAttributeItem($item); } }
/** * Sets a service as delivery or payment service for an order. * * @param \Aimeos\MShop\Order\Item\Base\Service\Iface $service Order service item for the given domain * @param string $type Service type * @return \Aimeos\MShop\Order\Item\Base\Service\Iface Item that was really added to the basket */ public function setService(\Aimeos\MShop\Order\Item\Base\Service\Iface $service, $type) { $this->checkPrice($service->getPrice()); $this->notifyListeners('setService.before', $service); $service = clone $service; $service->setType($type); // enforce that the type is the same as the given one $service->setId(null); // enforce saving as new item $this->services[$type] = $service; $this->setModified(); $this->notifyListeners('setService.after', $service); return $this->services[$type]; }