当前位置: 首页>>代码示例>>PHP>>正文


PHP Currency::getCurrent方法代码示例

本文整理汇总了PHP中Currency::getCurrent方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::getCurrent方法的具体用法?PHP Currency::getCurrent怎么用?PHP Currency::getCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Currency的用法示例。


在下文中一共展示了Currency::getCurrent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: convertAndFormatPrice

 function convertAndFormatPrice($price, $currency = false)
 {
     if (!$currency) {
         $currency = Currency::getCurrent();
     }
     return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:7,代码来源:mobile.config.inc.php

示例2: getValue

 /**
  * Return discount value
  *
  * @param integer $nb_discounts Number of discount currently in cart
  * @param boolean $order_total_products Total cart products amount
  * @return mixed Return a float value or '!' if reduction is 'Shipping free'
  */
 public function getValue($nb_discounts = 0, $order_total_products = 0, $shipping_fees = 0, $idCart = false, $useTax = true)
 {
     $totalAmount = 0;
     $cart = new Cart((int) $idCart);
     if (!Validate::isLoadedObject($cart)) {
         return 0;
     }
     if (!$this->cumulable and (int) $nb_discounts > 1 or !$this->active or !$this->quantity and !$cart->OrderExists()) {
         return 0;
     }
     if ($this->usedByCustomer((int) $cart->id_customer) >= $this->quantity_per_user and !$cart->OrderExists()) {
         return 0;
     }
     $date_start = strtotime($this->date_from);
     $date_end = strtotime($this->date_to);
     if ((time() < $date_start or time() > $date_end) and !$cart->OrderExists()) {
         return 0;
     }
     $products = $cart->getProducts();
     $categories = Discount::getCategories((int) $this->id);
     foreach ($products as $product) {
         if (count($categories) and Product::idIsOnCategoryId($product['id_product'], $categories)) {
             $totalAmount += $this->include_tax ? $product['total_wt'] : $product['total'];
         }
     }
     if ($this->minimal > 0 and $totalAmount < $this->minimal) {
         return 0;
     }
     switch ($this->id_discount_type) {
         /* Relative value (% of the order total) */
         case 1:
             $amount = 0;
             $percentage = $this->value / 100;
             foreach ($products as $product) {
                 if (Product::idIsOnCategoryId($product['id_product'], $categories)) {
                     if ($this->cumulable_reduction or !$product['reduction_applies'] and !$product['on_sale']) {
                         $amount += ($useTax ? $product['total_wt'] : $product['total']) * $percentage;
                     }
                 }
             }
             return $amount;
             /* Absolute value */
         /* Absolute value */
         case 2:
             // An "absolute" voucher is available in one currency only
             $currency = (int) $cart->id_currency ? Currency::getCurrencyInstance($cart->id_currency) : Currency::getCurrent();
             if ($this->id_currency != $currency->id) {
                 return 0;
             }
             $taxDiscount = Cart::getTaxesAverageUsed((int) $cart->id);
             if (!$useTax and isset($taxDiscount) and $taxDiscount != 1) {
                 $this->value = abs($this->value / (1 + $taxDiscount * 0.01));
             }
             // Main return
             $value = 0;
             foreach ($products as $product) {
                 if (Product::idIsOnCategoryId($product['id_product'], $categories)) {
                     $value = $this->value;
                 }
             }
             // Return 0 if there are no applicable categories
             return $value;
             /* Free shipping (does not return a value but a special code) */
         /* Free shipping (does not return a value but a special code) */
         case 3:
             return '!';
     }
     return 0;
 }
开发者ID:greench,项目名称:prestashop,代码行数:76,代码来源:Discount.php

示例3: convertPrice

 /**
  * Return price converted
  *
  * @param float $price Product price
  * @param object $currency Current currency object
  * @param boolean $to_currency convert to currency or from currency to default currency
  */
 public static function convertPrice($price, $currency = NULL, $to_currency = true)
 {
     if ($currency === NULL) {
         $currency = Currency::getCurrent();
     } elseif (is_numeric($currency)) {
         $currency = Currency::getCurrencyInstance($currency);
     }
     $c_id = is_array($currency) ? $currency['id_currency'] : $currency->id;
     $c_rate = is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate;
     if ($c_id != (int) Configuration::get('PS_CURRENCY_DEFAULT')) {
         if ($to_currency) {
             $price *= $c_rate;
         } else {
             $price /= $c_rate;
         }
     }
     return $price;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:25,代码来源:Tools14.php

示例4: getPriceFilterSubQuery

    private static function getPriceFilterSubQuery($filterValue)
    {
        if (version_compare(_PS_VERSION_, '1.5', '>')) {
            $idCurrency = (int) Context::getContext()->currency->id;
        } else {
            $idCurrency = (int) Currency::getCurrent()->id;
        }
        $priceFilterQuery = '';
        if (isset($filterValue) && $filterValue) {
            $priceFilterQuery = '
			INNER JOIN `' . _DB_PREFIX_ . 'layered_price_index` psi ON (psi.id_product = p.id_product AND psi.id_currency = ' . (int) $idCurrency . '
			AND psi.price_min <= ' . (int) $filterValue[1] . ' AND psi.price_max >= ' . (int) $filterValue[0] . ') ';
        } else {
            $priceFilterQuery = '
			INNER JOIN `' . _DB_PREFIX_ . 'layered_price_index` psi 
			ON (psi.id_product = p.id_product AND psi.id_currency = ' . (int) $idCurrency . ') ';
        }
        return array('join' => $priceFilterQuery, 'select' => ', psi.price_min, psi.price_max');
    }
开发者ID:greench,项目名称:prestashop,代码行数:19,代码来源:blocklayered.php

示例5: convertPrice

 /**
  * Return price converted
  *
  * @param float $price Product price
  * @param object $currency Current currency object
  */
 public static function convertPrice($price, $currency = NULL)
 {
     if ($currency === NULL) {
         $currency = Currency::getCurrent();
     }
     $c_id = is_array($currency) ? $currency['id_currency'] : $currency->id;
     $c_rate = is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate;
     if ($c_id != intval(Configuration::get('PS_CURRENCY_DEFAULT'))) {
         $price *= $c_rate;
     }
     return $price;
 }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:18,代码来源:Tools.php

示例6: dirname

*  @copyright 2013 - 2014 PayPlug SAS
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PayPlug SAS
*/
require_once dirname(__FILE__) . './../../../../config/config.inc.php';
/** Call init.php to initialize context */
require_once dirname(__FILE__) . '/../../../../init.php';
require_once dirname(__FILE__) . '/../../classes/PayplugLock.php';
/** Tips to include class of module and backward_compatibility */
$payplug = Module::getInstanceByName('payplug');
/** Check PS_VERSION */
if (version_compare(_PS_VERSION_, '1.4', '<')) {
    return;
}
if (version_compare(_PS_VERSION_, '1.5', '<')) {
    $currency = Currency::getCurrent()->iso_code;
    $order_confirmation_url = 'order-confirmation.php?';
} else {
    $context = Context::getContext();
    $currency = $context->currency;
    $order_confirmation_url = 'index.php?controller=order-confirmation&';
}
if (!($cart_id = Tools::getValue('cartid'))) {
    Payplug::redirectForVersion('index.php?controller=order&step=1');
}
$cart = new Cart($cart_id);
/**
 * If no current cart, redirect to order page
 */
if (!$cart->id) {
    Payplug::redirectForVersion('index.php?controller=order&step=1');
开发者ID:nilleroux,项目名称:payplug,代码行数:31,代码来源:validation.php

示例7: dirname

require_once dirname(__FILE__) . '/../../../../init.php';
/** Tips to include class of module and backward_compatibility */
$payplug = Module::getInstanceByName('payplug');
/** Check PS_VERSION */
if (version_compare(_PS_VERSION_, '1.4', '<')) {
    return;
}
/**
 * Check currency used
 */
$context = Context::getContext();
$cookie = $context->cookie;
$result_currency = array();
$cart = $context->cart;
if (version_compare(_PS_VERSION_, '1.5', '<')) {
    $result_currency['iso_code'] = Currency::getCurrent()->iso_code;
} else {
    $currency = $cart->id_currency;
    $result_currency = Currency::getCurrency($currency);
}
$supported_currencies = explode(';', Configuration::get('PAYPLUG_MODULE_CURRENCIES'));
if (!in_array($result_currency['iso_code'], $supported_currencies)) {
    return false;
}
/**
 *  Check amount
 */
$amount = $context->cart->getOrderTotal(true, Cart::BOTH) * 100;
if ($amount < Configuration::get('PAYPLUG_MODULE_MIN_AMOUNT') * 100 || $amount > Configuration::get('PAYPLUG_MODULE_MAX_AMOUNT') * 100) {
    return false;
}
开发者ID:apourchoux,项目名称:payplug,代码行数:31,代码来源:payment.php

示例8: makeLeftJoinWhereCriterion

    public static function makeLeftJoinWhereCriterion($fromMethod, $search, $id_lang, $selected_criterion, $selected_criteria_groups_type = array(), $current_id_criterion_group = false, $is_attribute_group = false, $id_currency = false, $id_country = false, $id_group = false, $include_price_table = false, $include_product_table = false, $group_type = false, $criterion_groups = array())
    {
        if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
            $context = Context::getContext();
            if (!$id_currency) {
                $id_currency = $context->currency->id;
            }
        } else {
            if (!$id_currency) {
                $id_currency = Currency::getCurrent()->id;
            }
        }
        $join_criterion_tables = array();
        $join_criterion = array();
        $count_criterion = array();
        $where_criterion = array();
        $where_qty = array();
        $field_select = array();
        $attribute_selected = false;
        $lastAttributeCombinationTableId = false;
        $stock_management = (int) Configuration::get('PS_STOCK_MANAGEMENT') ? true : false;
        if (!$stock_management) {
            $search['search_on_stock'] = false;
        }
        if ($group_type == 'stock' && $stock_management) {
            $strict_stock = true;
        } else {
            $strict_stock = false;
        }
        if ($stock_management && AdvancedSearchCoreClass::_isFilledArray($selected_criterion) && AdvancedSearchCoreClass::_isFilledArray($criterion_groups)) {
            foreach ($selected_criterion as $id_criterion_group_tmp => $id_criterion_tmp) {
                foreach ($criterion_groups as $criterion_group) {
                    if ($criterion_group['id_criterion_group'] == $id_criterion_group_tmp && $criterion_group['criterion_group_type'] == 'stock') {
                        $search['search_on_stock'] = true;
                        $strict_stock = true;
                        break;
                    }
                }
            }
        }
        $having = array();
        $where_price_range = array();
        if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
            $table_stock_index = 0;
        }
        $idSelectedCriteria = implode('-', self::array_values_recursive($selected_criterion));
        $cacheKey = sha1($fromMethod . $search['id_search'] . $idSelectedCriteria . '-' . implode('-', array_keys($selected_criterion)) . '-' . (int) $current_id_criterion_group . (int) $include_price_table . (int) $include_product_table . (int) $id_lang . (int) $is_attribute_group . (int) $group_type . (int) $strict_stock);
        if (isset(self::$_cacheLeftJoinWhereCriterion[$cacheKey])) {
            return self::$_cacheLeftJoinWhereCriterion[$cacheKey];
        }
        if ($group_type && !$include_product_table && $search['display_empty_criteria']) {
            $make_union = true;
        } else {
            $make_union = false;
        }
        $price_is_included = false;
        if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
            $join_criterion[] = 'JOIN `' . _DB_PREFIX_ . 'product_shop` ps ON (' . (AdvancedSearchCoreClass::_isFilledArray(PM_AdvancedSearch4::$productFilterList) ? ' ps.`id_product` IN (' . implode(',', PM_AdvancedSearch4::$productFilterList) . ') AND ' : '') . 'ps.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ') AND ps.`id_product` = acp.`id_product`)';
            $join_criterion_tables[] = 'ps';
        }
        if (AdvancedSearchCoreClass::_isFilledArray($selected_criterion)) {
            $price_is_included = false;
            $attribute_qty_compare_on_join = array();
            $now = date('Y-m-d H:i:s');
            foreach ($selected_criterion as $id_criterion_group => $id_criterion) {
                if ($selected_criteria_groups_type[$id_criterion_group]['criterion_group_type'] == 'stock') {
                    $strict_stock = true;
                    continue;
                }
                $join_criterion_table = false;
                $join_price_table = false;
                $where_join = array();
                $where_single_value_range = array();
                $where_translatable_value_range = array();
                if (isset($selected_criteria_groups_type[$id_criterion_group]) && ($selected_criteria_groups_type[$id_criterion_group]['display_type'] == 5 || $selected_criteria_groups_type[$id_criterion_group]['range'])) {
                    $id_currency_default = Configuration::get('PS_CURRENCY_DEFAULT');
                    if ($id_currency != $id_currency_default) {
                        $currency = new Currency($id_currency);
                        $conversion_rate = $currency->conversion_rate;
                    } else {
                        $conversion_rate = 0;
                    }
                    $where_price_criterion = array();
                    foreach ($id_criterion as $range) {
                        $range = explode('-', $range);
                        $original_range = $range;
                        if ($conversion_rate > 0) {
                            $range[0] = $range[0] / $conversion_rate;
                            if (isset($range[1])) {
                                $range[1] = $range[1] / $conversion_rate;
                            }
                        }
                        if (in_array($selected_criteria_groups_type[$id_criterion_group]['criterion_group_type'], array('weight', 'width', 'height', 'depth'))) {
                            $where_single_value_range[] = 'ROUND(ac' . (int) $id_criterion_group . '.`single_value`,5) >= ROUND("' . $range[0] . '",5)' . (isset($range[1]) && $range[1] ? ' AND ROUND(ac' . (int) $id_criterion_group . '.`single_value`,5) <= ROUND("' . $range[1] . '",5)' : '');
                        } elseif ($selected_criteria_groups_type[$id_criterion_group]['criterion_group_type'] == 'price') {
                            $price_is_included = true;
                            list($taxConversion, $taxConversionForReduction, $specificPriceCondition, $specificPriceGroupCondition) = self::getPriceRangeConditions($id_group);
                            $specificPriceCondition .= $specificPriceGroupCondition;
                            $priceMinCondition = '
                            IF(app.`is_specific` = 1 AND app.`id_currency` IN (0, ' . $id_currency . '),
//.........这里部分代码省略.........
开发者ID:acreno,项目名称:pm-ps,代码行数:101,代码来源:AdvancedSearchClass.php

示例9: getLocalCodeForSimplePath

 private function getLocalCodeForSimplePath()
 {
     $currency = Currency::getCurrent();
     if ($currency->iso_code == 'EUR') {
         return 'EUR';
     } elseif ($currency->iso_code == 'GBP') {
         return 'GBP';
     } elseif ($currency->iso_code == 'USD') {
         return 'USD';
     }
     return 'USD';
 }
开发者ID:paeddl,项目名称:amzpayments-1,代码行数:12,代码来源:amzpayments.php

示例10: convertPrice

 /**
  * Return price converted
  *
  * @param float $price Product price
  * @param object $currency Current currency object
  * @param boolean $to_currency convert to currency or from currency to default currency
  */
 public static function convertPrice($price, $currency = null, $to_currency = true)
 {
     if ($currency === null) {
         $currency = Currency::getCurrent();
     } elseif (is_numeric($currency)) {
         $currency = Currency::getCurrencyInstance($currency);
     }
     if (isset($currency->id)) {
         $c_id = $currency->id;
         $c_rate = $currency->conversion_rate;
     } else {
         $c_id = $currency['id_currency'];
         $c_rate = $currency['conversion_rate'];
     }
     if ($c_id != (int) _PS_CURRENCY_DEFAULT_) {
         $price = $to_currency ? $price * $c_rate : $price / $c_rate;
     }
     return $price;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:26,代码来源:Tools.php


注:本文中的Currency::getCurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。