示例#1
0
 /**
  * Method to display input to upload images
  * @param int  $product_id
  * @return html
  */
 public function onJ2StoreProductFormInput($product_id)
 {
     $vars = new JObject();
     //check product id exist
     if (isset($product_id)) {
         //get the article item
         $article = J2StoreItem::getArticle($product_id);
         //get the j2store price for the above item
         $price = J2StoreItem::_getJ2Item($product_id);
         //assign the product id into vars
         $vars->product_id = $product_id;
         if (isset($price->additional_image)) {
             $vars->additional_image = json_decode($price->additional_image);
         }
         $vars->asset_id = $article->asset_id;
     }
     //check asset id exist else get from app
     if (!isset($vars->asset_id)) {
         $vars->asset_id = JFactory::getApplication()->input->get('option');
     }
     //check already main image exist
     $vars->main_image = isset($price->main_image) ? $price->main_image : "";
     $vars->listview_thumb = isset($price->listview_thumb) ? $price->listview_thumb : "";
     $vars->no_of_additional_image = $this->params->get('no_of_additional_img', 5);
     //load the layot and return the result
     $result = $this->_getLayout('default', $vars);
     return $result;
 }
示例#2
0
 public function getShippingIsEnabled()
 {
     $model = JModelLegacy::getInstance('MyCart', 'J2StoreModel');
     $list = $model->getDataNew();
     // If no item in the list, return false
     if (empty($list)) {
         return false;
     }
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/j2item.php';
     $product_helper = new J2StoreItem();
     foreach ($list as $item) {
         $shipping = $product_helper->isShippingEnabled($item['product_id']);
         if ($shipping) {
             return true;
         }
     }
     return false;
 }
示例#3
0
 function setfiles()
 {
     $app = JFactory::getApplication();
     $model = $this->getModel('Productfiles');
     //$context = 'com_j2store.productfiles';
     /* 	$filter_order		= $app->getUserStateFromRequest( $context.'filter_order',		'filter_order',		'a.ordering',	'cmd' );
     		$filter_order_Dir	= $app->getUserStateFromRequest( $context.'filter_order_Dir',	'filter_order_Dir',	'',				'word' );
      */
     // table ordering
     /* 		$lists['order_Dir'] = $filter_order_Dir;
     		$lists['order'] = $filter_order;
      */
     $total = $model->getTotal();
     $pagination = $model->getPagination();
     //$id = JRequest::getVar('id', 0, 'get', 'int');
     $id = JRequest::getVar('id');
     //set states
     $model->setState('product.id', $id);
     // get items from the table
     $items = $model->getItems();
     $row = J2StoreItem::getArticle($id);
     $files = $model->getFiles();
     $error = $model->getError();
     $view = $this->getView('productfiles', 'html');
     $view->set('_controller', 'products');
     $view->set('_view', 'products');
     $view->set('_action', "index.php?option=com_j2store&view=products&task=setfiles&tmpl=component&id=" . $id);
     $view->setModel($model, true);
     $view->assign('state', $model->getState());
     $view->assign('row', $row);
     $view->assign('items', $items);
     $view->assign('files', $files);
     $view->assign('lists', $lists);
     // for pagination (footer)
     $view->assign('error', $error);
     $view->assign('total', $total);
     $view->assign('pagination', $pagination);
     $view->assign('product_id', $id);
     //$view->assign( 'product_id', $id );
     $view->setLayout('default');
     $view->display();
 }
示例#4
0
 /**
  * getItemName() - Get the name of an item.
  *
  * @param string $order_code The order code of the item.
  */
 public static function getItemName($order_code)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/libraries/j2item.php';
     $article_tbl = J2StoreItem::getArticle($order_code);
     return $article_tbl->title;
 }
