예제 #1
0
function fn_qwintry_get_price($price)
{
    $currencies = array_keys(fn_get_currencies());
    if (in_array('USD', $currencies)) {
        $price = fn_format_price_by_currency($price, CART_PRIMARY_CURRENCY, 'USD');
    } elseif (CART_PRIMARY_CURRENCY == 'EUR') {
        $price = $price * 1.097;
    } elseif (CART_PRIMARY_CURRENCY == 'RMB') {
        $price = $price * 1.157;
    }
    return $price;
}
예제 #2
0
 /**
  * Prepare request information
  *
  * @return array Prepared data
  */
 public function getRequestData()
 {
     $weight_data = fn_expand_weight($this->_shipping_info['package_info']['W']);
     $package_cost = $this->_shipping_info['package_info']['C'];
     $shipping_settings = $this->_shipping_info['service_params'];
     $pounds = $weight_data['pounds'];
     $location = $this->_shipping_info['package_info']['location'];
     $type = $this->_get_type();
     $currencies = array_keys(fn_get_currencies());
     if (in_array('USD', $currencies)) {
         $package_cost = fn_format_price_by_currency($package_cost, CART_PRIMARY_CURRENCY, 'USD');
     } elseif (CART_PRIMARY_CURRENCY == 'EUR') {
         $package_cost = $package_cost * 1.097;
     } elseif (CART_PRIMARY_CURRENCY == 'RMB') {
         $package_cost = $package_cost * 1.157;
     }
     if ($type == 'courier') {
         $data = array('params' => array('method' => 'qwair', 'hub_code' => empty($shipping_settings['hub']) ? 'DE1' : $shipping_settings['hub'], 'insurance' => false, 'retail_pricing' => false, 'weight' => $pounds > 0.1 ? $pounds : (empty($shipping_settings['default_weight']) ? 4 : $shipping_settings['default_weight']), 'items_value' => $package_cost, 'addr_country' => $location['country'], 'addr_zip' => $location['zipcode'], 'addr_line1' => $location['address'], 'addr_line2' => empty($location['address_2']) ? '' : $location['address_2'], 'addr_city' => $location['city'], 'addr_state' => fn_get_state_name($location['state'], $location['country'])));
     } elseif ($type == 'pickup') {
         $data = array('params' => array('insurance' => false, 'retail_pricing' => false, 'weight' => $pounds > 0.1 ? $pounds : (empty($shipping_settings['default_weight']) ? 4 : $shipping_settings['default_weight']), 'items_value' => $package_cost, 'delivery_pickup' => $this->_get_pickup_point()));
     }
     $request_data = array('method' => 'get', 'url' => 'cost', 'data' => $data);
     return $request_data;
 }
예제 #3
0
/**
 * Return available currencies
 * @param string $type Type of paypal (standard|express|payflow|pro|advanced|null)
 * @return array
 */
function fn_paypal_get_currencies($type = null)
{
    $paypal_currencies = array('CAD' => array('name' => __("currency_code_cad"), 'code' => 'CAD', 'id' => 124, 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'active' => true), 'EUR' => array('name' => __("currency_code_eur"), 'code' => 'EUR', 'id' => 978, 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'active' => true), 'GBP' => array('name' => __("currency_code_gbp"), 'code' => 'GBP', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 826, 'active' => true), 'USD' => array('name' => __("currency_code_usd"), 'code' => 'USD', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 840, 'active' => true), 'JPY' => array('name' => __("currency_code_jpy"), 'code' => 'JPY', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 392, 'active' => true), 'RUB' => array('name' => __("currency_code_rur"), 'code' => 'RUB', 'supports' => array('standard', 'express'), 'id' => 643, 'active' => true), 'AUD' => array('name' => __("currency_code_aud"), 'code' => 'AUD', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 36, 'active' => true), 'NZD' => array('name' => __("currency_code_nzd"), 'code' => 'NZD', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 554, 'active' => true), 'CHF' => array('name' => __("currency_code_chf"), 'code' => 'CHF', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 756, 'active' => true), 'HKD' => array('name' => __("currency_code_hkd"), 'code' => 'HKD', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 344, 'active' => true), 'SGD' => array('name' => __("currency_code_sgd"), 'code' => 'SGD', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 702, 'active' => true), 'SEK' => array('name' => __("currency_code_sek"), 'code' => 'SEK', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 752, 'active' => true), 'DKK' => array('name' => __("currency_code_dkk"), 'code' => 'DKK', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 208, 'active' => true), 'PLN' => array('name' => __("currency_code_pln"), 'code' => 'PLN', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 985, 'active' => true), 'NOK' => array('name' => __("currency_code_nok"), 'code' => 'NOK', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 578, 'active' => true), 'HUF' => array('name' => __("currency_code_huf"), 'code' => 'HUF', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 348, 'active' => true), 'CZK' => array('name' => __("currency_code_czk"), 'code' => 'CZK', 'supports' => array('standard', 'express', 'payflow', 'pro', 'advanced'), 'id' => 203, 'active' => true), 'ILS' => array('name' => __("currency_code_ils"), 'code' => 'ILS', 'supports' => array('standard', 'express', 'payflow', 'advanced'), 'id' => 376, 'active' => true), 'MXN' => array('name' => __("currency_code_mxn"), 'code' => 'MXN', 'supports' => array('standard', 'express', 'payflow', 'advanced'), 'id' => 484, 'active' => true), 'BRL' => array('name' => __("currency_code_brl"), 'code' => 'BRL', 'supports' => array('standard', 'express', 'payflow', 'advanced'), 'id' => 986, 'active' => true), 'PHP' => array('name' => __("currency_code_php"), 'code' => 'PHP', 'supports' => array('standard', 'express', 'payflow', 'advanced'), 'id' => 608, 'active' => true), 'TWD' => array('name' => __("currency_code_twd"), 'code' => 'TWD', 'supports' => array('standard', 'express', 'payflow', 'advanced'), 'id' => 901, 'active' => true), 'THB' => array('name' => __("currency_code_thb"), 'code' => 'THB', 'supports' => array('standard', 'express', 'payflow', 'advanced'), 'id' => 764, 'active' => true), 'TRY' => array('name' => __("currency_code_try"), 'code' => 'TRY', 'supports' => array('standard', 'express'), 'id' => 949, 'active' => true), 'MYR' => array('name' => __("currency_code_myr"), 'code' => 'MYR', 'supports' => array('standard', 'express'), 'id' => 458, 'active' => true));
    $currencies = fn_get_currencies();
    $result = array();
    foreach ($paypal_currencies as $key => &$item) {
        $item['active'] = isset($currencies[$key]);
        if ($type === null || in_array($type, $item['supports'], true)) {
            $result[$key] = $item;
        }
    }
    unset($item);
    return $result;
}