Example #1
0
 function prepareAjaxData($checkAutomaticSelected = true)
 {
     $this->prepareCartData(false);
     $data = new stdClass();
     $data->products = array();
     $data->totalProduct = 0;
     //OSP when prices removed needed to format billTotal for AJAX
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currencyDisplay = CurrencyDisplay::getInstance();
     foreach ($this->products as $i => $product) {
         $category_id = $this->getCardCategoryId($product->virtuemart_product_id);
         //Create product URL
         $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $category_id, FALSE);
         $data->products[$i]['product_name'] = JHtml::link($url, $product->product_name);
         if (!class_exists('VirtueMartModelCustomfields')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'customfields.php';
         }
         //  custom product fields display for cart
         $data->products[$i]['customProductData'] = VirtueMartModelCustomfields::CustomsFieldCartModDisplay($product);
         $data->products[$i]['product_sku'] = $product->product_sku;
         $data->products[$i]['prices'] = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['subtotal']);
         // other possible option to use for display
         $data->products[$i]['subtotal'] = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['subtotal']);
         $data->products[$i]['subtotal_tax_amount'] = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['subtotal_tax_amount']);
         $data->products[$i]['subtotal_discount'] = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['subtotal_discount']);
         $data->products[$i]['subtotal_with_tax'] = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['subtotal_with_tax']);
         // UPDATE CART / DELETE FROM CART
         $data->products[$i]['quantity'] = $product->quantity;
         $data->totalProduct += $product->quantity;
     }
     if (empty($this->cartPrices['billTotal']) or $this->cartPrices['billTotal'] < 0) {
         $this->cartPrices['billTotal'] = 0.0;
     }
     $data->billTotal = $currencyDisplay->priceDisplay($this->cartPrices['billTotal']);
     $data->dataValidated = $this->_dataValidated;
     if ($data->totalProduct > 1) {
         $data->totalProductTxt = vmText::sprintf('COM_VIRTUEMART_CART_X_PRODUCTS', $data->totalProduct);
     } else {
         if ($data->totalProduct == 1) {
             $data->totalProductTxt = vmText::_('COM_VIRTUEMART_CART_ONE_PRODUCT');
         } else {
             $data->totalProductTxt = vmText::_('COM_VIRTUEMART_EMPTY_CART');
         }
     }
     if (false && $data->dataValidated == true) {
         $taskRoute = '&task=confirm';
         $linkName = vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
     } else {
         $taskRoute = '';
         $linkName = vmText::_('COM_VIRTUEMART_CART_SHOW');
     }
     $data->cart_show = '<a style ="float:right;" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart" . $taskRoute, $this->useSSL) . '" rel="nofollow" >' . $linkName . '</a>';
     $data->billTotal = vmText::sprintf('COM_VIRTUEMART_CART_TOTALP', $data->billTotal);
     return $data;
 }
Example #2
0
 function prepareAjaxData($checkAutomaticSelected = false)
 {
     // Added for the zone shipment module
     //$vars["zone_qty"] = 0;
     $this->prepareCartData($checkAutomaticSelected);
     $weight_total = 0;
     $weight_subtotal = 0;
     //of course, some may argue that the $this->data->products should be generated in the view.html.php, but
     //
     if (empty($this->data)) {
         $this->data = new stdClass();
     }
     $this->data->products = array();
     $this->data->totalProduct = 0;
     $i = 0;
     //OSP when prices removed needed to format billTotal for AJAX
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     foreach ($this->products as $priceKey => $product) {
         //$vars["zone_qty"] += $product["quantity"];
         $category_id = $this->getCardCategoryId($product->virtuemart_product_id);
         //Create product URL
         $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $category_id, FALSE);
         // @todo Add variants
         $this->data->products[$i]['product_name'] = JHTML::link($url, $product->product_name);
         // Add the variants
         if (!is_numeric($priceKey)) {
             if (!class_exists('VirtueMartModelCustomfields')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
             }
             //  custom product fields display for cart
             $this->data->products[$i]['product_attributes'] = VirtueMartModelCustomfields::CustomsFieldCartModDisplay($priceKey, $product);
         }
         $this->data->products[$i]['product_sku'] = $product->product_sku;
         //** @todo WEIGHT CALCULATION
         //$weight_subtotal = vmShipmentMethod::get_weight($product["virtuemart_product_id"]) * $product->quantity'];
         //$weight_total += $weight_subtotal;
         // product Price total for ajax cart
         // 			$this->data->products[$i]['prices'] = $this->prices[$priceKey]['subtotal_with_tax'];
         $this->data->products[$i]['pricesUnformatted'] = $this->pricesUnformatted[$priceKey]['subtotal_with_tax'];
         $this->data->products[$i]['prices'] = $currency->priceDisplay($this->pricesUnformatted[$priceKey]['subtotal_with_tax']);
         // other possible option to use for display
         $this->data->products[$i]['subtotal'] = $this->pricesUnformatted[$priceKey]['subtotal'];
         $this->data->products[$i]['subtotal_tax_amount'] = $this->pricesUnformatted[$priceKey]['subtotal_tax_amount'];
         $this->data->products[$i]['subtotal_discount'] = $this->pricesUnformatted[$priceKey]['subtotal_discount'];
         $this->data->products[$i]['subtotal_with_tax'] = $this->pricesUnformatted[$priceKey]['subtotal_with_tax'];
         // UPDATE CART / DELETE FROM CART
         $this->data->products[$i]['quantity'] = $product->quantity;
         $this->data->totalProduct += $product->quantity;
         $i++;
     }
     $this->data->billTotal = $currency->priceDisplay($this->pricesUnformatted['billTotal']);
     $this->data->dataValidated = $this->_dataValidated;
     return $this->data;
 }
