gpt4 book ai didi

php - PayPal 网关已拒绝请求。购物车商品总金额与订单金额不匹配。洋红色

转载 作者:太空宇宙 更新时间:2023-11-03 16:29:37 25 4
gpt4 key购买 nike

我很清楚发生了什么。我不知道如何解决它。由于我要求 paypal 包括订单项,它计算了总订单项,但它们与总计不匹配。

配置文件

    <sales>
<quote>
<totals>
<biddiscount>
<class>winints/biddiscount</class>
<before>subtotal</before>
</biddiscount>
<globaldiscount>
<class>winints/globaldiscount</class>
<before>subtotal</before>
</globaldiscount>
</totals>
</quote>
</sales>

GlobalDiscount 类

<?php
/**
* Created by PhpStorm.
* User: numerical25
* Date: 5/17/14
* Time: 7:49 PM
*/

class Superior_WinInts_Model_Globaldiscount extends Mage_Sales_Model_Quote_Address_Total_Subtotal {

protected $amount = 0;
protected $set = 0;

public function collect(Mage_Sales_Model_Quote_Address $address) {
if ($address->getData('address_type') == 'billing')
return $this;
$discount = Mage::app()->getRequest()->getParam('global_discount_amount');
$grandTotal = $address->getGrandTotal();
$baseGrandTotal = $address->getBaseGrandTotal();
if(Mage::getSingleton('customer/session')->isLoggedIn() && $discount) {

$customer = Mage::getModel('customer/customer')->load(Mage::getSingleton('customer/session')->getId());
$credit = Mage::getModel("winints/wallet")
->getCustomerStoreCreditTotal($customer->getId());
if($credit >= $discount) {
$this->amount = $discount;
}
Mage::getSingleton('core/session')->setGlobalDiscount($discount);

$totals = array_sum($address->getAllTotalAmounts());
$baseTotals = array_sum($address->getAllBaseTotalAmounts());
//You have to set Grand and Base Grand Total for this crap to work
$address->setDiscountAmount(-$discount);
$address->setBaseDiscountAmount(-$discount);
$address->setGrandTotal($grandTotal - $discount);
$address->setBaseGrandTotal($baseGrandTotal - $discount);
$address->setSubtotal($baseGrandTotal - $discount);

} else if (Mage::getSingleton('core/session')->getGlobalDiscount()) {
$discount = Mage::getSingleton('core/session')->getGlobalDiscount();
$this->amount = Mage::getSingleton('core/session')->getGlobalDiscount();
$address->setDiscountAmount(-$discount);
$address->setBaseDiscountAmount(-$discount);
$address->setGrandTotal($grandTotal - $discount);
$address->setBaseGrandTotal($baseGrandTotal - $discount);
$address->setSubtotal($baseGrandTotal - $discount);
}
return $this;
}

public function fetch(Mage_Sales_Model_Quote_Address $address)
{
if(Mage::getSingleton('core/session')->getGlobalDiscount()) {
if(!$this->set) {
$address->addTotal(array(
'code'=>$this->getCode(),
'title'=>Mage::helper('catalog')->__('Global Discount (-)'),
'value'=> $this->amount
));
$this->set = 1;
}
}
return $this;
}
}

我已经完成了教程告诉我的所有事情,我尝试更新基本总计、总计、小计,所有内容。它仍然没有正确匹配

我做错了什么??

还有其他帖子,但不清楚。显然,总计中的行项目计算不正确。 .

最佳答案

弄清楚了,是的,网上的引用资料是不正确的。

在你的配置文件中

            <globaldiscount>
<class>winints/globaldiscount</class>
<before>subtotal</before>
</globaldiscount>

将标签中的值更改为“grand_total”

<after>grand_total</after>

如果您将其放在小计之前或之后,您的折扣将不会注意到总计,因为总计是最后计算的。

因此您的代码可能会计算小计但不会计算总计,这可能会给 paypal 带来不准确的估计

关于php - PayPal 网关已拒绝请求。购物车商品总金额与订单金额不匹配。洋红色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26160890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com