Exemplo n.º 1
0
 /**
  * Adds the default addresses to the basket if they are not available.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object
  */
 protected function setAddressDefault(\Aimeos\MShop\Order\Item\Base\Iface $order)
 {
     $context = $this->getContext();
     $addresses = $order->getAddresses();
     $type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
     if ($context->getUserId() !== null && !isset($addresses[$type]) && (bool) $this->getConfigValue('autofill.address', false) === true) {
         $customerManager = \Aimeos\MShop\Factory::createManager($context, 'customer');
         $orderAddressManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/address');
         $address = $customerManager->getItem($context->getUserId())->getPaymentAddress();
         $orderAddressItem = $orderAddressManager->createItem();
         $orderAddressItem->copyFrom($address);
         $order->setAddress($orderAddressItem, $type);
     }
 }
Exemplo n.º 2
0
 /**
  * Adds the addresses from the given order item to the basket.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object
  * @param \Aimeos\MShop\Order\Item\Iface $item Existing order to fetch the addresses from
  */
 protected function setAddresses(\Aimeos\MShop\Order\Item\Base\Iface $order, \Aimeos\MShop\Order\Item\Iface $item)
 {
     $addresses = $order->getAddresses();
     if (empty($addresses) && $this->getConfigValue('autofill.orderaddress', true) == true) {
         $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address');
         $search = $manager->createSearch();
         $search->setConditions($search->compare('==', 'order.base.address.baseid', $item->getBaseId()));
         $addresses = $manager->searchItems($search);
         foreach ($addresses as $address) {
             $order->setAddress($address, $address->getType());
         }
     }
 }