Exemple #1
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;
 }
Exemple #2
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];
 }