예제 #1
0
파일: select.php 프로젝트: ForAEdesWeb/AEW4
 public static function radio_productattributeoptions($productattribute_id, $selected, $name = 'filter_pao', $attribs = array('class' => 'inputbox'), $idtag = null, $required = 0, $opt_selected = array())
 {
     $list = array();
     $app = JFactory::getApplication();
     $j2storeparams = JComponentHelper::getParams('com_j2store');
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/models');
     $model = JModelLegacy::getInstance('ProductAttributeOptions', 'J2StoreModel');
     $model->setId($productattribute_id);
     $model->setState('order', 'a.ordering');
     $items = $model->getAllData();
     //now pass it to a view and get things done
     JLoader::register("J2StoreViewMyCart", JPATH_SITE . "/components/com_j2store/views/mycart/view.html.php");
     $config = array();
     $config['base_path'] = JPATH_SITE . "/components/com_j2store";
     // finds the default Site template
     $db = JFactory::getDBO();
     $query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home=1";
     $db->setQuery($query);
     $template = $db->loadResult();
     jimport('joomla.filesystem.file');
     if (JFile::exists(JPATH_SITE . '/templates/' . $template . '/html/com_j2store/mycart/attributeradio.php')) {
         // (have to do this because we load the same view from the admin-side Orders view, and conflicts arise)
         $config['template_path'] = JPATH_SITE . '/templates/' . $template . '/html/com_j2store/mycart';
     }
     $view = new J2StoreViewMyCart($config);
     $view->addTemplatePath(JPATH_SITE . '/templates/' . $template . '/html/com_j2store/mycart');
     require_once JPATH_SITE . DS . 'components' . DS . 'com_j2store' . DS . 'models' . DS . 'mycart.php';
     $cartmodel = new J2StoreModelMyCart();
     $view->set('_controller', 'mycart');
     $view->set('_view', 'mycart');
     $view->set('_doTask', true);
     $view->set('hidemenu', false);
     $view->setModel($model, true);
     $view->assign('productattribute_id', $productattribute_id);
     $view->assign('name', $name);
     $view->assign('idTag', $idtag);
     $view->assign('required', $required);
     $view->assign('attribs', $attribs);
     $view->assign('items', $items);
     $view->assign('params', $j2storeparams);
     $view->setLayout('attributeradio');
     //$this->_setModelState();
     ob_start();
     $view->display();
     $html .= ob_get_contents();
     ob_end_clean();
     return $html;
 }
예제 #2
0
파일: cart.php 프로젝트: ForAEdesWeb/AEW4
 public static function getAjaxCart($item, $values = array())
 {
     $app = JFactory::getApplication();
     if (is_array($values) && !count($values)) {
         $values = $app->input->getArray($_REQUEST);
     }
     //load javascript files
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/strapper.php';
     J2StoreStrapper::addJS();
     J2StoreStrapper::addCSS();
     $html = '';
     JLoader::register("J2StoreViewMyCart", JPATH_SITE . "/components/com_j2store/views/mycart/view.html.php");
     $layout = 'addtocart';
     $view = new J2StoreViewMyCart();
     $view->addTemplatePath(JPATH_SITE . '/components/com_j2store/views/mycart/tmpl');
     $view->addTemplatePath(JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_j2store/mycart');
     require_once JPATH_SITE . '/components/com_j2store/models/mycart.php';
     $model = new J2StoreModelMyCart();
     $product_id = $item->product_id = $item->id;
     $view->assign('_basePath', JPATH_SITE . '/components/com_j2store');
     $view->set('_controller', 'mycart');
     $view->set('_view', 'mycart');
     $view->set('_doTask', true);
     $view->set('hidemenu', true);
     $view->setModel($model, true);
     $view->setLayout($layout);
     $view->assign('product_id', $product_id);
     $config = JComponentHelper::getParams('com_j2store');
     $show_tax = $config->get('show_tax_total', '1');
     //	$show_attributes = $config->get( 'show_product_attributes', 1);
     $view->assign('show_tax', $show_tax);
     $view->assign('params', $config);
     //$view->assign( 'show_attributes', $show_attributes );
     //get j2store fields
     $item->product = $product = self::getItemInfo($product_id);
     $item->attribs = $product->product->attribs;
     //quantity
     if (isset($product->min_sale_qty) && $product->min_sale_qty > 1 && J2STORE_PRO == 1) {
         $item->product_quantity = (int) $product->min_sale_qty;
         $item->item_minimum_notice = JText::sprintf('J2STORE_MINIMUM_QUANTITY_NOTIFICATION', $product->product_name, (int) $product->min_sale_qty);
     } else {
         $item->product_quantity = 1;
     }
     //get attributes
     $attributes = $model->getProductOptions($product_id);
     if (count($attributes) && $product->manage_stock == 1 && J2STORE_PRO == 1 && !$config->get('allow_backorder', 0)) {
         //get unavailable attribute options
         $attributes = $model->processAttributeOptions($attributes, $product);
         //print_r($attributes );
     }
     //get prices
     $item->prices = J2StorePrices::getPrice($product_id, $item->product_quantity);
     //tax
     $t = new J2StoreTax();
     //assign tax class to the view. so that we dont have to call it everytime.
     $view->assign('tax_class', $t);
     if (isset($item->prices->product_specialprice) && $item->prices->product_specialprice > 0) {
         $item->special_price = $item->prices->product_specialprice;
     } elseif (isset($item->prices->product_customer_groupprice) && $item->prices->product_customer_groupprice >= 0) {
         $item->special_price = $item->prices->product_customer_groupprice;
     } else {
         $item->special_price = null;
     }
     $sp_tax = $t->getProductTax($item->special_price, $item->product_id);
     $item->sp_tax = isset($sp_tax) ? $sp_tax : 0;
     if ($item->special_price) {
         //we have an offer
         $item->price = $item->prices->product_baseprice;
     } else {
         $item->price = $item->prices->product_price;
     }
     $tax = $t->getProductTax($item->price, $item->product_id);
     $item->tax = isset($tax) ? $tax : 0;
     //now get the total stock
     if (J2STORE_PRO == 1 && $product->manage_stock == 1) {
         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/models');
         $qtyModel = JModelLegacy::getInstance('ProductQuantities', 'J2StoreModel');
         $qtyModel->setState('filter_product', $item->product_id);
         if ($config->get('show_option_stock', 0)) {
             $qtyModel->setState('filter_productid', $item->product_id);
             $item->option_stock = $qtyModel->getList();
         }
         $item->product_stock = $qtyModel->getQuantityTotal();
     } else {
         $item->product_stock = '';
     }
     //item sku
     $item->product_sku = $product->item_sku;
     $view->assign('product', $product);
     $view->assign('attributes', $attributes);
     $view->assign('params', $config);
     $view->assign('item', $item);
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }