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


PHP Tools::ps_round方法代码示例

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


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

示例1: 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

示例2: hookRightColumn

 function hookRightColumn($params)
 {
     global $smarty;
     if ($special = Product::getRandomSpecial(intval($params['cookie']->id_lang))) {
         $smarty->assign(array('special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'] / (1 + $special['rate'] / 100), 2), 'oldPrice' => $special['price'] + $special['reduction'], 'mediumSize' => Image::getSize('medium')));
     }
     return $this->display(__FILE__, 'blockspecials.tpl');
 }
开发者ID:vincent,项目名称:theinvertebrates,代码行数:8,代码来源:blockspecials.php

示例3: _assignSummaryInformations

 protected function _assignSummaryInformations()
 {
     $summary = $this->context->cart->getSummaryDetails();
     $customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
     // override customization tax rate with real tax (tax rules)
     if ($customizedDatas) {
         foreach ($summary['products'] as &$productUpdate) {
             $productId = (int) isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id'];
             $productAttributeId = (int) isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id'];
             if (isset($customizedDatas[$productId][$productAttributeId])) {
                 $productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             }
         }
         Product::addCustomizationPrice($summary['products'], $customizedDatas);
     }
     $cart_product_context = Context::getContext()->cloneContext();
     foreach ($summary['products'] as $key => &$product) {
         $product['quantity'] = $product['cart_quantity'];
         // for compatibility with 1.2 themes
         if ($cart_product_context->shop->id != $product['id_shop']) {
             $cart_product_context->shop = new Shop((int) $product['id_shop']);
         }
         $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], _PS_PRICE_COMPUTE_PRECISION_, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
         /**
          * ABU edit: variable is_discount set à 1 à tord, calcul foireux de presta
          * @bugfix: https://github.com/PrestaShop/PrestaShop/commit/379e28b341730ea95c0b2d6567817305ea841b23
          * @perso: soustraction de l'ecotax au price_without_specific_price @else
          */
         if (Product::getTaxCalculationMethod()) {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_);
         } else {
             // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
             $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'] - $product['ecotax'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_);
         }
     }
     // Get available cart rules and unset the cart rules already in the cart
     $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart);
     $cart_cart_rules = $this->context->cart->getCartRules();
     foreach ($available_cart_rules as $key => $available_cart_rule) {
         if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], CartRule::BO_ORDER_CODE_PREFIX) === 0) {
             unset($available_cart_rules[$key]);
             continue;
         }
         foreach ($cart_cart_rules as $cart_cart_rule) {
             if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) {
                 unset($available_cart_rules[$key]);
                 continue 2;
             }
         }
     }
     $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE');
     $this->context->smarty->assign($summary);
     $this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
     $this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)));
 }
开发者ID:ecSta,项目名称:prestanight,代码行数:56,代码来源:ParentOrderController.php

示例4: update_order_canada

