Exemplo n.º 1
0
 /**
  * @param string $code
  * @param OnlineShop_Framework_ICart $cart
  * @return bool
  */
 public static function releaseToken($code, OnlineShop_Framework_ICart $cart = null)
 {
     $db = \Pimcore\Resource::get();
     $query = "DELETE FROM " . OnlineShop_Framework_VoucherService_Reservation_Resource::TABLE_NAME . " WHERE token = ?";
     $params[] = $code;
     if (isset($cart)) {
         $query .= " AND cart_id = ?";
         $params[] = $cart->getId();
     }
     try {
         $db->query($query, $params);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $code
  * @param OnlineShop_Framework_ICart $cart
  * @return bool|string
  */
 public function get($code, OnlineShop_Framework_ICart $cart = null)
 {
     $query = "SELECT * FROM " . self::TABLE_NAME . " WHERE token = ?";
     $params[] = $code;
     if (isset($cart)) {
         $query .= " AND cart_id = ?";
         $params[] = $cart->getId();
     }
     try {
         $result = $this->db->fetchRow($query, $params);
         if (empty($result)) {
             //                throw new Exception("Reservation for token " . $code . " not found.");
             return false;
         }
         $this->assignVariablesToModel($result);
         $this->model->setValue('id', $result['id']);
         $this->model->setCartId($result['cart_id']);
         return true;
     } catch (Exception $e) {
         var_dump($e);
         return false;
     }
 }
Exemplo n.º 3
0
 /**
  * @throws OnlineShop_Framework_Exception_InvalidConfigException
  * @param OnlineShop_Framework_ICart $cart
  * @param string $name optional name of checkout manager, in case there are more than one configured
  * @return OnlineShop_Framework_ICheckoutManager
  */
 public function getCheckoutManager(OnlineShop_Framework_ICart $cart, $name = null)
 {
     if (empty($this->checkoutManagers[$cart->getId()])) {
         if ($name) {
             $managerConfigName = "checkoutmanager_" . $name;
             $manager = new $this->config->onlineshop->{$managerConfigName}->class($cart, $this->config->onlineshop->{$managerConfigName}->config);
             if (!$manager instanceof OnlineShop_Framework_ICheckoutManager) {
                 throw new OnlineShop_Framework_Exception_InvalidConfigException("Checkoutmanager class " . $this->config->onlineshop->{$managerConfigName}->class . " does not implement OnlineShop_Framework_ICheckoutManager.");
             }
         } else {
             $manager = new $this->config->onlineshop->checkoutmanager->class($cart, $this->config->onlineshop->checkoutmanager->config);
             if (!$manager instanceof OnlineShop_Framework_ICheckoutManager) {
                 throw new OnlineShop_Framework_Exception_InvalidConfigException("Checkoutmanager class " . $this->config->onlineshop->checkoutmanager->class . " does not implement OnlineShop_Framework_ICheckoutManager.");
             }
         }
         $this->checkoutManagers[$cart->getId()] = $manager;
     }
     return $this->checkoutManagers[$cart->getId()];
 }
Exemplo n.º 4
0
 public function setCart(OnlineShop_Framework_ICart $cart)
 {
     $this->cart = $cart;
     $this->cartId = $cart->getId();
 }
Exemplo n.º 5
0
 public function getOffersForCart(OnlineShop_Framework_ICart $cart)
 {
     $offerListClass = $this->offerClass . "_List";
     $list = new $offerListClass();
     $list->setCondition("cartId = ?", array($cart->getId()));
     return $list->load();
 }