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


PHP Currency::getCurrency方法代码示例

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


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

示例1: init

 /**
  * Initialize order controller
  * @see FrontController::init()
  */
 public function init()
 {
     global $orderTotal;
     parent::init();
     $this->step = (int) Tools::getValue('step');
     if (!$this->nbProducts) {
         $this->step = -1;
     }
     // If some products have disappear
     if (!$this->context->cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your cart is no longer available in this quantity, you cannot proceed with your order.');
     }
     // Check minimal amount
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     $orderTotal = $this->context->cart->getOrderTotal();
     $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step != -1) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'), Tools::displayPrice($minimal_purchase, $currency));
     }
     if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3))) {
         Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, 'back=' . $this->context->link->getPageLink('order', true, (int) $this->context->language->id, 'step=' . $this->step . '&multi-shipping=' . (int) Tools::getValue('multi-shipping')) . '&multi-shipping=' . (int) Tools::getValue('multi-shipping')));
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     if ($this->context->customer->id) {
         $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
     } else {
         $this->context->smarty->assign('address_list', array());
     }
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:39,代码来源:OrderController.php

示例2: postProcess

 public function postProcess()
 {
     $sid = Configuration::get('TWOCHECKOUTPP_SID');
     $secret_word = Configuration::get('TWOCHECKOUTPP_SECRET');
     $credit_card_processed = $_REQUEST['credit_card_processed'];
     $order_number = $_REQUEST['order_number'];
     $cart_id = $_REQUEST['merchant_order_id'];
     $cart = new Cart($cart_id);
     $checkout = new twocheckoutpp();
     if (Configuration::get('TWOCHECKOUTPP_CURRENCY') > 0) {
         $amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
         $currency_from = Currency::getCurrency($cart->id_currency);
         $currency_to = Currency::getCurrency(Configuration::get('TWOCHECKOUTPP_CURRENCY'));
         $amount = Tools::ps_round($amount / $currency_from['conversion_rate'], 2);
         $total = number_format(Tools::ps_round($amount *= $currency_to['conversion_rate'], 2), 2, '.', '');
     } else {
         $total = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
     }
     //Check the hash
     $compare_string = $secret_word . $sid . $order_number . $total;
     $compare_hash1 = strtoupper(md5($compare_string));
     $compare_hash2 = $_REQUEST['key'];
     if ($compare_hash1 == $compare_hash2) {
         $customer = new Customer($cart->id_customer);
         $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
         $checkout->validateOrder($cart_id, _PS_OS_PAYMENT_, $total, $checkout->displayName, '', array(), NULL, false, $customer->secure_key);
         $order = new Order($checkout->currentOrder);
         Tools::redirect('index.php?controller=order-confirmation&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . $checkout->currentOrder);
     } else {
         echo 'Hash Mismatch! Please contact the seller directly for assistance.</br>';
         echo 'Total: ' . $total . '</br>';
         echo '2CO Total: ' . $_REQUEST['total'];
     }
 }
开发者ID:stefanikolov,项目名称:prestashop-2checkout-api,代码行数:34,代码来源:validation.php

示例3: preProcess

 public function preProcess()
 {
     global $isVirtualCart, $orderTotal;
     parent::preProcess();
     /* If some products have disappear */
     if (!self::$cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your cart is no longer available for this quantity, you cannot proceed with your order.');
     }
     /* Check minimal amount */
     $currency = Currency::getCurrency((int) self::$cart->id_currency);
     $orderTotal = self::$cart->getOrderTotal();
     $minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if (self::$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase && $this->step != -1) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('A minimum purchase total of') . ' ' . Tools::displayPrice($minimalPurchase, $currency) . ' ' . Tools::displayError('is required in order to validate your order.');
     }
     if (!self::$cookie->isLogged(true) and in_array($this->step, array(1, 2, 3))) {
         Tools::redirect('authentication.php?back=' . urlencode('order.php?step=' . $this->step));
     }
     if ($this->nbProducts) {
         self::$smarty->assign('virtual_cart', $isVirtualCart);
     }
     // Update carrier selected on preProccess in order to fix a bug of
     // block cart when it's hooked on leftcolumn
     if ($this->step == 3 && Tools::isSubmit('processCarrier')) {
         $this->processCarrier();
     }
 }
开发者ID:ricardo-rdfs,项目名称:Portal-BIP,代码行数:29,代码来源:OrderController.php

