public static function getAll($group_id = 1, $view = NULL) { global $lC_Database, $lC_Language; $Qcfg = $lC_Database->query('select * from :table_configuration where configuration_group_id = :configuration_group_id order by sort_order'); $Qcfg->bindTable(':table_configuration', TABLE_CONFIGURATION); $Qcfg->bindInt(':configuration_group_id', $group_id); $Qcfg->execute(); $result = array('entries' => array()); $result = array('aaData' => array()); while ($Qcfg->next()) { if ($Qcfg->valueProtected('configuration_title') == 'Zip Code' && STORE_COUNTRY != 223) { $title = 'Postal Code'; } else { $title = $Qcfg->valueProtected('configuration_title'); } $value = $Qcfg->valueProtected('configuration_value'); $configuration_group_id = $Qcfg->valueProtected('configuration_group_id'); if ($value == '-1') { $value = $lC_Language->get('parameter_false'); } elseif ($value == '0') { $value = $lC_Language->get('parameter_optional'); } elseif ($value == '1') { // Value 1 or true/yes fix. if ($configuration_group_id == 7) { $value = 1; } else { $value = $lC_Language->get('parameter_true'); } } else { if ($title == 'Country' || $title == 'Country of Origin') { $country = lc_get_country_data($value); $value = $country['countries_name']; } else { if ($title == 'Default Shipping Unit') { $wc = lc_get_weight_class_data($value); $value = $wc['weight_class_title']; } else { if (stristr($title, 'percentage')) { $value = $value . '%'; } else { if ($title == 'Zone') { $zn = lc_get_zone_data($value); $value = $zn['zone_name']; } } } } } $action = '<td class="align-right vertical-center">' . ' <span class="button-group compact" title="' . $_SESSION['admin']['access']['configuration'] . '">' . ' <a href="javascript:void(0);" class="button icon-pencil' . ((int) ($_SESSION['admin']['access']['configuration'] < 4) ? " disabled" : NULL) . '"' . ((int) ($_SESSION['admin']['access']['configuration'] < 4) ? NULL : ' onclick="editEntry(\'' . $Qcfg->valueInt('configuration_id') . '\')"') . '><span>' . (stristr($view, 'mobile-') ? NULL : $lC_Language->get('icon_edit')) . '</span></a>' . ' </span>' . '</td>'; $result['aaData'][] = array("{$title}", "{$value}", "{$action}"); $result['entries'][] = $Qcfg->toArray(); if (!lc_empty($Qcfg->value('use_function'))) { $result['entries'][sizeof($result['entries']) - 1]['configuration_value'] = lc_call_user_func($Qcfg->value('use_function'), $Qcfg->value('configuration_value')); } } $Qcfg->freeResult(); return $result; }
public function quote($method = '') { global $lC_Database, $lC_Language, $lC_ShoppingCart, $lC_Currencies, $lC_Tax; if (!empty($method) && isset($this->_types[$method])) { $prod = $method; } else { if ($lC_ShoppingCart->getShippingAddress('country_iso_code_2') == 'CA') { $prod = 'STD'; } else { $prod = 'GNDRES'; } } if (!empty($method)) { $this->_upsAction('3'); } // return a single quote $this->_upsProduct($prod); $countries_array = lc_get_country_data(SHIPPING_ORIGIN_COUNTRY); $this->_upsOrigin(SHIPPING_ORIGIN_ZIP, $countries_array['countries_iso_code_2']); $this->_upsDest($lC_ShoppingCart->getShippingAddress('postcode'), $lC_ShoppingCart->getShippingAddress('country_iso_code_2')); $this->_upsRate(ADDONS_SHIPPING_UNITED_PARCEL_SERVICE_PICKUP); $this->_upsContainer(ADDONS_SHIPPING_UNITED_PARCEL_SERVICE_PACKAGE); $this->_upsWeight($lC_ShoppingCart->getWeight()); $this->_upsRescom(ADDONS_SHIPPING_UNITED_PARCEL_SERVICE_RES); $shipping_weight = $lC_ShoppingCart->getShippingBoxesWeight() < 0.1 ? 0.1 : $lC_ShoppingCart->getShippingBoxesWeight(); $shipping_num_boxes = ceil((double) $shipping_weight / (double) SHIPPING_MAX_WEIGHT); if ($shipping_num_boxes <= 0) { $shipping_num_boxes = 1; } $upsQuote = $this->_upsGetQuote(); if (is_array($upsQuote) && sizeof($upsQuote) > 0) { $this->quotes = array('id' => $this->_code, 'module' => $this->_title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . ' lbs)'); $methods = array(); $allowed_methods = $this->_getAllowedMethods(); $std_rcd = false; $qsize = sizeof($upsQuote); for ($i = 0; $i < $qsize; $i++) { list($type, $cost) = each($upsQuote[$i]); if ($type == 'STD') { if ($std_rcd) { continue; } else { $std_rcd = true; } } if (!in_array($type, $allowed_methods)) { continue; } $methods[] = array('id' => $type, 'title' => $this->_types[$type], 'cost' => ($cost + (double) ADDONS_SHIPPING_UNITED_PARCEL_SERVICE_HANDLING) * $shipping_num_boxes); } // begin sort order control - low to high is set, comment out for high to low sort usort($methods, array($this, '_usortMethods')); $this->quotes['methods'] = $methods; if ($this->_tax_class > 0) { $this->quotes['tax'] = $lC_Tax->getTaxRate($this->_tax_class); } } else { $this->quotes = array('module' => $this->_title, 'error' => 'We are unable to obtain a rate quote for UPS shipping.<br>Please contact the store if no other alternative is shown.'); } if (!empty($this->icon)) { $this->quotes['icon'] = lc_image($this->icon, $this->_title, null, null, 'style="vertical-align:-35%;"'); } return $this->quotes; }