public function agileExpressCheckout($tpl_file) { global $cookie, $cart, $smarty; if (!$this->active) { return; } $countries = Country::getCountries(intval($cookie->id_lang), !$cart->isVirtualCart()); $selectedCountry = 0; if (!AgileHelper::isLocalIP() && Configuration::get('PS_GEOLOCATION_ENABLED') == 1) { include_once _PS_GEOIP_DIR_ . 'geoipcity.inc'; $gi = geoip_open(realpath(_PS_GEOIP_DIR_ . 'GeoLiteCity.dat'), GEOIP_STANDARD); $ip_addr = Tools::getRemoteAddr(); $record = geoip_record_by_addr($gi, $ip_addr); $selectedCountry = (int) AgileHelper::getCountryIDbyIso($record->country_code); } if ($selectedCountry <= 0) { $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT')); } if ($cart->id_address_delivery > 0) { $daddress = new Address($cart->id_address_delivery); $selectedCountry = $daddress->id_country; } if (isset($_POST['expresscheckout_id_country']) and intval($_POST['expresscheckout_id_country']) > 0) { $selectedCountry = intval($_POST['expresscheckout_id_country']); } $hasStates = isset($countries[$selectedCountry]['states']) and $countries[$selectedCountry]['contains_states']; $selectedState = 0; if ($hasStates) { if ($cart->id_address_delivery > 0) { $daddress = new Address($cart->id_address_delivery); if ($this->stateInList($daddress->id_state, $countries[$selectedCountry]['states'])) { $selectedState = $daddress->id_state; } } if (isset($_POST['expresscheckout_id_state']) and intval($_POST['expresscheckout_id_state']) > 0) { if ($this->stateInList(intval($_POST['expresscheckout_id_state']), $countries[$selectedCountry]['states'])) { $selectedState = intval($_POST['expresscheckout_id_state']); } } } $cart->id_address_delivery = $this->getShippingAddressID($selectedCountry, $selectedState); $cart->save(); $selectedZoneID = $this->getZoneByStateOrCountry(isset($selectedCountry) ? $selectedCountry : 0, isset($selectedState) ? $selectedState : 0); $currency_cart = new Currency(intval($cart->id_currency)); $carriers = $this->getCarriersByZoneID($selectedZoneID); for ($idx = 0; $idx < count($carriers); $idx++) { $fees = Tools::ps_round(floatval($carriers[$idx]['price']), 2); $carriers[$idx]['name'] = $carriers[$idx]['name'] . ' -- ' . $currency_cart->sign . ' ' . $fees; } $selectedCarrier = empty($carriers) ? 0 : $carriers[0]['id_carrier']; if (isset($cart->id_carrier) and intval($cart->id_carrier) > 0 and $this->carrierInList($cart->id_carrier, $carriers)) { $selectedCarrier = intval($cart->id_carrier); } if (isset($_POST['expresscheckout_id_carrier']) and intval($_POST['expresscheckout_id_carrier']) > 0 and $this->carrierInList($_POST['expresscheckout_id_carrier'], $carriers)) { $selectedCarrier = intval($_POST['expresscheckout_id_carrier']); } $cart->id_carrier = $selectedCarrier; $delivery_option[(int) $cart->id_address_delivery] = $selectedCarrier . ","; $cart->setDeliveryOption($delivery_option); $cart->save(); $membership_interval = $this->get_membership_interval(); $recurring_only = intval(Configuration::get('AGILE_PAYPAL_AM_INTEGRATED')) == 1 && intval(Configuration::get('AGILE_PAYPAL_AM_SHOW_CHOICE')) == 0 && $membership_interval != '' ? 1 : 0; $display_repeating = intval(Configuration::get('AGILE_PAYPAL_RECURRING_PAYMENT')) == 1 ? 1 : (intval(Configuration::get('AGILE_PAYPAL_AM_INTEGRATED')) == 1 && (intval(Configuration::get('AGILE_PAYPAL_AM_NO_MIX_PRODUCT')) == 1 || intval(Configuration::get('AGILE_PAYPAL_AM_SHOW_CHOICE')) == 1) && $membership_interval != '' ? $recurring_only == 1 ? 0 : 1 : 0); $smarty->assign(array('countries' => $countries, 'hasStates' => $hasStates, 'states' => $hasStates ? $countries[$selectedCountry]['states'] : '', 'carriers' => $carriers, 'agilepaypal_dir' => dirname(__FILE__) . '/', 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'sl_state' => isset($selectedState) ? $selectedState : 0, 'sl_carrier' => isset($selectedCarrier) ? $selectedCarrier : 0, 'cycle_base' => $this->get_membership_units(), 'membership_interval' => $this->get_membership_interval(), 'hidestates' => (!$hasStates or intval(Configuration::get('AGILE_PAYPAL_HIDE_CARRIER')) == 1) ? 1 : 0, 'hidecarrier' => intval(Configuration::get('AGILE_PAYPAL_HIDE_CARRIER')), 'recurringpayment' => intval($display_repeating), 'recurringdaily' => intval(Configuration::get('AGILE_PAYPAL_RECURRING_DAILY')) == 1 ? 1 : 0, 'recurringweekly' => intval(Configuration::get('AGILE_PAYPAL_RECURRING_WEEKLY')) == 1 ? 1 : 0, 'recurringmonthly' => intval(Configuration::get('AGILE_PAYPAL_RECURRING_MONTHLY')) == 1 ? 1 : 0, 'recurringyearly' => intval(Configuration::get('AGILE_PAYPAL_RECURRING_YEARLY')) == 1 ? 1 : 0, 'hidecountry' => intval(Configuration::get('AGILE_PAYPAL_HIDE_COUNTRY')), 'recurringOnly' => intval($recurring_only), 'displayrepeating' => intval($display_repeating))); return $this->display($this->get_module_file(), $tpl_file); }