function update_order_canada()
{
    $sql = 'SHOW TABLES LIKE \'' . _DB_PREFIX_ . 'order_tax\'';
    $table = Db::getInstance()->ExecuteS($sql);
    if (!count($table)) {
        Db::getInstance()->Execute('
		CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'order_tax` (
		  `id_order` int(11) NOT NULL,
		  `tax_name` varchar(40) NOT NULL,
		  `tax_rate` decimal(6,3) NOT NULL,
		  `amount` decimal(20,6) NOT NULL
		) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8');
        $address_field = Configuration::get('PS_TAX_ADDRESS_TYPE');
        $sql = 'SELECT `id_order`
					FROM `' . _DB_PREFIX_ . 'orders` o
					LEFT JOIN `' . _DB_PREFIX_ . 'address` a ON (a.`id_address` = o.`' . bqSQL($address_field) . '`)
					LEFT JOIN `' . _DB_PREFIX_ . 'country` c ON (c.`id_country` = a.`id_country`)
					WHERE c.`iso_code` = "CA"';
        $id_order_list = Db::getInstance()->ExecuteS($sql);
        $values = '';
        foreach ($id_order_list as $id_order) {
            $amount = array();
            $id_order = $id_order['id_order'];
            $order = new Order((int) $id_order);
            if (!Validate::isLoadedObject($order)) {
                continue;
            }
            $products = $order->getProducts();
            foreach ($products as $product) {
                if (!array_key_exists($product['tax_name'], $amount)) {
                    $amount[$product['tax_name']] = array('amount' => 0, 'rate' => $product['tax_rate']);
                }
                if ($order->getTaxCalculationMethod() == PS_TAX_EXC) {
                    $total_product = $product['product_price'] * $product['product_quantity'];
                    $amount_tmp = Tools::ps_round($total_product * ($product['tax_rate'] / 100), 2);
                    $amount[$product['tax_name']]['amount'] += Tools::ps_round($total_product * ($product['tax_rate'] / 100), 2);
                } else {
                    $total_product = $product['product_price'] * $product['product_quantity'];
                    $amount_tmp = Tools::ps_round($total_product - $total_product / (1 + $product['tax_rate'] / 100), 2);
                    $amount[$product['tax_name']]['amount'] += Tools::ps_round($total_product - $total_product / (1 + $product['tax_rate'] / 100), 2);
                }
            }
            foreach ($amount as $tax_name => $tax_infos) {
                $values .= '(' . (int) $order->id . ', \'' . pSQL($tax_name) . '\', \'' . pSQL($tax_infos['rate']) . '\', ' . (double) $tax_infos['amount'] . '),';
            }
            unset($order);
        }
        if (!empty($values)) {
            $values = rtrim($values, ",");
            Db::getInstance()->Execute('
			INSERT INTO `' . _DB_PREFIX_ . 'order_tax` (id_order, tax_name, tax_rate, amount)
			VALUES ' . $values);
        }
    }
}
开发者ID:ricardo-rdfs,项目名称:Portal-BIP,代码行数:55,代码来源:update_order_canada.php

示例5: 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;
     }
     $taxCalculationMethod = Group::getPriceDisplayMethod((int) Group::getCurrent()->id);
     $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();
     $base_shipping = $params['cart']->getOrderTotal($useTax, Cart::ONLY_SHIPPING);
     $shipping_cost = Tools::displayPrice($base_shipping, $currency);
     $shipping_cost_float = Tools::convertPrice($base_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['is_gift'] = 1;
                     $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);
     }
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:54,代码来源:blockcart.php

示例6: hookRightColumn

 public function hookRightColumn($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return;
     }
     if (!($special = Product::getRandomSpecial((int) $params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) {
         return;
     }
     $this->smarty->assign(array('special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium'))));
     return $this->display(__FILE__, 'blockspecials.tpl');
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:11,代码来源:blockspecials.php

示例7: hookRightColumn

 public function hookRightColumn($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return;
     }
     // We need to create multiple caches because the products are sorted randomly
     $random = date('Ymd') . '|' . round(rand(1, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 1)));
     if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|' . $random))) {
         $countSpecial = Product::getCountSpecial((int) $params['cookie']->id_lang, 4);
         $this->smarty->assign(array('special' => $countSpecial, 'priceWithoutReduction_tax_excl' => Tools::ps_round(isset($special) ? $special['price_without_reduction'] : 0, 2), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium'))));
     }
     return $this->display(__FILE__, 'blockspecials.tpl', Configuration::get('BLOCKSPECIALS_NB_CACHES') ? $this->getCacheId('blockspecials|' . $random) : null);
 }
开发者ID:Arikito,项目名称:barbator,代码行数:13,代码来源:blockspecials.php

