Пример #1
0
 /**
  * Migrates the coupons from the old basket to the current one.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
  * @param array $errors Associative list of previous errors
  * @param string $localeKey Unique identifier of the site, language and currency
  * @return array Associative list of errors occured
  */
 protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
 {
     foreach ($basket->getCoupons() as $code => $list) {
         try {
             $this->addCoupon($code);
             $basket->deleteCoupon($code, true);
         } catch (\Exception $e) {
             $logger = $this->getContext()->getLogger();
             $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
             $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
             $errors['coupon'][$code] = $e->getMessage();
         }
     }
     return $errors;
 }
Пример #2
0
 /**
  * Removes the result of a coupon from the order base instance.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $base Basic order of the customer
  */
 public function deleteCoupon(\Aimeos\MShop\Order\Item\Base\Iface $base)
 {
     $base->deleteCoupon($this->code, true);
 }