コード例 #1
0
 /**
  * Actually fetch the shipping quotes based on the set information.
  *
  * @return array An array of shipping quotes.
  */
 private function FetchQuotes()
 {
     $upsUrl = 'https://wwwcie.ups.com/ups.app/xml/Rate';
     $shipmentXML = $this->GenerateRateXML();
     $result = PostToRemoteFileAndGetResponse($upsUrl, $shipmentXML);
     if ($result === false) {
         $this->SetError(GetLang('UPSOpenError'));
         return false;
     }
     $x = @simplexml_load_string($result);
     if (!is_object($x)) {
         $this->SetError(GetLang('UPSOpenError'));
         return false;
     }
     // Was an error returned from UPS? If so, set that and return
     if (isset($x->Response->ResponseStatusCode) && $x->Response->ResponseStatusCode == 0) {
         $this->SetError((string) $x->Response->Error->ErrorDescription);
         return false;
     }
     $quotes = array();
     if (!isset($x->RatedShipment[0])) {
         $quoteXML = array($x->RatedShipment);
     } else {
         $quoteXML = $x->RatedShipment;
     }
     $deliveryTypes = $this->GetValue('deliverytypes');
     if (!is_array($deliveryTypes)) {
         $deliveryTypes = array($deliveryTypes);
     }
     foreach ($quoteXML as $quote) {
         // Fetch the friendly name of the shipping service for this quote
         $serviceName = GetLang('Unknown');
         $service = (string) $quote->Service->Code;
         // We're not offering this delivery type in the store so skip it
         if (!in_array($service, $deliveryTypes)) {
             continue;
         }
         if (isset($this->internationalTypes[$service])) {
             $serviceName = GetLang('DeliveryType' . $this->internationalTypes[$service]);
         } else {
             if (isset($this->domesticTypes[$service])) {
                 $serviceName = GetLang('DeliveryType' . $this->domesticTypes[$service]);
             }
         }
         $cost = (double) $quote->TotalCharges->MonetaryValue;
         $currencyCode = (string) $quote->TotalCharges->CurrencyCode;
         $quoteCurrency = GetCurrencyByCode($currencyCode);
         if ($quoteCurrency == false) {
             $this->SetError(sprintf(GetLang('UPSCurrencyCodeError'), $currencyCode));
             continue;
         }
         $transitTime = 0;
         if (isset($quote->GuaranteedDaysToDelivery)) {
             $transitTime = (string) $quote->GuaranteedDaysToDelivery;
         }
         $cost = ConvertPriceToDefaultCurrency($cost, $quoteCurrency);
         $quotes[] = new ISC_SHIPPING_QUOTE($this->GetId(), $this->GetDisplayName(), $cost, $serviceName, $transitTime);
     }
     return $quotes;
 }
コード例 #2
0
ファイル: orders_jun24.php プロジェクト: nirvana-info/old_bak
/**
 * Rebuild the prices of an item in the customers shopping cart to the present
 * default currency.
 */
function RecompileOrderPrices()
{
    if (!isset($_SESSION['CART']['ITEMS']) || empty($_SESSION['CART']['ITEMS'])) {
        return false;
    }
    $defaultCurrency = GetDefaultCurrency();
    foreach ($_SESSION['CART']['ITEMS'] as $k => $item) {
        // If currencies are the same then leave it alone
        if (!isset($item['default_currency']) && $defaultCurrency['currencyid'] == $item['default_currency']) {
            continue;
        }
        if (array_key_exists('original_price', $item)) {
            $item['original_price'] = ConvertPriceToDefaultCurrency($item['original_price'], $item['default_currency']);
        }
        $item['product_price'] = ConvertPriceToDefaultCurrency($item['product_price'], $item['default_currency']);
        $item['default_currency'] = $defaultCurrency['currencyid'];
        $_SESSION['CART']['ITEMS'][$k] = $item;
    }
    return true;
}
コード例 #3
0
	private function PreviewGiftCertificate()
	{
		if(!isset($_REQUEST['certificate_theme'])) {
			$_REQUEST['certificate_theme'] = 'General';
		}

		$_REQUEST['certificate_theme'] = basename($_REQUEST['certificate_theme']);

		$certificate = array(
			"giftcertto" => $_REQUEST['to_name'],
			"giftcerttoemail" => $_REQUEST['to_email'],
			"giftcertfrom" => $_REQUEST['from_name'],
			"giftcertfromemail" => $_REQUEST['from_email'],
			"giftcertmessage" => $_REQUEST['message'],
			"giftcerttemplate" => $_REQUEST['certificate_theme'],
			"giftcertcode" => 'XXX-XXX-XXX-XXX'
		);

		if(GetConfig('GiftCertificateExpiry') > 0) {
			$certificate['giftcertexpirydate'] = time() + GetConfig('GiftCertificateExpiry');
		}

		if(isset($_REQUEST['selected_amount']) && $_REQUEST['selected_amount'] != "") {
			$certificate['giftcertamount'] = $_REQUEST['selected_amount'];
		}
		else {
			// Revert this currecny to the default one as this price is user input and therefor is not based on the default currency
			$certificate['giftcertamount'] = ConvertPriceToDefaultCurrency($_REQUEST['certificate_amount']);
		}
		echo $this->GenerateGiftCertificate($certificate);
		die();
	}