本文整理汇总了PHP中Product::getTaxCalculationMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getTaxCalculationMethod方法的具体用法?PHP Product::getTaxCalculationMethod怎么用?PHP Product::getTaxCalculationMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getTaxCalculationMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hookProductFooter
public function hookProductFooter($params)
{
$id_product = (int) $params['product']->id;
$product = $params['product'];
if (isset($params['product']->id_manufacturer) && $params['product']->id_manufacturer) {
$cache_id = 'productsmanufacturer|' . $id_product . '|' . (int) $params['product']->id_manufacturer;
if (!$this->isCached('productsmanufacturer.tpl', $this->getCacheId($cache_id))) {
// Get infos
$manufacturer_products = Manufacturer::getProducts($params['product']->id_manufacturer, $this->context->language->id, 1, Configuration::get('pmslid_limit'));
/* 100 products max. */
// Remove current product from the list
if (is_array($manufacturer_products) && count($manufacturer_products)) {
foreach ($manufacturer_products as $key => $manufacturer_product) {
if ($manufacturer_product['id_product'] == $id_product) {
unset($manufacturer_products[$key]);
break;
}
}
$taxes = Product::getTaxCalculationMethod();
if (!Configuration::get('pmslid_DISPLAY_PRICE')) {
foreach ($manufacturer_products as $key => $manufacturer_product) {
if ($manufacturer_product['id_product'] != $id_product) {
$manufacturer_products[$key]['show_price'] = 0;
}
}
}
}
// Display tpl
$this->smarty->assign(array('manufacturer_products' => $manufacturer_products, 'ProdDisplayPrice' => Configuration::get('pmslid_DISPLAY_PRICE')));
}
return $this->display(__FILE__, 'productsmanufacturer.tpl', $this->getCacheId($cache_id));
}
}
示例2: setProduct
public function setProduct($product, $combination)
{
// create the product
$context = Context::getContext();
$this->give_it_product = new GiveItSdkProduct();
$this->give_it_product->setCurrency($context->currency->iso_code);
$usetax = Product::getTaxCalculationMethod((int) $context->customer->id) != PS_TAX_EXC;
if ($combination['id_product_attribute'] == 0) {
$combination['attributes'] = '';
$image = Product::getCover($product->id);
} else {
$comb = new Combination($combination['id_product_attribute']);
if ($image = $comb->getWsImages()) {
$image = $image[0];
$image['id_image'] = $image['id'];
}
}
$image['id_product'] = $product->id;
$image['id_image'] = Product::defineProductImage($image, Context::getContext()->language->id);
$img_profile = version_compare(_PS_VERSION_, '1.5', '<') ? 'home' : ImageType::getFormatedName('medium');
$image = $image ? $context->link->getImageLink($product->link_rewrite, $image['id_image'], $img_profile) : '';
// first, set the product details.
$this->give_it_product->setProductDetails(array('code' => $product->id . '_' . $combination['id_product_attribute'], 'price' => (int) (Product::getPriceStatic((int) $product->id, $usetax, $combination['id_product_attribute']) * 100), 'name' => $product->name . ($combination['attributes'] ? ' : ' . $combination['attributes'] : ''), 'image' => $image));
$delivery = $this->setDelivery();
// add the delivery option to the product
$this->give_it_product->addBuyerOption($delivery);
//We should validate this product
$this->product_valid = $this->give_it_product->validate();
}
示例3: getCartNbPoints
public static function getCartNbPoints($cart, $newProduct = NULL)
{
$total = 0;
if (Validate::isLoadedObject($cart)) {
$cartProducts = $cart->getProducts();
$taxesEnabled = Product::getTaxCalculationMethod();
if (isset($newProduct) and !empty($newProduct)) {
$cartProductsNew['id_product'] = (int) $newProduct->id;
if ($taxesEnabled == PS_TAX_EXC) {
$cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int) $newProduct->getIdProductAttributeMostExpensive()), 2, '.', '');
} else {
$cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int) $newProduct->getIdProductAttributeMostExpensive()), 2, '.', '');
}
$cartProductsNew['cart_quantity'] = 1;
$cartProducts[] = $cartProductsNew;
}
foreach ($cartProducts as $product) {
if (!(int) Configuration::get('PS_LOYALTY_NONE_AWARD') and Product::isDiscounted((int) $product['id_product'])) {
global $smarty;
if (isset($smarty) and is_object($newProduct) and $product['id_product'] == $newProduct->id) {
$smarty->assign('no_pts_discounted', 1);
}
continue;
}
$total += self::getNbPointsByPrice($taxesEnabled == PS_TAX_EXC ? $product['price'] : $product['price_wt']) * (int) $product['cart_quantity'];
}
foreach ($cart->getDiscounts(false) as $discount) {
$total -= self::getNbPointsByPrice($discount['value_real']);
}
}
return $total;
}
示例4: includeTaxes
public function includeTaxes()
{
if (!Configuration::get('PS_TAX')) {
return false;
}
return !Product::getTaxCalculationMethod(Context::getContext()->cookie->id_customer);
}
示例5: _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)));
}
示例6: bootstrap
private function bootstrap()
{
$translator = $this->getTranslator();
$session = $this->getCheckoutSession();
$this->checkoutProcess = new CheckoutProcess($this->context, $session);
$this->checkoutProcess->addStep(new CheckoutPersonalInformationStep($this->context, $translator, $this->makeLoginForm(), $this->makeCustomerForm()))->addStep(new CheckoutAddressesStep($this->context, $translator, $this->makeAddressForm()));
if (!$this->context->cart->isVirtualCart()) {
$checkoutDeliveryStep = new CheckoutDeliveryStep($this->context, $translator);
$checkoutDeliveryStep->setRecyclablePackAllowed((bool) Configuration::get('PS_RECYCLABLE_PACK'))->setGiftAllowed((bool) Configuration::get('PS_GIFT_WRAPPING'))->setIncludeTaxes(!Product::getTaxCalculationMethod((int) $this->context->cart->id_customer) && (int) Configuration::get('PS_TAX'))->setDisplayTaxesLabel(Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'))->setGiftCost($this->context->cart->getGiftWrappingPrice($checkoutDeliveryStep->getIncludeTaxes()));
$this->checkoutProcess->addStep($checkoutDeliveryStep);
}
$this->checkoutProcess->addStep(new CheckoutPaymentStep($this->context, $translator, new PaymentOptionsFinder(), new ConditionsToApproveFinder($this->context, $translator)));
}
示例7: getDeliveryOptions
public function getDeliveryOptions()
{
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$include_taxes = !Product::getTaxCalculationMethod((int) $this->context->cart->id_customer) && (int) Configuration::get('PS_TAX');
$display_taxes_label = Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC');
$carriers_available = array();
if (isset($delivery_option_list[$this->context->cart->id_address_delivery])) {
foreach ($delivery_option_list[$this->context->cart->id_address_delivery] as $id_carriers_list => $carriers_list) {
foreach ($carriers_list as $carriers) {
if (is_array($carriers)) {
foreach ($carriers as $carrier) {
$carrier = array_merge($carrier, $this->objectPresenter->present($carrier['instance']));
$delay = $carrier['delay'][$this->context->language->id];
unset($carrier['instance'], $carrier['delay']);
$carrier['delay'] = $delay;
if ($this->isFreeShipping($this->context->cart, $carriers_list)) {
$carrier['price'] = $this->translator->trans('Free', array(), 'Shop.Theme.Checkout');
} else {
if ($include_taxes) {
$carrier['price'] = $this->priceFormatter->convertAndFormat($carriers_list['total_price_with_tax']);
if ($display_taxes_label) {
$carrier['price'] = sprintf($this->translator->trans('%s tax incl.', array(), 'Shop.Theme.Checkout'), $carrier['price']);
}
} else {
$carrier['price'] = $this->priceFormatter->convertAndFormat($carriers_list['total_price_without_tax']);
if ($display_taxes_label) {
$carrier['price'] = sprintf($this->translator->trans('%s tax excl.', array(), 'Shop.Theme.Checkout'), $carrier['price']);
}
}
}
if (count($carriers) > 1) {
$carrier['label'] = $carrier['price'];
} else {
$carrier['label'] = $carrier['name'] . ' - ' . $carrier['delay'] . ' - ' . $carrier['price'];
}
// If carrier related to a module, check for additionnal data to display
$carrier['extraContent'] = '';
if ($carrier['is_module']) {
if ($moduleId = Module::getModuleIdByName($carrier['external_module_name'])) {
$carrier['extraContent'] = Hook::exec('displayCarrierExtraContent', array('carrier' => $carrier), $moduleId);
}
}
$carriers_available[$id_carriers_list] = $carrier;
}
}
}
}
}
return $carriers_available;
}
示例8: getBestSellers
protected function getBestSellers($params)
{
if (Configuration::get('PS_CATALOG_MODE')) {
return false;
}
if (!($result = ProductSale::getBestSalesLight((int) $params['cookie']->id_lang, 0, 3))) {
return Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false;
}
$currency = new Currency($params['cookie']->id_currency);
$usetax = Product::getTaxCalculationMethod((int) $this->context->customer->id) != PS_TAX_EXC;
foreach ($result as &$row) {
$row['price'] = Tools::displayPrice(Product::getPriceStatic((int) $row['id_product'], $usetax), $currency);
}
return $result;
}
示例9: getCartNbPoints
public static function getCartNbPoints($cart, $newProduct = NULL)
{
$total = 0;
if (Validate::isLoadedObject($cart)) {
$currentContext = Context::getContext();
$context = clone $currentContext;
$context->cart = $cart;
// if customer is logged we do not recreate it
if (!$context->customer->isLogged(true)) {
$context->customer = new Customer($context->cart->id_customer);
}
$context->language = new Language($context->cart->id_lang);
$context->shop = new Shop($context->cart->id_shop);
$context->currency = new Currency($context->cart->id_currency, null, $context->shop->id);
$cartProducts = $cart->getProducts();
$taxesEnabled = Product::getTaxCalculationMethod();
if (isset($newProduct) and !empty($newProduct)) {
$cartProductsNew['id_product'] = (int) $newProduct->id;
if ($taxesEnabled == PS_TAX_EXC) {
$cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int) $newProduct->getIdProductAttributeMostExpensive()), 2, '.', '');
} else {
$cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int) $newProduct->getIdProductAttributeMostExpensive()), 2, '.', '');
}
$cartProductsNew['cart_quantity'] = 1;
$cartProducts[] = $cartProductsNew;
}
foreach ($cartProducts as $product) {
if (!(int) Configuration::get('PS_LOYALTY_NONE_AWARD') and Product::isDiscounted((int) $product['id_product'])) {
if (isset(Context::getContext()->smarty) and is_object($newProduct) and $product['id_product'] == $newProduct->id) {
Context::getContext()->smarty->assign('no_pts_discounted', 1);
}
continue;
}
$total += ($taxesEnabled == PS_TAX_EXC ? $product['price'] : $product['price_wt']) * (int) $product['cart_quantity'];
}
foreach ($cart->getCartRules(false) as $cart_rule) {
if ($taxesEnabled == PS_TAX_EXC) {
$total -= $cart_rule['value_tax_exc'];
} else {
$total -= $cart_rule['value_real'];
}
}
}
return self::getNbPointsByPrice($total);
}
示例10: 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;
}
示例11: hookProductFooter
/**
* Returns module content for left column
*/
public function hookProductFooter($params)
{
$cache_id = 'crossselling_mod|productfooter|' . (int) $params['product']->id;
if (!$this->isCached('crossselling_mod.tpl', $this->getCacheId($cache_id))) {
$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT o.id_order
FROM ' . _DB_PREFIX_ . 'orders o
LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON (od.id_order = o.id_order)
WHERE o.valid = 1 AND od.product_id = ' . (int) $params['product']->id);
if (count($orders)) {
$list = '';
foreach ($orders as $order) {
$list .= (int) $order['id_order'] . ',';
}
$list = rtrim($list, ',');
if (Group::isFeatureActive()) {
$sql_groups_join = '
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = product_shop.id_category_default AND cp.id_product = product_shop.id_product)
LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category`)';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '=' . (int) Group::getCurrent()->id);
}
$order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price, product_shop.id_category_default, p.available_for_order, p.customizable, cl.link_rewrite category, p.ean13, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
FROM ' . _DB_PREFIX_ . 'order_detail od
LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
' . Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) : Product::sqlStock('p', 'product', false, $this->context->shop)) . '
LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = od.product_id' . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = od.product_id)
' . (Group::isFeatureActive() ? $sql_groups_join : '') . '
WHERE od.id_order IN (' . $list . ')
AND pl.id_lang = ' . (int) $this->context->language->id . '
AND cl.id_lang = ' . (int) $this->context->language->id . '
AND od.product_id != ' . (int) $params['product']->id . '
AND i.cover = 1
AND product_shop.active = 1
' . (Group::isFeatureActive() ? $sql_groups_where : '') . '
ORDER BY RAND()
LIMIT ' . (int) Configuration::get('CROSSSELLING_NBR_M'));
$tax_calc = Product::getTaxCalculationMethod();
foreach ($order_products as &$order_product) {
$order_product['id_product'] = (int) $order_product['product_id'];
$order_product['image'] = $this->context->link->getImageLink($order_product['link_rewrite'], (int) $order_product['product_id'] . '-' . (int) $order_product['id_image'], ImageType::getFormatedName('home'));
$order_product['link'] = $this->context->link->getProductLink((int) $order_product['product_id'], $order_product['link_rewrite'], $order_product['category'], $order_product['ean13']);
if ($tax_calc == 0 || $tax_calc == 2) {
$order_product['price'] = Product::getPriceStatic((int) $order_product['product_id'], true, null);
} elseif ($tax_calc == 1) {
$order_product['price'] = Product::getPriceStatic((int) $order_product['product_id'], false, null);
}
$order_product['allow_oosp'] = Product::isAvailableWhenOutOfStock((int) $order_product['out_of_stock']);
}
$order_products = Product::getProductsProperties((int) $this->context->language->id, $order_products);
$this->smarty->assign(array('order' => false, 'orderProducts' => $order_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'middlePosition_crossselling' => round(count($order_products) / 2, 0), 'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE_M')));
}
}
return $this->display(__FILE__, 'crossselling_mod.tpl', $this->getCacheId($cache_id));
}
示例12: calcPrice
/**
* Calculates the price (including tax if applicable) and returns it.
*
* We need to check if taxes are to be included in the prices, given that they are configured.
* This is determined by the "Price display method" setting of the active user group.
* Possible values are 1, tax excluded, and 0, tax included.
*
* @param Product $product the product model.
* @param Context $context the context to calculate the price on (currency conversion).
* @param bool $discounted_price if discounts should be applied.
* @return string the calculated price.
*/
protected function calcPrice(Product $product, Context $context, $discounted_price = true)
{
$incl_tax = (bool) (!Product::getTaxCalculationMethod((int) $context->cookie->id_customer));
$specific_price_output = null;
$value = Product::getPriceStatic((int) $product->id, $incl_tax, null, 6, null, false, $discounted_price, 1, false, null, null, null, $specific_price_output, true, true, $context, true);
return Nosto::helper('price')->format($value);
}
示例13: hookProductFooter
/**
* Returns module content for left column
*/
public function hookProductFooter($params)
{
global $smarty, $cookie, $link;
$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT o.id_order
FROM ' . _DB_PREFIX_ . 'orders o
LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON (od.id_order = o.id_order)
WHERE o.valid = 1 AND od.product_id = ' . (int) $params['product']->id);
if (sizeof($orders)) {
$list = '';
foreach ($orders as $order) {
$list .= (int) $order['id_order'] . ',';
}
$list = rtrim($list, ',');
$orderProducts = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, p.show_price, cl.link_rewrite category, p.ean13
FROM ' . _DB_PREFIX_ . 'order_detail od
LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = od.product_id)
LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = p.id_category_default)
LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = od.product_id)
WHERE od.id_order IN (' . $list . ') AND pl.id_lang = ' . (int) $cookie->id_lang . ' AND cl.id_lang = ' . (int) $cookie->id_lang . '
AND od.product_id != ' . (int) $params['product']->id . ' AND i.cover = 1 AND p.active = 1
ORDER BY RAND()
LIMIT 10');
$taxCalc = Product::getTaxCalculationMethod();
foreach ($orderProducts as &$orderProduct) {
$orderProduct['image'] = $link->getImageLink($orderProduct['link_rewrite'], (int) $orderProduct['product_id'] . '-' . (int) $orderProduct['id_image'], 'medium');
$orderProduct['link'] = $link->getProductLink((int) $orderProduct['product_id'], $orderProduct['link_rewrite'], $orderProduct['category'], $orderProduct['ean13']);
if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') and ($taxCalc == 0 or $taxCalc == 2)) {
$orderProduct['displayed_price'] = Product::getPriceStatic((int) $orderProduct['product_id'], true, NULL);
} elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') and $taxCalc == 1) {
$orderProduct['displayed_price'] = Product::getPriceStatic((int) $orderProduct['product_id'], false, NULL);
}
}
$smarty->assign(array('orderProducts' => $orderProducts, 'middlePosition_crossselling' => round(sizeof($orderProducts) / 2, 0), 'crossDisplayPrice' => Configuration::get('CROSSSELLING_DISPLAY_PRICE')));
}
return $this->display(__FILE__, 'crossselling.tpl');
}
示例14: hookExtraRight
public function hookExtraRight($params)
{
include_once dirname(__FILE__) . '/LoyaltyModule.php';
$product = new Product((int) Tools::getValue('id_product'));
if (Validate::isLoadedObject($product)) {
if (Validate::isLoadedObject($params['cart'])) {
$pointsBefore = (int) LoyaltyModule::getCartNbPoints($params['cart']);
$pointsAfter = (int) LoyaltyModule::getCartNbPoints($params['cart'], $product);
$points = (int) ($pointsAfter - $pointsBefore);
} else {
if (!(int) Configuration::get('PS_LOYALTY_NONE_AWARD') && Product::isDiscounted((int) $product->id)) {
$points = 0;
$this->smarty->assign('no_pts_discounted', 1);
} else {
$points = (int) LoyaltyModule::getNbPointsByPrice($product->getPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true, (int) $product->getDefaultIdProductAttribute()));
}
$pointsAfter = $points;
$pointsBefore = 0;
}
$this->smarty->assign(array('points' => (int) $points, 'total_points' => (int) $pointsAfter, 'point_rate' => Configuration::get('PS_LOYALTY_POINT_RATE'), 'point_value' => Configuration::get('PS_LOYALTY_POINT_VALUE'), 'points_in_cart' => (int) $pointsBefore, 'voucher' => LoyaltyModule::getVoucherValue((int) $pointsAfter), 'none_award' => Configuration::get('PS_LOYALTY_NONE_AWARD')));
return $this->display(__FILE__, 'product.tpl');
}
return false;
}
示例15: hookDisplayProductButtons
public function hookDisplayProductButtons($params)
{
$taxes = Product::getTaxCalculationMethod();
$id_product = (int) Tools::getValue('id_product');
if ($taxes == 0 || $taxes == 2) {
$askforprice_product_price = Product::getPriceStatic($id_product, true, null, 2);
} elseif ($taxes == 1) {
$askforprice_product_price = Product::getPriceStatic($id_product, false, null, 2);
}
$this->context->smarty->assign(array('ASKFORPRICE_MINIMAL_PRICE' => Configuration::get('ASKFORPRICE_MINIMAL_PRICE', null), 'askforprice_product_price' => $askforprice_product_price, 'askforprice_form_url' => $this->context->link->getModuleLink('askforprice', 'form', array('id_product' => $id_product))));
return $this->display($this->_path, 'views/templates/front/askforprice.tpl');
}