本文整理汇总了PHP中Tools::displayPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::displayPrice方法的具体用法?PHP Tools::displayPrice怎么用?PHP Tools::displayPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::displayPrice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayContent
public function displayContent($params)
{
$alias_shop = (int) Tools::getValue('ash');
if (!empty($alias_shop)) {
$_s = AphStore::getByAlias($alias_shop, Context::getContext()->language->id);
$id_shop = $_s['id_shop'];
} else {
$id_shop = (int) Tools::getValue('ids');
}
$shop = new AphStore($id_shop, Context::getContext()->language->id);
$this->nbOffers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay, true);
$this->pagination((int) $this->nbOffers);
// Pagination must be call after "getStoresByProduct"
$this->offerSort();
$id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
$offers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay);
foreach ($offers as &$offer) {
$offer = new AphOffer($offer['id_offer'], (int) Context::getContext()->language->id, (int) $id_shop);
$offer['price_from'] = Tools::displayPrice($offer->price_wt, $id_currency);
error_log($o->reduction . ' ' . $o->id);
$offer['new_price'] = $o->price_wt < 0 ? $o->reduction_type == 'percentage' ? '-' . intval(round($o->reduction)) . '%' : '-' . Tools::displayPrice($o['reduction'], (int) Context::getContext()->currency->id) : Tools::displayPrice($o->price_wt, (int) Context::getContext()->currency->id) . ' ';
$offer['url'] = Context::getContext()->link->getModuleLink('blockoffers', 'offer', array('aof' => $offer['link_rewrite'], 'ido' => $offer['id_offer']));
$offer['img_link_rewrite'] = Tools::link_rewrite($offer['legend']);
}
$this->context->smarty->assign(array('offers' => $offers, 'nb_offers' => $this->nbOffers));
$this->context->controller->addJS($this->_path . 'blockoffer.js');
return $this->display(__FILE__, 'blockoffers.tpl', $this->getCacheId());
}
示例2: convertAndFormatPrice
function convertAndFormatPrice($price, $currency = false)
{
if (!$currency) {
$currency = Currency::getCurrent();
}
return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
}
示例3: postProcess
/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == 'swipp') {
$authorized = true;
break;
}
}
if (!$authorized) {
die($this->module->l('This payment method is not available.', 'validation'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$currency = $this->context->currency;
$total = (double) $cart->getOrderTotal(true, Cart::BOTH);
$mailVars = array('{swipp_phone}' => Configuration::get('SWIPP_PHONE'), '{swipp_owner}' => Configuration::get('SWIPP_OWNER'), '{swipp_payment_dkk}' => Tools::displayPrice($this->module->__getPriceDkk($cart), (int) Currency::getIdByIsoCode('DKK')));
$this->module->validateOrder($cart->id, Configuration::get('SWIPP_PAYMENT_STATE'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
}
示例4: hookRightColumn
function hookRightColumn($params)
{
global $smarty, $category_path;
$category_path_ids = array();
foreach ($category_path as $cat) {
$category_path_ids[] = $cat['id_category'];
}
$currency = new Currency(intval($params['cookie']->id_currency));
$bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 25);
$best_sellers = array();
$nr = 0;
foreach ($bestsellers as $bestseller) {
if ($nr >= 5) {
break;
}
$display = false;
foreach (Product::getIndexedCategories($bestseller['id_product']) as $row) {
if (in_array($row['id_category'], $category_path_ids)) {
$display = true;
break;
}
}
if ($display) {
$bestseller['price'] = Tools::displayPrice(Product::getPriceStaticLC(intval($bestseller['id_product'])), $currency, false, false);
$best_sellers[] = $bestseller;
$nr += 1;
}
}
$smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'), 'static_token' => Tools::getToken(false)));
return $this->display(__FILE__, 'blockbestsellers.tpl');
}
示例5: displayContent
public function displayContent()
{
$id_order = (int) Tools::getValue('id_order');
$order = new Order($id_order);
$paypal_order = PayPalOrder::getOrderById($id_order);
if (defined("PAYPAL_FORCE_CURRENCY")) {
$currency = new Currency((int) $this->context->currency->id);
$paycurrency = new Currency(PAYPAL_FORCE_CURRENCY);
$currency_decimals = $paycurrency->decimals;
$paypal_order['total_paid'] = $paypal_order['total_paid'] / $currency->conversion_rate * $paycurrency->conversion_rate;
}
$price = Tools::displayPrice($paypal_order['total_paid'], $this->context->currency);
$order_state = new OrderState($id_order);
if ($order_state) {
$order_state_message = $order_state->template[$this->context->language->id];
}
if (!$order || !$order_state || isset($order_state_message) && $order_state_message == 'payment_error') {
$this->context->smarty->assign(array('logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => $price));
if (isset($order_state_message) && $order_state_message) {
$this->context->smarty->assign('message', $order_state_message);
}
$template = 'error.tpl';
} else {
$this->context->smarty->assign(array('order' => $paypal_order, 'price' => $price));
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($paypal_order['id_order'])));
}
$template = 'order-confirmation.tpl';
}
$this->context->smarty->assign('use_mobile', (bool) $this->paypal->useMobile());
echo $this->paypal->fetchTemplate($template);
}
示例6: initContent
public function initContent()
{
parent::initContent();
$this->paypal = new PayPal();
$this->context = Context::getContext();
$this->id_module = (int) Tools::getValue('id_module');
$this->id_order = (int) Tools::getValue('id_order');
$order = new Order($this->id_order);
$order_state = new OrderState($order->current_state);
$paypal_order = PayPalOrder::getOrderById($this->id_order);
if ($order_state->template[$this->context->language->id] == 'payment_error') {
$this->context->smarty->assign(array('message' => $order_state->name[$this->context->language->id], 'logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => Tools::displayPrice($paypal_order['total_paid'], $this->context->currency)));
return $this->setTemplate('error.tpl');
}
$order_currency = new Currency((int) $order->id_currency);
$display_currency = new Currency((int) $this->context->currency->id);
$price = Tools::convertPriceFull($paypal_order['total_paid'], $order_currency, $display_currency);
$this->context->smarty->assign(array('is_guest' => $this->context->customer->is_guest || $this->context->customer->id == false, 'order' => $paypal_order, 'price' => Tools::displayPrice($price, $this->context->currency->id), 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()));
if ($this->context->customer->is_guest || $this->context->customer->id == false) {
$this->context->smarty->assign(array('id_order' => (int) $this->id_order, 'id_order_formatted' => sprintf('#%06d', (int) $this->id_order), 'order_reference' => $order->reference));
/* If guest we clear the cookie for security reason */
$this->context->customer->mylogout();
}
if ($this->context->getMobileDevice() == true) {
$this->setTemplate('order-confirmation-mobile.tpl');
} else {
$this->setTemplate('order-confirmation.tpl');
}
}
示例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.');
}
// 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());
}
}
示例8: smartyAssigns
public function smartyAssigns(&$smarty, &$params)
{
global $errors, $cookie;
// Set currency
if (!intval($params['cart']->id_currency)) {
$currency = new Currency(intval($params['cookie']->id_currency));
} else {
$currency = new Currency(intval($params['cart']->id_currency));
}
if (!Validate::isLoadedObject($currency)) {
$currency = new Currency(intval(Configuration::get('PS_CURRENCY_DEFAULT')));
}
if ($params['cart']->id_customer) {
$customer = new Customer(intval($params['cart']->id_customer));
$taxCalculationMethod = Group::getPriceDisplayMethod(intval($customer->id_default_group));
} else {
$taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
}
$usetax = $taxCalculationMethod == PS_TAX_EXC ? false : true;
$products = $params['cart']->getProducts(true);
$nbTotalProducts = 0;
foreach ($products as $product) {
$nbTotalProducts += intval($product['cart_quantity']);
}
$wrappingCost = floatval($params['cart']->getOrderTotal($usetax, 6));
$smarty->assign(array('products' => $products, 'customizedDatas' => Product::getAllCustomizedDatas(intval($params['cart']->id)), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'discounts' => $params['cart']->getDiscounts(false, $usetax), 'nb_total_products' => intval($nbTotalProducts), 'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 5), $currency), 'show_wrapping' => $wrappingCost > 0 ? true : false, 'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency), 'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 4), $currency), 'total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax), $currency), 'id_carrier' => intval($params['cart']->id_carrier), 'ajax_allowed' => intval(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false));
if (sizeof($errors)) {
$smarty->assign('errors', $errors);
}
if (isset($cookie->ajax_blockcart_display)) {
$smarty->assign('colapseExpandStatus', $cookie->ajax_blockcart_display);
}
}
示例9: postProcess
public function postProcess()
{
// Check if cart exists and all fields are set
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
Tools::redirect('index.php?controller=order&step=1');
}
// Check if module is enabled
$authorized = false;
foreach (Module::getPaymentModules() as $module) {
if ($module['name'] == $this->module->name) {
$authorized = true;
}
}
if (!$authorized) {
die('This payment method is not available.');
}
// Check if customer exists
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
// Set datas
$currency = $this->context->currency;
$total = (double) $cart->getOrderTotal(true, Cart::BOTH);
$extra_vars = array('{total_to_pay}' => Tools::displayPrice($total), '{cheque_order}' => Configuration::get('MYMOD_CH_ORDER'), '{cheque_address}' => Configuration::get('MYMOD_CH_ADDRESS'), '{bankwire_details}' => Configuration::get('MYMOD_BA_DETAILS'), '{bankwire_owner}' => Configuration::get('MYMOD_BA_OWNER'));
// Validate order
$this->module->validateOrder($cart->id, Configuration::get('PS_OS_MYMOD_PAYMENT'), $total, $this->module->displayName, NULL, $extra_vars, (int) $currency->id, false, $customer->secure_key);
// Redirect on order confirmation page
Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
}
示例10: 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();
}
}
示例11: getData
public function getData()
{
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$this->query = 'SELECT SQL_CALC_FOUND_ROWS cr.code, ocr.name, COUNT(ocr.id_cart_rule) as total, ROUND(SUM(o.total_paid_real) / o.conversion_rate,2) as ca
FROM ' . _DB_PREFIX_ . 'order_cart_rule ocr
LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON o.id_order = ocr.id_order
LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule cr ON cr.id_cart_rule = ocr.id_cart_rule
WHERE o.valid = 1
' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
AND o.invoice_date BETWEEN ' . $this->getDate() . '
GROUP BY ocr.id_cart_rule';
if (Validate::IsName($this->_sort)) {
$this->query .= ' ORDER BY `' . bqSQL($this->_sort) . '`';
if (isset($this->_direction) && (Tools::strtoupper($this->_direction) == 'ASC' || Tools::strtoupper($this->_direction) == 'DESC')) {
$this->query .= ' ' . pSQL($this->_direction);
}
}
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit)) {
$this->query .= ' LIMIT ' . (int) $this->_start . ', ' . (int) $this->_limit;
}
$values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query);
foreach ($values as &$value) {
$value['ca'] = Tools::displayPrice($value['ca'], $currency);
}
$this->_values = $values;
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
}
示例12: displayContent
public function displayContent()
{
$id_order = (int) Tools::getValue('id_order');
$order = PayPalOrder::getOrderById($id_order);
$price = Tools::displayPrice($order['total_paid'], $this->context->currency);
$this->context->smarty->assign(array('order' => $order, 'price' => $price));
echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl');
}
示例13: displayContent
public function displayContent()
{
$order = PayPalOrder::getOrderById((int) Tools::getValue('id_order'));
$this->context->smarty->assign(array('order' => $order, 'price' => Tools::displayPrice($order['total_paid'], $this->context->currency), 'use_mobile' => $this->context->getMobileDevice()));
if (!$order) {
$this->context->smarty->assign('errors', array($this->paypal->l('Payment error')));
}
echo $this->paypal->fetchTemplate('/views/templates/front/', 'order-confirmation');
}
示例14: 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());
}
}
示例15: displayContent
public function displayContent()
{
$id_order = (int) Tools::getValue('id_order');
$order = PayPalOrder::getOrderById($id_order);
$price = Tools::displayPrice($order['total_paid'], $this->context->currency);
$this->context->smarty->assign(array('order' => $order, 'price' => $price));
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($id_order)));
}
echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl');
}