示例#1
0
 /**
  * add item to wishlist
  */
 public function addAction()
 {
     // init
     $status = array('title' => 'Wishlist', 'text' => 'error', 'success' => false);
     // add item to wishlist
     if ($id = $this->getParam('item')) {
         $product = Object_Product::getById($id);
         /* @var Website_DefaultProduct $product */
         if ($product) {
             $this->wishlist->addItem($product, 1);
             $this->wishlist->save();
             $status['title'] = 'Added';
             $status['success'] = true;
             $status['text'] = $product->getOSName();
             $status['image'] = $product->getFirstImage(array('width' => 48, 'height' => 48, 'aspectratio' => true))->__toString();
         }
     }
     // its a ajax request?
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->_helper->json($status);
     } else {
         $url = $this->view->url(array('action' => 'list'), 'wishlist');
         $this->redirect($url);
     }
 }
示例#2
0
 public function productDescriptionAction()
 {
     $product = Object_Product::getById($this->getParam("id"));
     if ($product instanceof Object_Product) {
         $this->view->product = $product;
         $this->view->showVariantTable = $this->getParam("variants");
     } else {
         echo "ERROR";
         exit;
     }
 }
示例#3
0
 public function cartAction()
 {
     // init
     $manager = OnlineShop_Framework_Factory::getInstance()->getCartManager();
     $cart = null;
     // search for the cart
     foreach ($manager->getCarts() as $current) {
         if ($current->getName() === "cart") {
             $cart = $current;
             break;
         }
     }
     // create new cart if not exists
     if (!$cart) {
         $cartId = $manager->createCart(array('name' => "cart"));
         $cart = $manager->getCart($cartId);
     }
     //p_r($cart); die();
     $product = Object_Product::getById(4814);
     $cart->addItem($product, 1);
     $cart->setCheckoutData("DATA1", "sdfsdfsdfsdfsdfsdf asdf sf asdf asdf asdf asdf sdaf");
     $cart->save();
     p_r($_SESSION);
     die("done");
 }
示例#4
0
 public function productCellAction()
 {
     if ($this->getParam("type") == "object") {
         $this->view->product = Object_Product::getById($this->getParam("id"));
         $this->view->view = $this->view;
         $this->view->view->params = array("country" => $this->getParam("country"));
     }
     $this->renderScript('/shop/list/product.php');
 }
示例#5
0
 /**
  * update cart item
  */
 public function updateAction()
 {
     // init
     $status = array('title' => 'Cart', 'text' => 'error', 'success' => false, 'snippet' => array());
     if ($this->getParam("qty")) {
         foreach ($this->getParam("qty") as $key => $qty) {
             $product = Object_Product::getById($key);
             if ($product) {
                 $this->cart->updateItem($key, $product, intval($qty), true);
                 $this->cart->save();
                 $status['text'] = 'Quantity changed';
                 $status['success'] = true;
             }
         }
     }
     // change quantity
     //        foreach($this->getAllParams() as $name => $value)
     //        {
     //            if(preg_match('#^(?<action>qty|comment)_(?<itemKey>\w+)#', $name, $match))
     //            {
     //                $item = $this->cart->getItem($match['itemKey']);
     //                if($item)
     //                {
     //                    if($match['action'] == 'qty')
     //                    {
     //                        $item->setCount( (int)$value );
     //                        $status['text'] = 'Quantity changed';
     //                    }
     //
     //                    if($match['action'] == 'comment')
     //                    {
     //                        $item->setComment( $value );
     //                        $status['text'] = 'Comment saved';
     //                    }
     //
     //                    $item->save();
     //                    $status['success'] = true;
     //                }
     //            }
     //        }
     // its a ajax request?
     if ($this->getRequest()->isXmlHttpRequest()) {
         // add header cart snippet
         $this->snippetHeaderAction();
         $status['snippet']['snippetHeader'] = $this->view->render('cart/snippet-header.php');
         $this->_helper->viewRenderer->setNoRender(true);
         $this->getResponse()->setHeader('Content-Type', 'application/json');
         echo Zend_Json::encode($status);
     } else {
         $url = $this->view->url(array('action' => 'list'), 'cart');
         $this->redirect($url);
     }
 }