示例#5
0
                </tr>
            </thead>
            <tbody>
            <?php 
    $i = 0;
    $k = 0;
    $subtotal = 0;
    ?>
            <?php 
    foreach ($items as $item) {
        ?>
            	<?php 
        $article = J2StoreItem::getArticle($item->product_id);
        $link = ContentHelperRoute::getArticleRoute($article->id, $article->catid, $article->language);
        $link = JRoute::_($link);
        $image = J2StoreItem::getJ2Image($item->product_id, $this->params);
        ?>

                <tr class="row<?php 
        echo $k;
        ?>
">
                	<td>
                   <?php 
        if ($this->params->get('show_thumb_cart')) {
            ?>
                    <span class="j2store-cart-item-image">
                       <?php 
            if (!empty($image)) {
                echo $image;
            }
示例#6
0
 function setquantities()
 {
     $app = JFactory::getApplication();
     $product_id = $app->input->getInt('product_id');
     $model = $this->getModel('productquantities');
     $model->setState('filter_productid', $product_id);
     $items = $model->getAll();
     $row = J2StoreItem::getArticle($product_id);
     J2StoreItem::doProductQuantitiesReconciliation($row->id);
     $ns = 'com_j2store.productquantities.setquantities';
     $filter_order = $app->getUserStateFromRequest($ns . 'filter_order', 'filter_order', 'tbl.productquantity_id', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest($ns . 'filter_order_Dir', 'filter_order_Dir', '', 'word');
     // table ordering
     $model->setState('direction', $filter_order_Dir);
     $model->setState('order', $filter_order);
     $view = $this->getView('productquantities', 'html');
     $view->set('_controller', 'products');
     $view->set('_view', 'productquantities');
     $view->set('_action', "index.php?option=com_j2store&view=products&task=setquantities&product_id={$row->id}&tmpl=component");
     $view->setModel($model, true);
     $view->assign('state', $model->getState());
     $view->assign('row', $row);
     $view->assign('items', $model->getList());
     $view->setLayout('setquantities');
     $view->display();
 }
示例#7
0
                    <th><?php 
echo JText::_("J2STORE_CARTSUMMARY_TOTAL");
?>
</th>
                </tr>
            </thead>
            <tbody>
            <?php 
$i = 0;
$k = 0;
?>
            <?php 
foreach ($items as $item) {
    ?>
				<?php 
    $article = J2StoreItem::getArticle($item->product_id);
    $link = ContentHelperRoute::getArticleRoute($article->id, $article->catid, $article->language);
    $link = JRoute::_($link);
    ?>

                <tr class="row<?php 
    echo $k;
    ?>
">
                    <td>
                        <a href="<?php 
    echo $link;
    ?>
"><?php 
    echo $item->orderitem_name;
    ?>
示例#8
0
 /**
  * Adds any necessary _productsquantities records
  *
  * @param unknown_type $product_id     Product ID
  * @param unknown_type $vendor_id      Vendor ID
  * @param array $items                 Array of productQuantities objects
  * @param unknown_type $csvs           CSV output from getProductAttributeCSVs
  * @return array $items                Array of objects
  */
 static function reconcileProductAttributeCSVs($product_id, $vendor_id, $items, $csvs)
 {
     // remove extras
     $done = array();
     foreach ($items as $key => $item) {
         if (!in_array($item->product_attributes, $csvs) || in_array($item->product_attributes, $done)) {
             $row = JTable::getInstance('ProductQuantities', 'Table');
             if (!$row->delete($item->productquantity_id)) {
                 JError::raiseNotice('1', $row->getError());
             }
             unset($items[$key]);
         }
         $done[] = $item->product_attributes;
     }
     // add new ones
     $existingEntries = J2StoreItem::getColumn($items, 'product_attributes');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
     foreach ($csvs as $csv) {
         if (!in_array($csv, $existingEntries)) {
             $row = JTable::getInstance('ProductQuantities', 'Table');
             $row->product_id = $product_id;
             $row->product_attributes = $csv;
             if (!$row->save()) {
                 JError::raiseNotice('1', $row->getError());
             }
             $items[] = $row;
         }
     }
     return $items;
 }
示例#9
0
文件: cart.php 项目: ForAEdesWeb/AEW4
 public static function getItemInfo($id)
 {
     static $itemsets;
     if (!is_array($itemsets)) {
         $itemsets = array();
     }
     if (!isset($itemsets[$id])) {
         $row = J2StoreItem::getArticle($id);
         //create an object and return
         $item = J2StorePrices::getJ2Product($id);
         $item->product_id = $id;
         $item->product_name = $row->title;
         $item->short_description = $row->introtext;
         $item->long_description = $row->fulltext;
         $item->metakey = $row->metakey;
         $item->metadesc = $row->metadesc;
         $item->metadata = $row->metadata;
         $item->price = $item->item_price;
         $item->product_sku = $item->item_sku;
         $item->tax_profile_id = $item->item_tax;
         $store_config = J2StoreHelperCart::getStoreAddress();
         if ($item->use_store_config_min_out_qty > 0) {
             $item->min_out_qty = (double) $store_config->store_min_out_qty;
         }
         if ($item->use_store_config_min_sale_qty > 0) {
             $item->min_sale_qty = (double) $store_config->store_min_sale_qty;
         }
         if ($item->use_store_config_max_sale_qty > 0) {
             $item->max_sale_qty = (double) $store_config->store_max_sale_qty;
         }
         if ($item->use_store_config_notify_qty > 0) {
             $item->notify_qty = (double) $store_config->store_notify_qty;
         }
         $item->product = $row;
         //$item = $j2item;
         $itemsets[$id] = $item;
     }
     return $itemsets[$id];
 }
示例#10
0
 public static function getAvailableQuantity($id, $attribute)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $tableQuantity = JTable::getInstance('ProductQuantities', 'Table');
     $tableProduct = JTable::getInstance('Prices', 'Table');
     $J2Item = J2StoreItem::getArticle($id);
     $tableProduct->load(array('article_id' => $id));
     if (!isset($tableProduct->manage_stock) || $tableProduct->manage_stock == 0) {
         $tableProduct->quantity = '9999';
         return $tableProduct;
     }
     $select[] = "quantities.quantity";
     $select[] = "price.manage_stock";
     $query->select($select);
     $query->from($tableProduct->getTableName() . " AS price");
     $leftJoinCondition = $tableQuantity->getTableName() . " as quantities ON price.article_id = quantities.product_id ";
     $query->leftJoin($leftJoinCondition);
     $whereClause[] = "quantities.product_id = " . (int) $id;
     $whereClause[] = "quantities.product_attributes='" . $attribute . "'";
     $whereClause[] = "price.manage_stock =1 ";
     $query->where($whereClause, "AND");
     $db = JFactory::getDBO();
     $db->setQuery((string) $query);
     $item = $db->loadObject();
     if (empty($item)) {
         $return = new JObject();
         $return->product_id = $id;
         $return->product_name = $J2Item->title;
         $return->quantity = 0;
         $return->manage_stock = $tableProduct->manage_stock;
         return $return;
     }
     return $item;
 }
示例#11
0
 /**
  * This displays the content article
  * specified in the plugin's params
  *
  * @return unknown_type
  */
 function _displayArticle()
 {
     $html = '';
     $articleid = (int) $this->params->get('articleid');
     if ($articleid && is_int($articleid)) {
         require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/j2item.php';
         $html = J2StoreItem::display($articleid);
     }
     return $html;
 }
示例#12
0
 public function getTerms()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('article_id');
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/library/j2item.php';
     $j2item = new J2StoreItem();
     $data = $j2item->display($id);
     $view = $this->getView('checkout', 'html');
     $view->set('_controller', 'checkout');
     $view->set('_view', 'checkout');
     $view->set('_doTask', true);
     $view->set('hidemenu', true);
     $view->assign('html', $data);
     $view->setLayout('checkout_terms');
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     echo $html;
     $app->close();
 }
示例#13
0
 public function getRate($shipping_method_id, $product_id = '', $use_weight = '0', $weight = '0')
 {
     // TODO Give this better error reporting capabilities
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_j2store' . DS . 'models');
     $model = JModelLegacy::getInstance('ShippingRates', 'J2StoreModel');
     $model->setState('filter_shippingmethod', $shipping_method_id);
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_j2store' . DS . 'tables');
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_j2store' . DS . 'library' . DS . 'j2item.php';
     $product_helper = new J2StoreItem();
     $isShips = $product_helper->isShippingEnabled($product_id);
     if (empty($isShips)) {
         // product doesn't require shipping, therefore cannot impact shipping costs
         return JTable::getInstance('ShippingRates', 'Table');
     }
     if (!empty($use_weight) && $use_weight == '1') {
         if (!empty($weight)) {
             $model->setState('filter_weight', $weight);
         }
     }
     $items = $model->getList();
     if (empty($items)) {
         return JTable::getInstance('ShippingRates', 'Table');
     }
     return $items[0];
 }