Exemplo n.º 1
0
 public function addtocart($data, $form)
 {
     if ($buyable = $this->getBuyable($data)) {
         $cart = ShoppingCart::singleton();
         $saveabledata = !empty($this->saveablefields) ? Convert::raw2sql(array_intersect_key($data, array_combine($this->saveablefields, $this->saveablefields))) : $data;
         $quantity = isset($data['Quantity']) ? (int) $data['Quantity'] : 1;
         $cart->add($buyable, $quantity, $saveabledata);
         if (!ShoppingCart_Controller::config()->direct_to_cart_page) {
             $form->SessionMessage($cart->getMessage(), $cart->getMessageType());
         }
         ShoppingCart_Controller::direct($cart->getMessageType());
     }
 }
 public function addtocart($data, $form)
 {
     if ($buyable = $this->getBuyable($data)) {
         $cart = ShoppingCart::singleton();
         $request = $this->getRequest();
         $order = $cart->current();
         if ($request && $request->isAjax() && $order) {
             ShopTools::install_locale($order->Locale);
         }
         $saveabledata = !empty($this->saveablefields) ? Convert::raw2sql(array_intersect_key($data, array_combine($this->saveablefields, $this->saveablefields))) : $data;
         $quantity = isset($data['Quantity']) ? (int) $data['Quantity'] : 1;
         $cart->add($buyable, $quantity, $saveabledata);
         if (!ShoppingCart_Controller::config()->direct_to_cart_page) {
             $form->SessionMessage($cart->getMessage(), $cart->getMessageType());
         }
         $this->extend('updateAddToCart', $form, $buyable);
         $this->extend('updateAddProductFormResponse', $request, $response, $buyable, $quantity, $form);
         return $response ? $response : ShoppingCart_Controller::direct($cart->getMessageType());
     }
 }