示例4: validCurrency

 public static function validCurrency($id_currency)
 {
     $ret_valid_currency = null;
     if ($id_currency <= 0 || (!($res_currency = Currency::getCurrency($id_currency)) || empty($res_currency))) {
         $ret_valid_currency['error'] = 'The selected currency is not valid';
     } else {
         $ret_valid_currency['currency_code'] = $res_currency['iso_code'];
     }
     return $ret_valid_currency;
 }
开发者ID:hjcalvo,项目名称:prestashop-taxamo-plugin,代码行数:10,代码来源:Tools.php

示例5: init

 /**
  * Initialize order controller
  * @see FrontController::init()
  */
 public function init()
 {
     global $orderTotal;
     parent::init();
     $this->step = (int) Tools::getValue('step');
     if (!$this->nbProducts) {
         $this->step = -1;
     }
     $product = $this->context->cart->checkQuantities(true);
     if ((int) ($id_product = $this->context->cart->checkProductsAccess())) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('An item in your cart is no longer available (%1s). You cannot proceed with your order.'), Product::getProductName((int) $id_product));
     }
     // If some products have disappear
     if (is_array($product)) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('An item (%1s) in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.'), $product['name']);
     }
     // Check minimal amount
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     $orderTotal = $this->context->cart->getOrderTotal();
     $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('A minimum purchase total of %1s (tax excl.) is required to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency));
     }
     if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3))) {
         $params = array();
         if ($this->step) {
             $params['step'] = (int) $this->step;
         }
         if ($multi = (int) Tools::getValue('multi-shipping')) {
             $params['multi-shipping'] = $multi;
         }
         $back_url = $this->context->link->getPageLink('order', true, (int) $this->context->language->id, $params);
         $params = array('back' => $back_url);
         if ($multi) {
             $params['multi-shipping'] = $multi;
         }
         if ($guest = (int) Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
             $params['display_guest_checkout'] = $guest;
         }
         Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, $params));
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     if ($this->context->customer->id) {
         $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
     } else {
         $this->context->smarty->assign('address_list', array());
     }
 }
开发者ID:ac3gam3r,项目名称:Maxokraft,代码行数:59,代码来源:OrderController.php

示例6: initContent

 public function initContent()
 {
     if (Tools::isSubmit('module') && Tools::getValue('controller') == 'payment') {
         $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
         $orderTotal = $this->context->cart->getOrderTotal();
         $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
         if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase) {
             Tools::redirect('index.php?controller=order&step=1');
         }
     }
     parent::initContent();
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:12,代码来源:ModuleFrontController.php

示例7: init

 /**
  * Initialize order controller
  * @see FrontController::init()
  */
 public function init()
 {
     global $orderTotal;
     parent::init();
     $this->step = (int) Tools::getValue('step');
     if (!$this->nbProducts) {
         $this->step = -1;
     }
     // If some products have disappear
     if (!$this->context->cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.');
     }
     // Check minimal amount
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     //Gelikon Стоимость товаров без доставки BEGIN
     $cart_products = $this->context->cart->getProducts();
     $products_total_wt = 0;
     if ($cart_products) {
         foreach ($cart_products as $cart_product) {
             $products_total_wt += $cart_product["total_wt"];
         }
     }
     $this->context->smarty->assign('products_total_wt', $products_total_wt);
     //Gelikon Стоимость товаров без доставки END
     $orderTotal = $this->context->cart->getOrderTotal();
     $this->context->smarty->assign('global_order_total', $orderTotal);
     $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency));
     }
     if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3))) {
         $back_url = $this->context->link->getPageLink('order', true, (int) $this->context->language->id, array('step' => $this->step, 'multi-shipping' => (int) Tools::getValue('multi-shipping')));
         $params = array('multi-shipping' => (int) Tools::getValue('multi-shipping'), 'display_guest_checkout' => (int) Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'back' => $back_url);
         Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, $params));
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     if ($this->context->customer->id) {
         $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
     } else {
         $this->context->smarty->assign('address_list', array());
     }
 }
开发者ID:,项目名称:,代码行数:52,代码来源:

