本文整理汇总了PHP中Tools::convertPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::convertPrice方法的具体用法?PHP Tools::convertPrice怎么用?PHP Tools::convertPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::convertPrice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
示例2: 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());
}
}
示例3: convertAndFormatPrice
function convertAndFormatPrice($price, $currency = false)
{
if (!$currency) {
$currency = Currency::getCurrent();
}
return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
}
示例4: assignContentVars
public function assignContentVars(&$params)
{
global $errors;
// Set currency
if ((int) $params['cart']->id_currency && (int) $params['cart']->id_currency != $this->context->currency->id) {
$currency = new Currency((int) $params['cart']->id_currency);
} else {
$currency = $this->context->currency;
}
if ($params['cart']->id_customer) {
$customer = new Customer((int) $params['cart']->id_customer);
$taxCalculationMethod = Group::getPriceDisplayMethod((int) $customer->id_default_group);
} else {
$taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
}
$useTax = !($taxCalculationMethod == PS_TAX_EXC);
$products = $params['cart']->getProducts(true);
$nbTotalProducts = 0;
foreach ($products as $product) {
$nbTotalProducts += (int) $product['cart_quantity'];
}
$cart_rules = $params['cart']->getCartRules();
$shipping_cost = Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING), $currency);
$shipping_cost_float = Tools::convertPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING), $currency);
$wrappingCost = (double) $params['cart']->getOrderTotal($useTax, Cart::ONLY_WRAPPING);
$totalToPay = $params['cart']->getOrderTotal($useTax);
if ($useTax && Configuration::get('PS_TAX_DISPLAY') == 1) {
$totalToPayWithoutTaxes = $params['cart']->getOrderTotal(false);
$this->smarty->assign('tax_cost', Tools::displayPrice($totalToPay - $totalToPayWithoutTaxes, $currency));
}
// The cart content is altered for display
foreach ($cart_rules as &$cart_rule) {
if ($cart_rule['free_shipping']) {
$shipping_cost = Tools::displayPrice(0, $currency);
$shipping_cost_float = 0;
$cart_rule['value_real'] -= Tools::convertPrice($params['cart']->getOrderTotal(true, Cart::ONLY_SHIPPING), $currency);
$cart_rule['value_tax_exc'] = Tools::convertPrice($params['cart']->getOrderTotal(false, Cart::ONLY_SHIPPING), $currency);
}
if ($cart_rule['gift_product']) {
foreach ($products as &$product) {
if ($product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute']) {
$product['total_wt'] = Tools::ps_round($product['total_wt'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
$product['total'] = Tools::ps_round($product['total'] - $product['price'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'] - $product['price'], (int) $currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
}
}
}
}
$this->smarty->assign(array('products' => $products, 'customizedDatas' => Product::getAllCustomizedDatas((int) $params['cart']->id), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'discounts' => $cart_rules, 'nb_total_products' => (int) $nbTotalProducts, 'shipping_cost' => $shipping_cost, 'shipping_cost_float' => $shipping_cost_float, 'show_wrapping' => $wrappingCost > 0 ? true : false, 'show_tax' => (int) (Configuration::get('PS_TAX_DISPLAY') == 1 && (int) Configuration::get('PS_TAX')), 'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency), 'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING), $currency), 'total' => Tools::displayPrice($totalToPay, $currency), 'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order', 'ajax_allowed' => (int) Configuration::get('PS_BLOCK_CART_AJAX') == 1 ? true : false, 'static_token' => Tools::getToken(false)));
if (count($errors)) {
$this->smarty->assign('errors', $errors);
}
if (isset($this->context->cookie->ajax_blockcart_display)) {
$this->smarty->assign('colapseExpandStatus', $this->context->cookie->ajax_blockcart_display);
}
}
示例5: getValue
public static function getValue($product_price, $id_discount_type, $value, $usetax = true, $taxrate = 1, $currency = NULL)
{
if ($id_discount_type == 1) {
$percentage = $value / 100;
return $percentage * floatval($product_price);
} elseif ($id_discount_type == 2) {
return !$usetax ? Tools::convertPrice($value, $currency) / (1 + $taxrate / 100) : Tools::convertPrice($value, $currency);
}
return 0;
}
示例6: 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());
}
}
示例7: 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();
}
示例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()));
}
}
}
示例9: assignPriceAndTax
/**
* Assign price and tax to the template
*/
protected function assignPriceAndTax()
{
die('coucou');
$id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
$id_group = (int) Group::getCurrent()->id;
$id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
$group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
if ($group_reduction === false) {
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
}
// Tax
$tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$this->context->smarty->assign('tax_rate', $tax);
$product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6) * 10;
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
$product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
}
$product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
$ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
$ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
}
$id_currency = (int) $this->context->cookie->id_currency;
$id_product = (int) $this->product->id;
$id_shop = $this->context->shop->id;
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true, (int) $this->context->customer->id);
foreach ($quantity_discounts as &$quantity_discount) {
if ($quantity_discount['id_product_attribute']) {
$combination = new Combination((int) $quantity_discount['id_product_attribute']);
$attributes = $combination->getAttributesName((int) $this->context->language->id);
foreach ($attributes as $attribute) {
$quantity_discount['attributes'] = $attribute['name'] . ' - ';
}
$quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
}
if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
$quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
}
}
$product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false) * 10;
$address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$this->context->smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount), 'ecotax_tax_inc' => $ecotax_tax_amount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'productPriceWithoutEcoTax' => (double) $product_price_without_eco_tax, 'group_reduction' => $group_reduction, 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address), 'ecotax' => !count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'), 'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group)));
}
示例10: verif_champ
function verif_champ($post)
{
$return = false;
$conf = Configuration::getMultiple(array('ATOS_MERCHAND_ID'));
$cookie = new Cookie('ps');
$id_cart = $cookie->id_cart;
$cart = new Cart($id_cart);
$id_currency = intval($cart->id_currency);
$currency = new Currency(intval($id_currency));
$montant = number_format(Tools::convertPrice($cart->getOrderTotal(true, 3), $currency), 2, '.', '');
if (strpos($montant, '.')) {
$montant = $montant * 100;
}
$montant = str_replace('.', '', $montant);
if ($post['amount'] == $montant && $post['id_cart'] == $id_cart) {
$return = true;
}
//return $return;
return true;
}
示例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);
}
}
示例12: initContent
/**
* AdminController::initContent() override
* @see AdminController::initContent()
*/
public function initContent()
{
if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate the Advanced Stock Management feature prior to using this feature.');
return false;
}
// Manage the add stock form
if ($this->display == 'addstock' || $this->display == 'removestock' || $this->display == 'transferstock') {
if (Tools::isSubmit('id_product') || Tools::isSubmit('id_product_attribute')) {
// get id product and product attribute if possible
$id_product = (int) Tools::getValue('id_product', 0);
$id_product_attribute = (int) Tools::getValue('id_product_attribute', 0);
$product_is_valid = false;
$is_pack = false;
$is_virtual = false;
$lang_id = $this->context->language->id;
$default_wholesale_price = 0;
// try to load product attribute first
if ($id_product_attribute > 0) {
// try to load product attribute
$combination = new Combination($id_product_attribute);
if (Validate::isLoadedObject($combination)) {
$product_is_valid = true;
$id_product = $combination->id_product;
$reference = $combination->reference;
$ean13 = $combination->ean13;
$upc = $combination->upc;
$manufacturer_reference = $combination->supplier_reference;
// get the full name for this combination
$query = new DbQuery();
$query->select('IFNULL(CONCAT(pl.`name`, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.`name` SEPARATOR \', \')),pl.`name`) as name');
$query->from('product_attribute', 'a');
$query->join('INNER JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang` = ' . (int) $lang_id . ')
LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.`id_product_attribute` = a.`id_product_attribute`)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute atr ON (atr.`id_attribute` = pac.`id_attribute`)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.`id_attribute` = atr.`id_attribute` AND al.`id_lang` = ' . (int) $lang_id . ')
LEFT JOIN ' . _DB_PREFIX_ . 'attribute_group_lang agl ON (agl.`id_attribute_group` = atr.`id_attribute_group` AND agl.`id_lang` = ' . (int) $lang_id . ')');
$query->where('a.`id_product_attribute` = ' . $id_product_attribute);
$name = Db::getInstance()->getValue($query);
$p = new Product($id_product, false, $lang_id);
$default_wholesale_price = $combination->wholesale_price > 0 ? $combination->wholesale_price : $p->wholesale_price;
}
} else {
$product = new Product($id_product, false, $lang_id);
if (is_int($product->id)) {
$product_is_valid = true;
$reference = $product->reference;
$ean13 = $product->ean13;
$upc = $product->upc;
$name = $product->name;
$manufacturer_reference = $product->supplier_reference;
$is_pack = $product->cache_is_pack;
$is_virtual = $product->is_virtual;
$default_wholesale_price = $product->wholesale_price;
}
}
if ($product_is_valid === true && $is_virtual == false) {
// init form
$this->renderForm();
$this->getlanguages();
$helper = new HelperForm();
$this->initPageHeaderToolbar();
// Check if form template has been overriden
if (file_exists($this->context->smarty->getTemplateDir(0) . '/' . $this->tpl_folder . 'form.tpl')) {
$helper->tpl = $this->tpl_folder . 'form.tpl';
}
$this->setHelperDisplay($helper);
$helper->submit_action = $this->display;
$helper->id = null;
// no display standard hidden field in the form
$helper->languages = $this->_languages;
$helper->default_form_language = $this->default_form_language;
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
$helper->show_cancel_button = true;
$helper->back_url = $this->context->link->getAdminLink('AdminStockManagement');
$helper->fields_value = array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'reference' => $reference, 'manufacturer_reference' => $manufacturer_reference, 'name' => $name, 'ean13' => $ean13, 'upc' => $upc, 'check' => md5(_COOKIE_KEY_ . $id_product . $id_product_attribute), 'quantity' => Tools::getValue('quantity', ''), 'id_warehouse' => Tools::getValue('id_warehouse', ''), 'usable' => $this->fields_value['usable'] ? $this->fields_value['usable'] : Tools::getValue('usable', 1), 'price' => Tools::getValue('price', (double) Tools::convertPrice($default_wholesale_price, null)), 'id_currency' => Tools::getValue('id_currency', ''), 'id_stock_mvt_reason' => Tools::getValue('id_stock_mvt_reason', ''), 'is_post' => 1);
if ($this->display == 'addstock') {
$_POST['id_product'] = (int) $id_product;
}
if ($this->display == 'transferstock') {
$helper->fields_value['id_warehouse_from'] = Tools::getValue('id_warehouse_from', '');
$helper->fields_value['id_warehouse_to'] = Tools::getValue('id_warehouse_to', '');
$helper->fields_value['usable_from'] = Tools::getValue('usable_from', '1');
$helper->fields_value['usable_to'] = Tools::getValue('usable_to', '1');
}
$this->content .= $helper->generateForm($this->fields_form);
$this->context->smarty->assign(array('content' => $this->content, 'show_page_header_toolbar' => $this->show_page_header_toolbar, 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn));
} else {
$this->errors[] = Tools::displayError('The specified product is not valid.');
}
}
} else {
parent::initContent();
}
}
示例13: _assignWrappingAndTOS
protected function _assignWrappingAndTOS()
{
// Wrapping fees
$wrapping_fees = $this->context->cart->getGiftWrappingPrice(false);
$wrapping_fees_tax_inc = $wrapping_fees = $this->context->cart->getGiftWrappingPrice();
// TOS
$cms = new CMS(Configuration::get('PS_CONDITIONS_CMS_ID'), $this->context->language->id);
$this->link_conditions = $this->context->link->getCMSLink($cms, $cms->link_rewrite, (bool) Configuration::get('PS_SSL_ENABLED'));
if (!strpos($this->link_conditions, '?')) {
$this->link_conditions .= '?content_only=1';
} else {
$this->link_conditions .= '&content_only=1';
}
$free_shipping = false;
foreach ($this->context->cart->getCartRules() as $rule) {
if ($rule['free_shipping'] && !$rule['carrier_restriction']) {
$free_shipping = true;
break;
}
}
$this->context->smarty->assign(array('free_shipping' => $free_shipping, 'checkedTOS' => (int) $this->context->cookie->checkedTOS, 'recyclablePackAllowed' => (int) Configuration::get('PS_RECYCLABLE_PACK'), 'giftAllowed' => (int) Configuration::get('PS_GIFT_WRAPPING'), 'cms_id' => (int) Configuration::get('PS_CONDITIONS_CMS_ID'), 'conditions' => (int) Configuration::get('PS_CONDITIONS'), 'link_conditions' => $this->link_conditions, 'recyclable' => (int) $this->context->cart->recyclable, 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), 'carriers' => $this->context->cart->simulateCarriersOutput(), 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), 'address_collection' => $this->context->cart->getAddressCollection(), 'delivery_option' => $this->context->cart->getDeliveryOption(null, false), 'gift_wrapping_price' => (double) $wrapping_fees, 'total_wrapping_cost' => Tools::convertPrice($wrapping_fees_tax_inc, $this->context->currency), 'total_wrapping_tax_exc_cost' => Tools::convertPrice($wrapping_fees, $this->context->currency)));
}
示例14: getTotalPaid
/**
* Get total paid
*
* @since 1.5.0.1
* @param Currency $currency currency used for the total paid of the current order
* @return float amount in the $currency
*/
public function getTotalPaid($currency = null)
{
if (!$currency) {
$currency = new Currency($this->id_currency);
}
$total = 0;
// Retrieve all payments
$payments = $this->getOrderPaymentCollection();
foreach ($payments as $payment) {
if ($payment->id_currency == $currency->id) {
$total += $payment->amount;
} else {
$amount = Tools::convertPrice($payment->amount, $payment->id_currency, false);
if ($currency->id == Configuration::get('PS_DEFAULT_CURRENCY', null, null, $this->id_shop)) {
$total += $amount;
} else {
$total += Tools::convertPrice($amount, $currency->id, true);
}
}
}
return Tools::ps_round($total, 2);
}
示例15: process
//.........这里部分代码省略.........
if ((int) Tools::getValue('pp') == 1) {
$time8 = time();
echo 'time8: ' . $time8;
}
if ($this->is_saree || $this->is_lehenga) {
if ($this->is_lehenga) {
self::$smarty->assign('is_lehenga', $this->is_lehenga);
}
self::$smarty->assign('as_shown', (bool) $this->product->as_shown);
/*if($blouse_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 1))
self::$smarty->assign('measurement_info', $blouse_measurements);
if($skirt_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 2))
self::$smarty->assign('skirt_measurement_info', $skirt_measurements);*/
if ((int) Tools::getValue('pp') == 1) {
$time81 = time();
echo 'time81: ' . $time81;
}
if ($this->is_saree) {
//count of all styles mapped to this product
$res = Db::getInstance()->getRow("select count(s.id_style) as style_count from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1");
$style_count = (int) $res['style_count'];
if ($style_count === 0) {
// show the default style for sarees
$style = array('id_style' => 1, 'style_image_small' => '1-small.png', 'style_name' => 'Round');
} else {
$res = Db::getInstance()->getRow("select s.id_style, s.style_name, s.style_image_small from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1 and ps.is_default = 1");
if (!empty($res)) {
//show the default style for this product
$style = array('id_style' => $res['id_style'], 'style_image_small' => $res['style_image_small'], 'style_name' => $res['style_name']);
}
}
if ((int) Tools::getValue('pp') == 1) {
$time82 = time();
echo 'time82: ' . $time82;
}
self::$smarty->assign('blouse_style_count', $style_count);
self::$smarty->assign('blouse_style', $style);
}
} else {
if ($this->is_skd || $this->is_skd_rts) {
self::$smarty->assign('is_anarkali', $this->is_anarkali);
if ($this->is_anarkali) {
if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 5)) {
self::$smarty->assign('kurta_measurement_info', $kurta_measurements);
}
} else {
if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 3)) {
self::$smarty->assign('kurta_measurement_info', $kurta_measurements);
}
}
if ($salwar_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 4)) {
self::$smarty->assign('salwar_measurement_info', $salwar_measurements);
}
//get default styles for this product (RTS)
if ($this->is_skd_rts) {
$res = Db::getInstance()->ExecuteS("select count(s.id_style) as style_count, s.style_type, ps.id_product from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} group by ps.id_product,s.style_type");
foreach ($res as $s) {
$style_count = (int) $s['style_count'];
if ((int) $s['style_type'] === 4) {
self::$smarty->assign('kurta_style_count', $style_count);
} else {
if ((int) $s['style_type'] === 5) {
self::$smarty->assign('salwar_style_count', $style_count);
}
}
}
$res = Db::getInstance()->ExecuteS("select s.id_style, s.style_type, s.style_image_small, s.style_name from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and ps.is_default = 1");
foreach ($res as $s) {
$style = array('id_style' => $s['id_style'], 'style_image_small' => $s['style_image_small'], 'style_name' => $s['style_name']);
if ((int) $s['style_type'] === 4) {
self::$smarty->assign('kurta_style', $style);
} else {
if ((int) $s['style_type'] === 5) {
self::$smarty->assign('salwar_style', $style);
}
}
}
}
}
}
self::$smarty->assign('is_bottoms', $this->is_bottoms);
self::$smarty->assign('is_abaya', $this->is_abaya);
self::$smarty->assign('is_wristwear', $this->is_wristwear);
self::$smarty->assign('is_pakistani_rts', $this->is_pakistani_rts);
if ((int) Tools::getValue('pp') == 1) {
$time85 = time();
echo 'time85: ' . $time85;
}
self::$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'categories' => Category::getHomeCategories((int) self::$cookie->id_lang), 'have_image' => Product::getCover((int) Tools::getValue('id_product')), 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => !sizeof($this->errors) and $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')));
if ((int) Tools::getValue('pp') == 1) {
$time9 = time();
echo 'time9: ' . $time9;
}
//add this to product stats
//Tools::captureActivity(PSTAT_VIEWS,$id_product);
if ((int) Tools::getValue('pp') == 1) {
$time1 = time();
echo 'process end: ' . $time1;
}
}