示例8: hookHome

 public function hookHome($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return;
     }
     global $smarty;
     $tmp = Product::getPricesDrop(intval($params['cookie']->id_lang));
     asort($tmp);
     if (!($special = Product::getRandomSpecial((int) $params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) {
         return;
     }
     $this->smarty->assign(array('special' => $special, 'specials' => $tmp, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize('medium_default')));
     return $this->display(__FILE__, 'tmspecials.tpl');
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:14,代码来源:tmspecials.php

示例9: confirmOrder

 public function confirmOrder($custom)
 {
     $cart = new Cart((int) $custom['id_cart']);
     $cart_details = $cart->getSummaryDetails(null, true);
     $cart_hash = sha1(serialize($cart->nbProducts()));
     $this->context->cart = $cart;
     $address = new Address((int) $cart->id_address_invoice);
     $this->context->country = new Country((int) $address->id_country);
     $this->context->customer = new Customer((int) $cart->id_customer);
     $this->context->language = new Language((int) $cart->id_lang);
     $this->context->currency = new Currency((int) $cart->id_currency);
     if (isset($cart->id_shop)) {
         $this->context->shop = new Shop($cart->id_shop);
     }
     $res = $this->getResult();
     if (strcmp($res, "VERIFIED") == 0) {
         $currency_decimals = is_array($this->context->currency) ? (int) $this->context->currency['decimals'] : (int) $this->context->currency->decimals;
         $this->decimals = $currency_decimals * _PS_PRICE_DISPLAY_PRECISION_;
         $message = null;
         $mc_gross = Tools::ps_round(Tools::getValue('mc_gross'), $this->decimals);
         $cart_details = $cart->getSummaryDetails(null, true);
         $shipping = $cart_details['total_shipping_tax_exc'];
         $subtotal = $cart_details['total_price_without_tax'] - $cart_details['total_shipping_tax_exc'];
         $tax = $cart_details['total_tax'];
         $total_price = Tools::ps_round($shipping + $subtotal + $tax, $this->decimals);
         if (bccomp($mc_gross, $total_price, 2) !== 0) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Price paid on paypal is not the same that on PrestaShop.') . '<br />';
         } elseif ($custom['hash'] != $cart_hash) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Cart changed, please retry.') . '<br />';
         } else {
             $payment = (int) Configuration::get('PS_OS_PAYMENT');
             $message = $this->l('Payment accepted.') . '<br />';
         }
         $customer = new Customer((int) $cart->id_customer);
         $transaction = PayPalOrder::getTransactionDetails(false);
         if (_PS_VERSION_ < '1.5') {
             $shop = null;
         } else {
             $shop_id = $this->context->shop->id;
             $shop = new Shop($shop_id);
         }
         $this->validateOrder($cart->id, $payment, $total_price, $this->displayName, $message, $transaction, $cart->id_currency, false, $customer->secure_key, $shop);
     }
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:46,代码来源:notifier.php

示例10: 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)));
 }
开发者ID:ArnaudBenassy,项目名称:prestashop_test,代码行数:47,代码来源:ProductController.php

示例11: hookOrderConfirmation

 public function hookOrderConfirmation($params)
 {
     // Setting parameters
     $parameters = Configuration::getMultiple(array('PS_LANG_DEFAULT'));
     $order = $params['objOrder'];
     if (Validate::isLoadedObject($order)) {
         $conversion_rate = 1;
         $amount = isset($order->total_paid_tax_excl) ? $order->total_paid_tax_excl : 0;
         $shipping = isset($order->total_shipping_tax_incl) ? $order->total_shipping_tax_incl : 0;
         $conversionAmount = $amount - $shipping;
         // Order general information
         $trans = array('id' => (int) $order->id, 'total' => Tools::ps_round((double) $conversionAmount / (double) $conversion_rate, 2));
         $tapfiliate_id = Configuration::get('TAPFILIATE_ID');
         $this->context->smarty->assign('trans', $trans);
         $this->context->smarty->assign('tapfiliate_id', $tapfiliate_id);
         $this->context->smarty->assign('isOrder', true);
         return $this->display(__FILE__, 'views/templates/hook/footer.tpl');
     }
 }
开发者ID:ErikTVF,项目名称:Shopping-Cart-Integrations,代码行数:19,代码来源:tapfiliate.php