Example #3
0
 function prepareAjaxData($cart)
 {
     // Added for the zone shipment module
     //$vars["zone_qty"] = 0;
     $cart->prepareCartData(false);
     $weight_total = 0;
     $weight_subtotal = 0;
     //of course, some may argue that the $this->data->products should be generated in the view.html.php, but
     //
     if (empty($this->data)) {
         $this->data = new stdClass();
     }
     $this->data->products = array();
     $this->data->totalProduct = 0;
     $i = 0;
     //OSP when prices removed needed to format billTotal for AJAX
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance();
     foreach ($cart->products as $priceKey => $product) {
         //$vars["zone_qty"] += $product["quantity"];
         $category_id = $cart->getCardCategoryId($product->virtuemart_product_id);
         //Create product URL
         $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $category_id);
         // @todo Add variants
         $this->data->products[$i]['product_name'] = JHTML::link($url, $product->product_name);
         // Add the variants
         if (!is_numeric($priceKey)) {
             if (!class_exists('VirtueMartModelCustomfields')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
             }
             //  custom product fields display for cart
             $this->data->products[$i]['product_attributes'] = VirtueMartModelCustomfields::CustomsFieldCartModDisplay($priceKey, $product);
         }
         $this->data->products[$i]['product_sku'] = $product->product_sku;
         //** @todo WEIGHT CALCULATION
         //$weight_subtotal = vmShipmentMethod::get_weight($product["virtuemart_product_id"]) * $product->quantity'];
         //$weight_total += $weight_subtotal;
         // product Price total for ajax cart
         // 			$this->data->products[$i]['prices'] = $this->prices[$priceKey]['subtotal_with_tax'];
         $this->data->products[$i]['pricesUnformatted'] = $cart->pricesUnformatted[$priceKey]['subtotal_with_tax'];
         $this->data->products[$i]['prices'] = $currency->priceDisplay($cart->pricesUnformatted[$priceKey]['subtotal_with_tax']);
         // other possible option to use for display
         $this->data->products[$i]['subtotal'] = $cart->pricesUnformatted[$priceKey]['subtotal'];
         $this->data->products[$i]['subtotal_tax_amount'] = $cart->pricesUnformatted[$priceKey]['subtotal_tax_amount'];
         $this->data->products[$i]['subtotal_discount'] = $cart->pricesUnformatted[$priceKey]['subtotal_discount'];
         $this->data->products[$i]['subtotal_with_tax'] = $cart->pricesUnformatted[$priceKey]['subtotal_with_tax'];
         // UPDATE CART / DELETE FROM CART
         $this->data->products[$i]['quantity'] = $product->quantity;
         $this->data->totalProduct += $product->quantity;
         $product_images = $this->model->getProduct($product->virtuemart_product_id, true, false, true, $product->quantity);
         $this->model->addImages($product_images, 1);
         if (isset($product_images->images[0]->file_url) && $product_images->images[0]->file_url) {
             $this->data->products[$i]['image'] = $product_images->images[0]->file_url;
         } else {
             $this->data->products[$i]['image'] = 'modules/mod_virtuemart_quickcart/assets/images/demo.jpg';
         }
         $this->data->products[$i]['realimage'] = $this->createRealImage($this->data->products[$i], $this->params);
         $this->data->products[$i]['image'] = $this->_baseurl . $product_images->images[0]->file_url;
         $textcount = $this->params->get('jl_limit_desc', '100');
         $jl_readmore = $this->params->get('jl_readmore', '1');
         $titleMaxChars = $this->params->get('title_max_chars', '100');
         $replacer = $this->params->get('replacer', '...');
         $introtext = strip_tags($product->product_s_desc);
         $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id);
         if ($textcount) {
             $this->data->products[$i]['desc'] = $this->cutstr($introtext, $textcount, $url, $jl_readmore);
         }
         $this->data->products[$i]['subtitle'] = $this->substring($product->product_name, $titleMaxChars, $replacer);
         $this->data->products[$i]['url'] = $url;
         $this->data->products[$i]['cart_item_id'] = $priceKey;
         $i++;
     }
     $this->data->billTotal = $currency->priceDisplay($cart->pricesUnformatted['billTotal']);
     $this->data->dataValidated = $cart->_dataValidated;
     return $this->data;
 }