public function SetPanelSettings() { $selectedCountry = GetConfig('CompanyCountry'); $selectedState = 0; if (isset($GLOBALS['SavedAddress']) && is_array($GLOBALS['SavedAddress'])) { $address = $GLOBALS['SavedAddress']; $selectedCountry = $address['shipcountry']; $addressVars = array('account_email' => 'AccountEmail', 'shipfirstname' => 'AddressFirstName', 'shiplastname' => 'AddressLastName', 'shipcompany' => 'AddressCompany', 'shipaddress1' => 'AddressLine1', 'shipaddress2' => 'AddressLine2', 'shipcity' => 'AddressCity', 'shipstate' => 'AddressState', 'shipzip' => 'AddressZip', 'shipphone' => 'AddressPhone'); if (isset($address['shipstateid'])) { $selectedState = $address['shipstateid']; } foreach ($addressVars as $addressField => $formField) { if (isset($address[$addressField])) { $GLOBALS[$formField] = isc_html_escape($address[$addressField]); } } } $country_id = GetCountryIdByName($selectedCountry); $GLOBALS['CountryList'] = GetCountryList(GetConfig('CompanyCountry'), true); $GLOBALS['StateList'] = GetStateListAsOptions($country_id, $selectedState); // If there are no states for the country then // hide the dropdown and show the textbox instead if (GetNumStatesInCountry($country_id) == 0) { $GLOBALS['HideStateList'] = "none"; } else { $GLOBALS['HideStateBox'] = "none"; } }
/** * Set up everything pertaining to the display of the 'Estimate Shipping' * feature, as well as the shipping cost of all items in the cart if it is * known. */ public function setUpShippingAndHandling() { $GLOBALS['HideShoppingCartShippingCost'] = 'none'; $GLOBALS['HideShoppingCartHandlingCost'] = 'none'; $GLOBALS['HideShoppingCartShippingEstimator'] = 'display: none'; $this->quote->setIsSplitShipping(false); $handling = $this->quote->getHandlingCost($this->displayIncludingTax); if($handling > 0) { $handlingFormatted = currencyConvertFormatPrice($handling); $GLOBALS['HandlingCost'] = $handlingFormatted; $GLOBALS['HideShoppingCartHandlingCost'] = ''; } // All products in the cart are digital downloads so the shipping doesn't apply if($this->quote->isDigital()) { return; } // If we're still here, shipping applies to this order $GLOBALS['HideShoppingCartShippingEstimator'] = ''; $selectedCountry = GetCountryIdByName(GetConfig('CompanyCountry')); $selectedState = 0; $selectedStateName = ''; // Retain the country, stae and zip code selections if we have them $shippingAddress = $this->quote->getShippingAddress(0); if($shippingAddress->getCountryId()) { $selectedCountry = $shippingAddress->getCountryId(); $selectedState = $shippingAddress->getStateId(); $GLOBALS['ShippingZip'] = $shippingAddress->getZip(); } $GLOBALS['ShippingCountryList'] = GetCountryList($selectedCountry); $GLOBALS['ShippingStateList'] = GetStateListAsOptions($selectedCountry, $selectedState); $GLOBALS['ShippingStateName'] = isc_html_escape($selectedStateName); // If there are no states for the country then hide the dropdown and show the textbox instead if (GetNumStatesInCountry($selectedCountry) == 0) { $GLOBALS['ShippingHideStateList'] = "none"; } else { $GLOBALS['ShippingHideStateBox'] = "none"; } // Show the stored shipping estimate if we have one if($shippingAddress->hasShippingMethod()) { $GLOBALS['HideShoppingCartShippingCost'] = ''; $cost = $shippingAddress->getNonDiscountedShippingCost($this->displayIncludingTax); if($cost == 0) { $GLOBALS['ShippingCost'] = getLang('Free'); } else { $GLOBALS['ShippingCost'] = currencyConvertFormatPrice($cost); } $GLOBALS['ShippingProvider'] = isc_html_escape($shippingAddress->getShippingProvider()); } }
/** * Display a list of states for a given country * * @return void **/ private function GetCountryStates() { $country = $_REQUEST['c']; if (IsId($country)) { $countryId = $country; } else { $countryId = GetCountryIdByName($country); } if (isset($_REQUEST['s']) && GetStateByName($_REQUEST['s'], $countryId)) { $state = $_REQUEST['s']; } else { $state = ''; } if (isset($_REQUEST['format']) && $_REQUEST['format'] == 'options') { echo GetStateListAsOptions($country, $state, false, '', '', false, true); } else { echo GetStateList((int) $country); } }
/** * Generate a field (either a text box or select box) for entering/selecting a state. * In the case that the supplied country does not have any states, a text box is returned. * If the country does have states, a textbox asking for the country to be selected is returned. * * @param string The name of the text box/select box. * @param string The ID of the text box/select box. * @param string The name of the country to fetch the states for (can also be the country ID) * @param string The name of the selected state. * @param string Optionally a class name to be applied to the select box or text box. * @return string The generated text/select box. */ function GenerateStateSelect($name, $id, $country = '', $selectedState = '', $className = '') { // If no country was supplied use the store default if (empty($country)) { $country = GetConfig('CompanyCountry'); } $stateList = GetStateListAsOptions($country, $selectedState, false, '', '', false, true); if (!$stateList) { return '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $className . '" class="StateSelect" value="' . isc_html_escape($selectedState) . '" />'; } else { $select = '<select name="' . $name . '" id="' . $id . '" class="' . $className . '" class="StateSelect">'; $select .= $stateList; $select .= '</select>'; return $select; } }
/** * Show the form to update an existing tax rate. */ private function EditTaxRate() { $GLOBALS['FormAction'] = "SettingsSaveUpdatedTaxRate"; $GLOBALS['TaxRateTitle'] = GetLang('EditTaxRate'); $GLOBALS['CancelMessage'] = GetLang('CancelAddTaxRate'); if (isset($_GET['taxRateId'])) { $taxRateId = (int) $_GET['taxRateId']; $query = sprintf("select * from [|PREFIX|]tax_rates where taxrateid='%d'", $taxRateId); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['hiddenFields'] = sprintf("<input type='hidden' name='taxrateid' value='%d' />", $taxRateId); if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['TaxRateName'] = isc_html_escape($row['taxratename']); if ($row['taxratebasedon'] == "subtotal") { $GLOBALS['BasedOnSubTotal'] = 'selected="selected"'; } else { $GLOBALS['BasedOnSubTotalAndShipping'] = 'selected="selected"'; } if ($row['taxaddress'] == 'shipping') { $GLOBALS['TaxAddressShipping'] = 'selected="selected"'; } else { $GLOBALS['TaxAddressBilling'] = 'selected="selected"'; } $GLOBALS['CountryList'] = GetCountryList($row['taxratecountry'], true, "AllCountries", 0, true); $row['taxratestates'] = trim($row['taxratestates'], ','); if ($row['taxratestates'] == "0") { $sel_first = true; } else { $sel_first = false; } // If there's at least one state for this country in the database, show the list if (GetNumStatesInCountry($row['taxratecountry']) > 0) { $GLOBALS['StateList'] = GetStateListAsOptions($row['taxratecountry'], explode(",", $row['taxratestates']), true, "AllStates", "0", $sel_first); } else { $GLOBALS['HideStateList'] = "none"; } if ($row['taxratestatus'] == 1) { $GLOBALS['TaxEnabled'] = 'checked="checked"'; } $GLOBALS['TaxRatePercent'] = FormatPrice($row['taxratepercent'], false, false); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("tax.form"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); } else { $this->ManageTaxSettings(); } } else { $this->ManageTaxSettings(); } }
public function SetupPreCheckoutShipping() { $subtotal = $GLOBALS['CartSubTotal']; $_SESSION['CHECKOUT']['SUBTOTAL_COST'] = $GLOBALS['CartSubTotal']; // Hide everything by default $GLOBALS['HideCartFreeShippingPanel'] = 'none'; $GLOBALS['HideCartDiscountRulePanel'] = 'none'; $GLOBALS['HideShoppingCartShippingCost'] = 'none'; $GLOBALS['HideShoppingCartHandlingCost'] = 'none'; $GLOBALS['HideShoppingCartShippingEstimator'] = 'display: none'; $GLOBALS['HideShoppingCartImmediateDownload'] = 'none'; // All products in the cart are digital downloads so the shipping doesn't apply if ($this->api->AllProductsInCartAreIntangible()) { // Show the 'immediate download' text $GLOBALS['HideShoppingCartImmediateDownload'] = ''; // If we have a handling fee set up for digital orders then we need to show it too if (GetConfig('DigitalOrderHandlingFee') > 0) { $_SESSION['CHECKOUT']['HANDLING_COST'] = GetConfig('DigitalOrderHandlingFee'); $GLOBALS['HandlingCost'] = CurrencyConvertFormatPrice(GetConfig('DigitalOrderHandlingFee')); $GLOBALS['CartSubTotal'] += GetConfig('DigitalOrderHandlingFee'); $GLOBALS['HideShoppingCartHandlingCost'] = ''; } return; } $freeShippingQualified = false; $cartProducts = $this->api->GetProductsInCart(); $freeShippingProductCount = 0; foreach ($cartProducts as $product) { if ($product['data']['prodtype'] == PT_PHYSICAL && $product['data']['prodfreeshipping'] == 1) { ++$freeShippingProductCount; } } $discountMessages = $this->api->Get('DISCOUNT_MESSAGES'); if (!is_array($discountMessages)) { $discountMessages = array(); } $GLOBALS['CartRuleMessage'] = ''; foreach ($discountMessages as $message) { $GLOBALS['CartRuleMessage'] .= '<p class="InfoMessage">' . GetLang('DiscountCongratulations') . ' '; $GLOBALS['CartRuleMessage'] .= $message; $GLOBALS['CartRuleMessage'] .= '</p>'; } // If all of the products in the cart have free shipping, then we automatically qualify if ($freeShippingProductCount == count($cartProducts) || $this->api->GetCartFreeShipping()) { $GLOBALS['ShippingCost'] = GetLang('Free'); $freeShippingQualified = true; $GLOBALS['HideCartFreeShippingPanel'] = ""; $GLOBALS['FreeShippingMessage'] = GetLang('OrderQualifiesForFreeShipping'); return; } // Show the estimation box $GLOBALS['HideShoppingCartShippingEstimator'] = ''; // If we have a shipping zone already stored, we can show a little more if (isset($_SESSION['OFFERCART']['SHIPPING']['ZONE'])) { $zone = GetShippingZoneById($_SESSION['OFFERCART']['SHIPPING']['ZONE']); // The zone no longer exists if (!isset($zone['zoneid'])) { unset($_SESSION['OFFERCART']['SHIPPING']); return; } // If the contents of the cart have changed since their last known values (based off a unique hash of the cart contents) // then invalidate the shipping costs if (isset($_SESSION['OFFERCART']['SHIPPING']['CART_HASH']) && $this->api->GenerateCartHash() != $_SESSION['OFFERCART']['SHIPPING']['CART_HASH']) { // Remove any existing shipping costs $this->InvalidateCartShippingCosts(); } // If we have a shipping cost saved, store it too if (isset($_SESSION['OFFERCART']['SHIPPING']['SHIPPING_COST'])) { $GLOBALS['HideShoppingCartShippingCost'] = ''; if ($_SESSION['OFFERCART']['SHIPPING']['SHIPPING_COST'] == 0) { $GLOBALS['ShippingCost'] = GetLang('Free'); } else { $GLOBALS['ShippingCost'] = CurrencyConvertFormatPrice($_SESSION['OFFERCART']['SHIPPING']['SHIPPING_COST']); $subtotal += $_SESSION['OFFERCART']['SHIPPING']['SHIPPING_COST']; $GLOBALS['ShippingProvider'] = isc_html_escape($_SESSION['OFFERCART']['SHIPPING']['SHIPPING_PROVIDER']); } } // If there is a handling fee, we need to show it too if (isset($_SESSION['OFFERCART']['SHIPPING']['HANDLING_FEE']) && $_SESSION['OFFERCART']['SHIPPING']['HANDLING_FEE'] > 0) { $GLOBALS['HideShoppingCartHandlingCost'] = ''; $GLOBALS['HandlingCost'] = CurrencyConvertFormatPrice($_SESSION['OFFERCART']['SHIPPING']['HANDLING_FEE']); $subtotal += $_SESSION['OFFERCART']['SHIPPING']['HANDLING_FEE']; } // This zone has free shipping set up. Do we qualify? if ($zone['zonefreeshipping'] == 1) { $GLOBALS['HideCartFreeShippingPanel'] = ""; // We don't have enough to qualify - but still show the "spend x more for free shipping" message if ($GLOBALS['CartSubTotal'] < $zone['zonefreeshippingtotal']) { $diff = CurrencyConvertFormatPrice($zone['zonefreeshippingtotal'] - $GLOBALS['CartSubTotal']); if ($zone['zonehandlingfee'] > 0 && !$zone['zonehandlingseparate']) { $GLOBALS['FreeShippingMessage'] = sprintf(GetLang('SpendXMoreXShipping'), $diff, CurrencyConvertFormatPrice($zone['zonehandlingfee'])); } else { $GLOBALS['FreeShippingMessage'] = sprintf(GetLang('SpendXMoreFreeShipping'), $diff); } } else { // Setup the shipping message - if a handling fee is to be applied, then they actually qualify for $X shipping, not free shipping if ($zone['zonehandlingfee'] > 0 && !$zone['zonehandlingseparate']) { $GLOBALS['FreeShippingMessage'] = sprintf(GetLang('OrderQualifiesForXShipping'), CurrencyConvertFormatPrice($zone['zonehandlingfee'])); } else { $GLOBALS['FreeShippingMessage'] = GetLang('OrderQualifiesForFreeShipping'); } } } } $selectedCountry = GetCountryIdByName(GetConfig('CompanyCountry')); $selectedState = 0; $selectedStateName = ''; $zipCode = ''; // Retain the country, stae and zip code selections if we have them if (isset($_SESSION['OFFERCART']['SHIPPING']['COUNTRY_ID'])) { $selectedCountry = (int) $_SESSION['OFFERCART']['SHIPPING']['COUNTRY_ID']; if (isset($_SESSION['OFFERCART']['SHIPPING']['STATE_ID'])) { $selectedState = (int) $_SESSION['OFFERCART']['SHIPPING']['STATE_ID']; } if (isset($_SESSION['OFFERCART']['SHIPPING']['STATE'])) { $selectedStateName = $_SESSION['OFFERCART']['SHIPPING']['STATE']; } if (isset($_SESSION['OFFERCART']['SHIPPING']['ZIP_CODE'])) { $GLOBALS['ShippingZip'] = isc_html_escape($_SESSION['OFFERCART']['SHIPPING']['ZIP_CODE']); } } $GLOBALS['ShippingCountryList'] = GetCountryList($selectedCountry); $GLOBALS['ShippingStateList'] = GetStateListAsOptions($selectedCountry, $selectedState); $GLOBALS['ShippingStateName'] = isc_html_escape($selectedStateName); // If there are no states for the country then hide the dropdown and show the textbox instead if (GetNumStatesInCountry($selectedCountry) == 0) { $GLOBALS['ShippingHideStateList'] = "none"; } else { $GLOBALS['ShippingHideStateBox'] = "none"; } // if (isset($_SESSION['the_offered_price'])) // { // $GLOBALS['CartSubTotal'] = $_SESSION['the_offered_price']; // } // else // { $GLOBALS['CartSubTotal'] = $subtotal; // } }