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_k2store' . DS . 'models'); $model = JModelLegacy::getInstance('ShippingRates', 'K2StoreModel'); $model->setState('filter_shippingmethod', $shipping_method_id); JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'tables'); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'library' . DS . 'k2item.php'; $product_helper = new K2StoreItem(); $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]; }
public function getShippingIsEnabled() { $model = JModelLegacy::getInstance('MyCart', 'K2StoreModel'); $list = $model->getDataNew(); // If no item in the list, return false if (empty($list)) { return false; } require_once JPATH_ADMINISTRATOR . '/components/com_k2store/library/k2item.php'; $product_helper = new K2StoreItem(); foreach ($list as $item) { $shipping = $product_helper->isShippingEnabled($item['product_id']); if ($shipping) { return true; } } return false; }