示例12: confirmOrder

 public function confirmOrder($custom)
 {
     $cart = new Cart((int) $custom['id_cart']);
     $cart_details = $cart->getSummaryDetails(null, true);
     $cart_hash = sha1(serialize($cart->nbProducts()));
     $this->context->cart = $cart;
     $address = new Address((int) $cart->id_address_invoice);
     $this->context->country = new Country((int) $address->id_country);
     $this->context->customer = new Customer((int) $cart->id_customer);
     $this->context->language = new Language((int) $cart->id_lang);
     $this->context->currency = new Currency((int) $cart->id_currency);
     if (isset($cart->id_shop)) {
         $this->context->shop = new Shop($cart->id_shop);
     }
     $this->createLog($cart->getProducts(true));
     $mc_gross = Tools::getValue('mc_gross');
     $total_price = Tools::ps_round($cart_details['total_price'], 2);
     $message = null;
     $result = $this->verify();
     if (strcmp($result, VERIFIED) == 0) {
         if ($mc_gross != $total_price) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Price payed on paypal is not the same that on PrestaShop.') . '<br />';
         } elseif ($custom['hash'] != $cart_hash) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Cart changed, please retry.') . '<br />';
         } else {
             $payment = (int) Configuration::get('PS_OS_WS_PAYMENT');
             $message = $this->l('Payment accepted.') . '<br />';
         }
         $customer = new Customer((int) $cart->id_customer);
         $id_order = (int) Order::getOrderByCartId((int) $cart->id);
         $transaction = array('currency' => pSQL(Tools::getValue(CURRENCY)), 'id_invoice' => pSQL(Tools::getValue(ID_INVOICE)), 'id_transaction' => pSQL(Tools::getValue(ID_TRANSACTION)), 'payment_date' => pSQL(Tools::getValue(PAYMENT_DATE)), 'shipping' => (double) Tools::getValue(SHIPPING), 'total_paid' => (double) Tools::getValue(TOTAL_PAID));
         $this->validateOrder($cart->id, $payment, $total_price, $this->displayName, $message, $transaction, $cart->id_currency, false, $customer->secure_key);
         $history = new OrderHistory();
         $history->id_order = (int) $id_order;
         $history->changeIdOrderState((int) $payment, (int) $id_order);
         $history->addWithemail();
         $history->add();
     }
 }
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:41,代码来源:notifier.php

示例13: formatEntityToXML

 /**
  * Convert the entities data into an xml object and return the xml object as a string
  *
  * @param array $aEntity Entity data
  */
 public function formatEntityToXML($aEntity)
 {
     $dom = new DOMDocument('1.0', 'utf-8');
     // Set the root of the XML
     $root = $dom->createElement($this->sEntity);
     $dom->appendChild($root);
     $oOrder = new Order((int) $aEntity['id_order']);
     $root->setAttribute("isodate", date('c', strtotime($oOrder->invoice_date)));
     $userid = $dom->createElement('userid', (int) $oOrder->id_customer);
     $root->appendChild($userid);
     $transactionid = $dom->createElement('transactionid', (int) $oOrder->id);
     $root->appendChild($transactionid);
     $aOrderProducts = $oOrder->getProducts();
     $sReturn = false;
     if (is_array($aOrderProducts) && count($aOrderProducts) > 0) {
         foreach ($aOrderProducts as $aOrderProduct) {
             $item = $dom->createElement('item');
             $root->appendChild($item);
             $itemid = $dom->createElement('itemid', (int) $aOrderProduct['product_id']);
             $item->appendChild($itemid);
             $profile = $dom->createElement('profile', (int) $oOrder->id_lang);
             $item->appendChild($profile);
             if ($oOrder->getTaxCalculationMethod() == PS_TAX_EXC) {
                 $product_price = $aOrderProduct['product_price'] + $aOrderProduct['ecotax'];
             } else {
                 $product_price = $aOrderProduct['product_price_wt'];
             }
             $price = $dom->createElement('price', number_format(Tools::ps_round($product_price, 2), 2, '.', ''));
             $item->appendChild($price);
             $quantity = $dom->createElement('quantity', (int) $aOrderProduct['product_quantity']);
             $item->appendChild($quantity);
         }
         $sReturn = $dom->saveHTML();
     }
     unset($dom);
     unset($oOrder);
     unset($aOrderProducts);
     return $sReturn;
 }
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:44,代码来源:OrderExtractorToXML.php

