首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magento -在购物车/订单中获得含税和折扣的产品价格(Criteo标签)

Magento -在购物车/订单中获得含税和折扣的产品价格(Criteo标签)
EN

Stack Overflow用户
提问于 2014-08-18 16:37:20
回答 2查看 4.5K关注 0票数 1

对于Criteo标签的实现,我试图通过税收和折扣获得购物车(和成功页面)中所有产品的价格(以及其他东西)。我目前正在做这样的事情,但它只显示有折扣和无税的价格:

代码语言:javascript
复制
$cartAllItems = Mage::getModel('checkout/cart')->getItems();
foreach ($cartAllItems as $item){
    $price = Mage::helper('tax')->getPrice($item->getProduct(), $item->getProduct()->getFinalPrice());
    // other things
}

我已经测试了很多东西,但都不能让它工作。Thx帮助

EN

回答 2

Stack Overflow用户

发布于 2014-08-18 19:16:22

我觉得你可以用,

代码语言:javascript
复制
Mage::helper('checkout')->getQuote()->getShippingAddress()->getData('tax_amount')

这将返回您的总税额。或者您可以使用

代码语言:javascript
复制
$totalItemsInCart = Mage::helper('checkout/cart')->getItemsCount();
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); 
$subtotal = round($totals["subtotal"]->getValue()); 
$grandtotal = round($totals["grand_total"]->getValue()); 
if(isset($totals['discount']) && $totals['discount']->getValue()) {
   $discount = round($totals['discount']->getValue()); 
} else {
   $discount = '';
}
if(isset($totals['tax']) && $totals['tax']->getValue()) {
  $tax = round($totals['tax']->getValue()); 
} else {
  $tax = '';
}

我猜根据您的需求对进行了修改

代码语言:javascript
复制
foreach ($productIds as $productId) {
  $_product  = Mage::getModel('catalog/product')->load($productId);   
  $productsPrice = floatval($_product->getData("price")); 

  // Get the product's tax class' ID
  $taxClassId = $_product->getData("tax_class_id");
  echo 'Tax Class ID '.$taxClassId.'
';
  // Get the tax rates of each tax class in an associative array
  $taxClasses  = Mage::helper("core")->jsonDecode( Mage::helper("tax")-        
>getAllRatesByProductClass() );
  echo 'Tax Classes '.$taxClasses.'
';
  // Extract the tax rate from the array
  $taxRate   = $taxClasses["value_".$taxClassId];
  echo 'Tax Rate '.$taxRate.'
';
 }
 ?>
票数 1
EN

Stack Overflow用户

发布于 2020-04-05 08:32:29

您可以获得每件商品的折扣和税值,并进行计算。

代码语言:javascript
复制
$_item->getDiscountAmount
$_item->getTaxAmount

$totalItemPrice = $_item->getPrice - $_item->getDiscountAmount + $_item->getTaxAmount
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25359244

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档