小编Unf*_*foX的帖子

Magento,getSubtotal和getGrandTotal总是返回零

我有一个奇怪的问题.我开发了一个模块,根据数据库中的某些值为总计添加一行.但是当我打电话时,我的模块模型(继承自Mage_Sales_Model_Quote_Address_Total_Abstract)

$address->getSubtotal()
Run Code Online (Sandbox Code Playgroud)

要么

$address->getGrandTotal()
Run Code Online (Sandbox Code Playgroud)

或任何其他总计方法,我得到零(0)返回.但是在phpmyadmin中,我看到那些值不是零.除这些总计列之外的任何其他列都返回其正确的值(即,getAddressId()返回ID,getAddressType返回"运送"等)

可能是什么问题,任何想法?谢谢----------编辑-----------好的,在@Alan Storm的评论之后,我看到我应该更清楚了.我正在尝试开发分期付款模块.我将在管理员中设置分期付款(根据月数更改),并且我会在结账时将此费用添加到购物车总额中.

这是我的收集方法,

public function collect(Mage_Sales_Model_Quote_Address $address)
{

$address->setInstalmentCount(2); //instalment count is hardcoded as 2 for debugging

$paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
$paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
if ($paymentMethod != 'oos' && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())){            
    return $this;
}

$paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();

if ($paymentMethod->getCode() != 'oos') {            
    return $this;
}

$items = $address->getAllItems();
if (!count($items)) {
    return $this;
}

$baseTotal = $address->getBaseGrandTotal();   // THIS ALWAYS RETURNS ZERO

// adress is the reference for grand …
Run Code Online (Sandbox Code Playgroud)

php model totals magento cart

5
推荐指数
1
解决办法
4773
查看次数

标签 统计

cart ×1

magento ×1

model ×1

php ×1

totals ×1