示例8: preProcess

 public function preProcess()
 {
     global $isVirtualCart, $orderTotal;
     parent::preProcess();
     /* If some products have disappear */
     if (!self::$cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your shopping bag is no longer available for this quantity, please remove it to proceed.');
     }
     /* Check minimal amount */
     $currency = Currency::getCurrency((int) self::$cart->id_currency);
     $orderTotal = self::$cart->getOrderTotal();
     $minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if (self::$cart->getOrderTotal(false) < $minimalPurchase && $this->step != -1) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('A minimum purchase total of') . ' ' . Tools::displayPrice($minimalPurchase, $currency) . ' ' . Tools::displayError('is required in order to validate your order.');
     }
     if (!self::$cookie->isLogged(true) and in_array($this->step, array(1, 2, 3))) {
         Tools::redirect('authentication.php?back=' . urlencode('order.php?step=' . $this->step));
     }
     if ($this->nbProducts) {
         self::$smarty->assign('virtual_cart', $isVirtualCart);
     }
     $this->_addAddress($this->step);
     if (self::$cookie->isLogged(true)) {
         $reward_points = VBRewards::getCustomerPoints(self::$cookie->id_customer);
         $redemption_status = VBRewards::checkPointsValidity(self::$cookie->id_customer, 0, self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS));
         self::$smarty->assign('can_redeem_points', 1);
         self::$smarty->assign("redemption_status", $redemption_status);
         if ($redemption_status === CANNOT_REDEEM_COINS) {
             self::$smarty->assign('can_redeem_points', 0);
         } else {
             if ($redemption_status === INSUFFICIENT_VALID_ORDERS) {
                 self::$smarty->assign('redemption_status_message', 'Coins can be redeemed from second purchase onwards.');
             } else {
                 if ($redemption_status === MIN_CRITERIA_NOT_MET) {
                     self::$smarty->assign('redemption_status_message', 'Order value should be more than 100 USD to redeem coins');
                 }
             }
         }
         self::$smarty->assign('redeem_points', (int) self::$cart->getPoints());
         self::$smarty->assign('balance_points', $reward_points);
         if ($reward_points - (int) self::$cart->getPoints() > 0) {
             self::$smarty->assign('balance_cash', (int) self::$cart->getPointsDiscounts($reward_points - (int) self::$cart->getPoints()));
         }
     }
 }
开发者ID:priyankajsr19,项目名称:shalu,代码行数:47,代码来源:OrderController.php

示例9: hookBackOfficeHome

    public function hookBackOfficeHome($params)
    {
        global $cookie;
        $this->_postProcess();
        $currency = Currency::getCurrency(intval(Configuration::get('PS_CURRENCY_DEFAULT')));
        $results = $this->getResults();
        $employee = new Employee(intval($cookie->id_employee));
        $id_tab_stats = Tab::getIdFromClassName('AdminStats');
        $access = Profile::getProfileAccess($employee->id_profile, $id_tab_stats);
        if (!$access['view']) {
            return '';
        }
        $this->_html = '
		<fieldset style="width:520px;">
			<legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Statistics') . '</legend>
			<div style="float:left;width:240px;text-align:center">
				<div style="float:left;width:120px;text-align:center">
					<center><p style="font-weight:bold;height:80px;width:100px;text-align:center;background-image:url(\'' . __PS_BASE_URI__ . 'modules/statshome/square1.gif\')">
						<br /><br />' . Tools::displayPrice($results['total_sales'], $currency) . '
					</p></center>
					<p>' . $this->l('of sales') . '</p>
					<center><p style="font-weight:bold;height:80px;width:100px;text-align:center;background-image:url(\'' . __PS_BASE_URI__ . 'modules/statshome/square3.gif\')">
						<br /><br />' . intval($results['total_registrations']) . '
					</p></center>
					<p>' . ($results['total_registrations'] != 1 ? $this->l('registrations') : $this->l('registration')) . '</p>
				</div>
				<div style="float:left;width:120px;text-align:center">
					<center><p style="font-weight:bold;height:80px;width:100px;text-align:center;background-image:url(\'' . __PS_BASE_URI__ . 'modules/statshome/square2.gif\')">
						<br /><br />' . intval($results['total_orders']) . '
					</p></center>
					<p>' . ($results['total_orders'] != 1 ? $this->l('orders placed') : $this->l('order placed')) . '</p>
					<center><p style="font-weight:bold;height:80px;width:100px;text-align:center;background-image:url(\'' . __PS_BASE_URI__ . 'modules/statshome/square4.gif\')">
						<br /><br />' . intval($results['total_viewed']) . '
					</p></center>
					<p>' . ($results['total_viewed'] != 1 ? $this->l('product pages viewed') : $this->l('product page viewed')) . '</p>
				</div>
			</div>
			<div style="float:right;text-align:right;width:240px">';
        include_once dirname(__FILE__) . '/../..' . $this->_adminPath . '/tabs/AdminStats.php';
        $this->_html .= AdminStatsTab::displayCalendarStatic(array('Calendar' => $this->l('Calendar'), 'Day' => $this->l('Day'), 'Month' => $this->l('Month'), 'Year' => $this->l('Year')));
        $this->_html .= '<div class="space"></div>
				<p style=" font-weight: bold ">' . $this->l('Visitors online now:') . ' ' . intval($this->getVisitorsNow()) . '</p>
			</div>
		</fieldset>
		<div class="clear space"><br /><br /></div>';
        return $this->_html;
    }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:47,代码来源:statshome.php