示例14: getTaxesAmount

 public function getTaxesAmount($price_before_tax, $price_after_tax = null, $round_precision = 2, $round_mode = null)
 {
     $amounts = array();
     $total_base = 0;
     foreach ($this->getProductTaxes() as $row) {
         if (!array_key_exists($row['id_tax'], $amounts)) {
             $amounts[$row['id_tax']] = array('rate' => $row['rate'], 'base' => 0);
         }
         $amounts[$row['id_tax']]['base'] += $row['total_price_tax_excl'];
         $total_base += $row['total_price_tax_excl'];
     }
     $actual_tax = 0;
     foreach ($amounts as &$data) {
         $data = Tools::ps_round($price_before_tax * ($data['base'] / $total_base) * $data['rate'] / 100, $round_precision, $round_mode);
         $actual_tax += $data;
     }
     unset($data);
     if ($price_after_tax) {
         Tools::spreadAmount($price_after_tax - $price_before_tax - $actual_tax, $round_precision, $amounts, 'id_tax');
     }
     return $amounts;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:22,代码来源:AverageTaxOfProductsTaxCalculator.php

示例15: setDetailProductPrice

 protected function setDetailProductPrice(Order $order, Cart $cart, $product)
 {
     $this->setContext((int) $product['id_shop']);
     $specific_price = $null = null;
     Product::getPriceStatic((int) $product['id_product'], true, (int) $product['id_product_attribute'], 6, null, false, true, array($product['cart_quantity'], $product['cart_quantity_fractional']), false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, $this->context);
     $this->specificPrice = $specific_price;
     $this->original_product_price = Product::getPriceStatic($product['id_product'], false, (int) $product['id_product_attribute'], 6, null, false, false, 1, false, null, null, null, $null, true, true, $this->context);
     $this->product_price = $this->original_product_price;
     $this->unit_price_tax_incl = (double) $product['price_wt'];
     $this->unit_price_tax_excl = (double) $product['price'];
     $this->total_price_tax_incl = (double) $product['total_wt'];
     $this->total_price_tax_excl = (double) $product['total'];
     $this->purchase_supplier_price = (double) $product['wholesale_price'];
     if ($product['id_supplier'] > 0 && ($supplier_price = ProductSupplier::getProductPrice((int) $product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true)) > 0) {
         $this->purchase_supplier_price = (double) $supplier_price;
     }
     $this->setSpecificPrice($order, $product);
     $this->group_reduction = (double) Group::getReduction((int) $order->id_customer);
     $shop_id = $this->context->shop->id;
     $quantity_discount = SpecificPrice::getQuantityDiscount((int) $product['id_product'], $shop_id, (int) $cart->id_currency, (int) $this->vat_address->id_country, (int) $this->customer->id_default_group, (int) PP::resolveQty($product['cart_quantity'], $product['cart_quantity_fractional']), false, null, null, $null, true, true, $this->context);
     $unit_price = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null, 2, null, false, true, 1, false, (int) $order->id_customer, null, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $null, true, true, $this->context);
     $this->product_quantity_discount = 0.0;
     if ($quantity_discount) {
         $this->product_quantity_discount = $unit_price;
         if (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC) {
             $this->product_quantity_discount = Tools::ps_round($unit_price, 2);
         }
         if (isset($this->tax_calculator)) {
             $this->product_quantity_discount -= $this->tax_calculator->addTaxes($quantity_discount['price']);
         }
     }
     $this->discount_quantity_applied = $this->specificPrice && $this->specificPrice['from_quantity'] > PP::getSpecificPriceFromQty((int) $product['id_product']) ? 1 : 0;
     $this->id_cart_product = (int) $product['id_cart_product'];
     $this->product_quantity_fractional = (double) $product['cart_quantity_fractional'];
     $ppropertiessmartprice_hook3 = null;
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:36,代码来源:OrderDetail.php


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