示例10: getTableRecentOrders

 public function getTableRecentOrders()
 {
     $header = array(array('title' => $this->l('Customer Name'), 'class' => 'text-left'), array('title' => $this->l('Products'), 'class' => 'text-center'), array('title' => $this->l('Total'), 'class' => 'text-center'), array('title' => $this->l('Date'), 'class' => 'text-center'), array('title' => $this->l('Action'), 'class' => 'text-center'));
     $orders = Order::getOrdersWithInformations((int) Configuration::get('DASHPRODUCT_NBR_SHOW_LAST_ORDER', 10));
     $body = array();
     foreach ($orders as $order) {
         $currency = Currency::getCurrency((int) $order['id_currency']);
         $tr = array();
         $tr[] = array('id' => 'firstname_lastname', 'value' => Tools::htmlentitiesUTF8($order['firstname']) . ' ' . Tools::htmlentitiesUTF8($order['lastname']), 'class' => 'text-left');
         $tr[] = array('id' => 'state_name', 'value' => count(OrderDetail::getList((int) $order['id_order'])), 'class' => 'text-center');
         $tr[] = array('id' => 'total_paid', 'value' => Tools::displayPrice((double) $order['total_paid'], $currency), 'class' => 'text-center', 'wrapper_start' => '<span class="badge">', 'wrapper_end' => '<span>');
         $tr[] = array('id' => 'date_add', 'value' => Tools::displayDate($order['date_add']), 'class' => 'text-center');
         $tr[] = array('id' => 'details', 'value' => $this->l('Details'), 'class' => 'text-right', 'wrapper_start' => '<a class="btn btn-default" href="index.php?tab=AdminOrders&id_order=' . (int) $order['id_order'] . '&vieworder&token=' . Tools::getAdminTokenLite('AdminOrders') . '" title="' . $this->l('Details') . '"><i class="icon-search"></i>', 'wrapper_end' => '</a>');
         $body[] = $tr;
     }
     return array('header' => $header, 'body' => $body);
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:17,代码来源:dashproducts.php

示例11: preProcess

 public function preProcess()
 {
     global $isVirtualCart, $orderTotal;
     parent::preProcess();
     /* If some products have disappear */
     if (!self::$cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your cart is no longer available for this quantity, you cannot proceed with your order.');
     }
     /* Check minimal amount */
     $currency = Currency::getCurrency((int) self::$cart->id_currency);
     $orderTotal = self::$cart->getOrderTotal();
     $minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($orderTotal < $minimalPurchase) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('A minimum purchase total of') . ' ' . Tools::displayPrice($minimalPurchase, $currency) . ' ' . Tools::displayError('is required in order to validate your order.');
     }
     if (!self::$cookie->isLogged(true) and in_array($this->step, array(1, 2, 3))) {
         Tools::redirect('authentication.php?back=order.php?step=' . $this->step);
     }
     if ($this->nbProducts) {
         self::$smarty->assign('virtual_cart', $isVirtualCart);
     }
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:24,代码来源:OrderController.php

示例12: execPayment

 function execPayment($cart)
 {
     $delivery = new Address(intval($cart->id_address_delivery));
     $invoice = new Address(intval($cart->id_address_invoice));
     $customer = new Customer(intval($cart->id_customer));
     global $cookie, $smarty;
     //Verify currencies and display payment form
     $cart_details = $cart->getSummaryDetails(null, true);
     $currencies = Currency::getCurrencies();
     $authorized_currencies = array_flip(explode(',', $this->currencies));
     $currencies_used = array();
     foreach ($currencies as $key => $currency) {
         if (isset($authorized_currencies[$currency['id_currency']])) {
             $currencies_used[] = $currencies[$key];
         }
     }
     $order_currency = '';
     foreach ($currencies_used as $key => $currency) {
         if ($currency['id_currency'] == $cart->id_currency) {
             $order_currency = $currency['iso_code'];
         }
     }
     $products = $cart->getProducts();
     foreach ($products as $key => $product) {
         $products[$key]['name'] = str_replace('"', '\'', $product['name']);
         $products[$key]['name'] = htmlentities(utf8_decode($product['name']));
     }
     $discounts = $cart_details['discounts'];
     $carrier = $cart_details['carrier'];
     if (_PS_VERSION_ < '1.5') {
         $shipping_cost = $cart_details['total_shipping_tax_exc'];
     } else {
         $shipping_cost = $this->context->cart->getTotalShippingCost();
     }
     $CheckoutUrl = 'https://www.2checkout.com/checkout/purchase';
     $sid = Configuration::get('TWOCHECKOUTPP_SID');
     $amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
     $cart_order_id = $cart->id;
     $email = $customer->email;
     $secure_key = $customer->secure_key;
     $demo = "N";
     // Change to "Y" for demo mode
     $outside_state = "XX";
     // This will pre-select Outside USA and Canada, if state does not exist
     // Invoice Parameters
     $card_holder_name = $invoice->firstname . ' ' . $invoice->lastname;
     $street_address = $invoice->address1;
     $street_address2 = $invoice->address2;
     $phone = $invoice->phone;
     $city = $invoice->city;
     $state = (Validate::isLoadedObject($invoice) and $invoice->id_state) ? new State(intval($invoice->id_state)) : false;
     $zip = $invoice->postcode;
     $country = $invoice->country;
     // Shipping Parameters
     $ship_name = $delivery->firstname . ' ' . $invoice->lastname;
     $ship_street_address = $delivery->address1;
     $ship_street_address2 = $delivery->address2;
     $ship_city = $delivery->city;
     $ship_state = (Validate::isLoadedObject($delivery) and $delivery->id_state) ? new State(intval($delivery->id_state)) : false;
     $ship_zip = $delivery->postcode;
     $ship_country = $delivery->country;
     $check_total = $this->checkTotal($cart);
     if (Configuration::get('TWOCHECKOUTPP_CURRENCY') > 0) {
         $currency_from = Currency::getCurrency($cart->id_currency);
         $currency_to = Currency::getCurrency(Configuration::get('TWOCHECKOUTPP_CURRENCY'));
         $amount = Tools::ps_round($amount / $currency_from['conversion_rate'], 2);
         $total = Tools::ps_round($amount *= $currency_to['conversion_rate'], 2);
         $order_currency = $currency_to['iso_code'];
         $override_currency = $currency_to;
     } else {
         $total = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
         $override_currency = 0;
     }
     $cart = new Cart($cookie->id_cart);
     $address = new Address($cart->id_address_delivery, intval($cookie->id_lang));
     $state = State::getNameById($address->id_state);
     $state = $state ? '(' . $state . ')' : '';
     $str_address = ($address->company ? $address->company . '<br>' : '') . $address->firstname . ' ' . $address->lastname . '<br>' . $address->address1 . '<br>' . ($address->address2 ? $address->address2 . '<br>' : '') . $address->postcode . ' ' . $address->city . '<br>' . $address->country . $state;
     $carrier = Carrier::getCarriers(intval($cookie->id_lang));
     if ($carrier) {
         foreach ($carrier as $c) {
             if ($cart->id_carrier == $c['id_carrier']) {
                 $carrier_name = $c['name'];
                 break;
             }
         }
     }
     $params = array();
     $params['sid'] = $sid;
     $params['paypal_direct'] = 'Y';
     $params['currency_code'] = $order_currency;
     $params['return_url'] = $this->context->link->getPageLink('order', true, NULL, "step=3");
     $params['merchant_order_id'] = $cart_order_id;
     $params['email'] = $email;
     $params['phone'] = $phone;
     $params['card_holder_name'] = $card_holder_name;
     $params['street_address'] = $street_address;
     $params['street_address2'] = $street_address2;
     $params['city'] = $city;
     $params['state'] = $state;
//.........这里部分代码省略.........
开发者ID:stefanikolov,项目名称:prestashop-2checkout-api,代码行数:101,代码来源:twocheckoutpp.php

示例13: calculateOrder

 /**
  * Calculate a forex order
  * @param $currencyCode
  * @param null $currencyAmount
  * @param null $payableAmount
  * @param bool $applyDiscount
  * @return bool|Order
  */
 public static function calculateOrder($currencyCode, $currencyAmount = null, $payableAmount = null, $applyDiscount = false)
 {
     if (!isset($currencyAmount) && !isset($payableAmount)) {
         return false;
     }
     $currency = Currency::getCurrency($currencyCode);
     if (!$currency) {
         return false;
     }
     $order = new self();
     $order->currency_code = $currencyCode;
     $order->exchange_rate = $currency->exchange_rate;
     $order->surcharge_percentage = $currency->currency_surcharge;
     $order->discount_amount = 0;
     $order->discount_percentage = 0;
     if (!empty($currencyAmount)) {
         $order->currency_amount = $currencyAmount;
         // Calculate the initial currency conversion before surcharges and discounts
         $order->payable_amount = $currencyAmount * (1 / $currency->exchange_rate);
         // Calculate the surcharge
         $order->surcharge_amount = $order->payable_amount / 100 * $order->surcharge_percentage;
         // Add the surcharge to the amount payable
         $order->payable_amount += $order->surcharge_amount;
         $order->payable_amount = round($order->payable_amount, 2, PHP_ROUND_HALF_UP);
     } else {
         $order->payable_amount = $payableAmount;
         $order->surcharge_amount = $payableAmount / (100 + $order->surcharge_percentage) * $order->surcharge_percentage;
         $order->currency_amount = $payableAmount - $order->surcharge_amount;
         $order->currency_amount = $order->currency_amount * $currency->exchange_rate;
     }
     // Apply the discount if one is available
     if ($applyDiscount && $currency->currency_discount > 0) {
         $order->discount_percentage = $currency->currency_discount;
         $order->discount_amount = $order->payable_amount / 100 * $currency->currency_discount;
         $order->payable_amount -= $order->discount_amount;
         $order->payable_amount = round($order->payable_amount, 2, PHP_ROUND_HALF_UP);
     }
     $order->zar_amount = self::calculateRandValue($order->payable_amount);
     $order->currency_amount = self::formatValue($order->currency_amount);
     $order->surcharge_amount = self::formatValue($order->surcharge_amount);
     $order->payable_amount = self::formatValue($order->payable_amount);
     $order->zar_amount = self::formatValue($order->zar_amount);
     return $order;
 }
开发者ID:ashleykleynhans,项目名称:forex,代码行数:52,代码来源:Order.php

示例14: postProcess

 /**
  * AdminController::postProcess() override
  * @see AdminController::postProcess()
  */
 public function postProcess()
 {
     $this->is_editing_order = false;
     // Checks access
     if (Tools::isSubmit('submitAddsupply_order') && !($this->tabAccess['add'] === '1')) {
         $this->errors[] = Tools::displayError('You do not have permission to add a supply order.');
     }
     if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && !($this->tabAccess['edit'] === '1')) {
         $this->errors[] = Tools::displayError('You do not have permission to edit an order.');
     }
     // Trick to use both Supply Order as template and actual orders
     if (Tools::isSubmit('is_template')) {
         $_GET['mod'] = 'template';
     }
     // checks if supply order reference is unique
     if (Tools::isSubmit('reference')) {
         // gets the reference
         $ref = pSQL(Tools::getValue('reference'));
         if (Tools::getValue('id_supply_order') != 0 && SupplyOrder::getReferenceById((int) Tools::getValue('id_supply_order')) != $ref) {
             if ((int) SupplyOrder::exists($ref) != 0) {
                 $this->errors[] = Tools::displayError('The reference has to be unique.');
             }
         } elseif (Tools::getValue('id_supply_order') == 0 && (int) SupplyOrder::exists($ref) != 0) {
             $this->errors[] = Tools::displayError('The reference has to be unique.');
         }
     }
     if ($this->errors) {
         return;
     }
     // Global checks when add / update a supply order
     if (Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitAddsupply_orderAndStay')) {
         $this->action = 'save';
         $this->is_editing_order = true;
         // get supplier ID
         $id_supplier = (int) Tools::getValue('id_supplier', 0);
         if ($id_supplier <= 0 || !Supplier::supplierExists($id_supplier)) {
             $this->errors[] = Tools::displayError('The selected supplier is not valid.');
         }
         // get warehouse id
         $id_warehouse = (int) Tools::getValue('id_warehouse', 0);
         if ($id_warehouse <= 0 || !Warehouse::exists($id_warehouse)) {
             $this->errors[] = Tools::displayError('The selected warehouse is not valid.');
         }
         // get currency id
         $id_currency = (int) Tools::getValue('id_currency', 0);
         if ($id_currency <= 0 || (!($result = Currency::getCurrency($id_currency)) || empty($result))) {
             $this->errors[] = Tools::displayError('The selected currency is not valid.');
         }
         // get delivery date
         if (Tools::getValue('mod') != 'template' && strtotime(Tools::getValue('date_delivery_expected')) <= strtotime('-1 day')) {
             $this->errors[] = Tools::displayError('The specified date cannot be in the past.');
         }
         // gets threshold
         $quantity_threshold = Tools::getValue('load_products');
         if (is_numeric($quantity_threshold)) {
             $quantity_threshold = (int) $quantity_threshold;
         } else {
             $quantity_threshold = null;
         }
         if (!count($this->errors)) {
             // forces date for templates
             if (Tools::isSubmit('is_template') && !Tools::getValue('date_delivery_expected')) {
                 $_POST['date_delivery_expected'] = date('Y-m-d h:i:s');
             }
             // specify initial state
             $_POST['id_supply_order_state'] = 1;
             //defaut creation state
             // specify global reference currency
             $_POST['id_ref_currency'] = Currency::getDefaultCurrency()->id;
             // specify supplier name
             $_POST['supplier_name'] = Supplier::getNameById($id_supplier);
             //specific discount check
             $_POST['discount_rate'] = (double) str_replace(array(' ', ','), array('', '.'), Tools::getValue('discount_rate', 0));
         }
         // manage each associated product
         $this->manageOrderProducts();
         // if the threshold is defined and we are saving the order
         if (Tools::isSubmit('submitAddsupply_order') && Validate::isInt($quantity_threshold)) {
             $this->loadProducts((int) $quantity_threshold);
         }
     }
     // Manage state change
     if (Tools::isSubmit('submitChangestate') && Tools::isSubmit('id_supply_order') && Tools::isSubmit('id_supply_order_state')) {
         if ($this->tabAccess['edit'] != '1') {
             $this->errors[] = Tools::displayError('You do not have permission to change the order status.');
         }
         // get state ID
         $id_state = (int) Tools::getValue('id_supply_order_state', 0);
         if ($id_state <= 0) {
             $this->errors[] = Tools::displayError('The selected supply order status is not valid.');
         }
         // get supply order ID
         $id_supply_order = (int) Tools::getValue('id_supply_order', 0);
         if ($id_supply_order <= 0) {
             $this->errors[] = Tools::displayError('The supply order ID is not valid.');
         }
//.........这里部分代码省略.........
开发者ID:zangles,项目名称:lennyba,代码行数:101,代码来源:AdminSupplyOrdersController.php

示例15: _getPaymentMethods

 protected function _getPaymentMethods()
 {
     if (!$this->isOpcModuleActive()) {
         return parent::_getPaymentMethods();
     }
     if ($this->context->cart->OrderExists()) {
         $ret = '<p class="warning">' . Tools::displayError('Error: this order has already been validated') . '</p>';
         return array("orig_hook" => $ret, "parsed_content" => $ret);
     }
     $ret = "";
     $address_delivery = new Address($this->context->cart->id_address_delivery);
     $address_invoice = $this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice ? $address_delivery : new Address($this->context->cart->id_address_invoice);
     if (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice || !Validate::isLoadedObject($address_delivery) || !Validate::isLoadedObject($address_invoice) || $address_invoice->deleted || $address_delivery->deleted) {
         $ret = '<p class="warning">' . Tools::displayError('Error: please choose an address') . '</p>';
     }
     if (count($this->context->cart->getDeliveryOptionList()) == 0 && !$this->context->cart->isVirtualCart()) {
         if ($this->context->cart->isMultiAddressDelivery()) {
             $ret .= '<p class="warning">' . Tools::displayError('Error: There are no carriers available that deliver to some of your addresses') . '</p>';
         } else {
             $ret .= '<p class="warning">' . Tools::displayError('Error: There are no carriers available that deliver to this address') . '</p>';
         }
     }
     if (!$this->context->cart->getDeliveryOption(null, false) && !$this->context->cart->isVirtualCart()) {
         $ret = '<p class="warning">' . Tools::displayError('Error: please choose a carrier') . '</p>';
     }
     if (!$this->context->cart->id_currency) {
         $ret .= '<p class="warning">' . Tools::displayError('Error: no currency has been selected') . '</p>';
     }
     if (!$this->context->cart->checkQuantities()) {
         $ret .= '<p class="warning">' . Tools::displayError('An item in your cart is no longer available, you cannot proceed with your order.') . '</p>';
     }
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     $minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) {
         $ret .= '<p class="warning">' . sprintf(Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'), Tools::displayPrice($minimalPurchase, $currency)) . '</p>';
     }
     if (trim($ret) != "") {
         return array("orig_hook" => $ret, "parsed_content" => $ret);
     }
     $opc_config = $this->context->smarty->tpl_vars["opc_config"]->value;
     $tmp_customer_id_1 = isset($opc_config) && isset($opc_config["payment_customer_id"]) ? intval($opc_config["payment_customer_id"]) : 0;
     $reset_id_customer = false;
     if (!$this->context->cookie->id_customer) {
         $simulated_customer_id = $tmp_customer_id_1 > 0 ? $tmp_customer_id_1 : Customer::getFirstCustomerId();
         $this->context->cookie->id_customer = $simulated_customer_id;
         $reset_id_customer = true;
         if (!$this->context->customer->id) {
             $this->context->customer->id = $simulated_customer_id;
         }
     }
     $orig_context_country = $this->context->country;
     if (isset($address_invoice) && $address_invoice != null) {
         $this->context->country = new Country($address_invoice->id_country);
     }
     if ($this->context->cart->getOrderTotal() <= 0) {
         $return = $this->context->smarty->fetch($this->opc_templates_path . '/free-order-payment.tpl');
     } else {
         $ship2pay_support = isset($opc_config) && isset($opc_config["ship2pay"]) && $opc_config["ship2pay"] == "1" ? true : false;
         if ($ship2pay_support) {
             $orig_id_carrier = $this->context->cart->id_carrier;
             $selected_carrier = Cart::desintifier($this->context->cart->simulateCarrierSelectedOutput());
             $selected_carrier = explode(",", $selected_carrier);
             $selected_carrier = $selected_carrier[0];
             $this->context->cart->id_carrier = $selected_carrier;
             $this->context->cart->update();
             $return = Hook::exec('displayPayment');
         } else {
             $return = Hook::exec('displayPayment');
         }
     }
     $this->context->country = $orig_context_country;
     # restore cookie's id_customer
     if ($reset_id_customer) {
         unset($this->context->cookie->id_customer);
         $this->context->customer->id = null;
     }
     # fix Moneybookers relative path to images
     $return = preg_replace('/src="modules\\//', 'src="' . __PS_BASE_URI__ . 'modules/', $return);
     # OPCKT fix Paypal relative path to redirect script
     $return = preg_replace('/href="modules\\//', 'href="' . __PS_BASE_URI__ . 'modules/', $return);
     if (!$return) {
         $ret = '<p class="warning">' . Tools::displayError('No payment method is available') . '</p>';
         return array("orig_hook" => $ret, "parsed_content" => $ret);
     }
     $parsed_content = "";
     $parse_payment_methods = isset($opc_config) && isset($opc_config["payment_radio_buttons"]) && $opc_config["payment_radio_buttons"] == "1" ? true : false;
     if ($parse_payment_methods) {
         $content = $return;
         $payment_methods = array();
         $i = 0;
         preg_match_all('/<a.*?>[^>]*?<img[^>]*?src="(.*?)".*?\\/?>(.*?)<\\/a>/ms', $content, $matches1, PREG_SET_ORDER);
         $tmp_return = preg_replace_callback('/(<(a))([^>]*?>[^>]*?<img.*?src)/ms', array($this, "_genPaymentModId"), $return);
         if ($tmp_return == NULL) {
             echo "ERRoR!";
         }
         if ($tmp_return != null) {
             // NULL can be returned on backtrace limit exhaustion
             $return = $tmp_return;
         }
         preg_match_all('/<input [^>]*?type="image".*?src="(.*?)".*?>.*?<span.*?>(.*?)<\\/span>/ms', $content, $matches2, PREG_SET_ORDER);
//.........这里部分代码省略.........
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:OrderOpcController.php


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