Magento 在结账页面保存订单总额
我们在结账页面有一个类似于礼品卡余额使用的系统。当客户在结账页面上时,客户可以使用他们的礼品卡余额来购买产品。
因此,我在付款选项卡之前添加了一个选项卡,其中客户可以选择输入礼品卡余额金额中使用的金额,因此当他们说继续时,我会在自定义 Onepage 控制器中获取输入的值并将其传递给 Onepage.php(模型类) ) 来减少总量。
这就是我在模型类上所做的事情。
public function saveCustomDiscount($discount=0)
{
$this->getQuote()->setGrandTotal($this->getQuote()->getGrandTotal() - $discount);
$this->getQuote()->setBaseGrandTotal($this->getQuote()->getBaseGrandTotal() - $discount);
$this->getQuote()->save();
//$this->getQuote()->collectTotals()->save();
$order = $this->getQuote()->getData();
Zend_Debug::dump($order);
return array();
}
我从控制器操作函数调用此函数并获取用户输入。
在这里,作为折扣传递的总金额和基本总额并没有减少。和原来的一样。
笔记 : 自定义订单保存之前。
array(51) {
---------------
["grand_total"] => string(8) "243.7200"
["base_grand_total"] => string(8) "243.7200"
-----------------
}
自定义订单保存后。
array(51) {
---------------
["grand_total"] => float(223.72)
["base_grand_total"] => float(223.72)
-----------------
}
进行调试时,数据类型从字符串更改为浮点数。我要做的就是减少定制折扣的订单总额。请帮我。
谢谢
We have a system like gift cards balance usage in the checkout page.While customers on the checkout page customers can use their Gift card balance amount to buy products.
So i have added a a tab before payment tab in which customers have option to enter the amount o use from their gift card balance amount so when they say proceed am getting the entered value in custom Onepage controller and pass it to Onepage.php(Model class) to reduce the total amount.
This is what am doing on the model class.
public function saveCustomDiscount($discount=0)
{
$this->getQuote()->setGrandTotal($this->getQuote()->getGrandTotal() - $discount);
$this->getQuote()->setBaseGrandTotal($this->getQuote()->getBaseGrandTotal() - $discount);
$this->getQuote()->save();
//$this->getQuote()->collectTotals()->save();
$order = $this->getQuote()->getData();
Zend_Debug::dump($order);
return array();
}
And am calling this function from the controller Action function were am getting the user input.
Here what ever am passing as discount the total amount and base total is not reducing. Its same as original.
Note :
Before custom order save.
array(51) {
---------------
["grand_total"] => string(8) "243.7200"
["base_grand_total"] => string(8) "243.7200"
-----------------
}
After custom order save.
array(51) {
---------------
["grand_total"] => float(223.72)
["base_grand_total"] => float(223.72)
-----------------
}
The data type is changed from string to float when am doing debug. What i have to do, to reduce the order total from the custom discount. Please help me.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你设置折扣码了吗?
后来,在报价中,您应用了折扣吗?
编辑
:
我和一个团队合作做了一个 Wordpress / Magento 混合体,它肯定给我留下了一些学习教训。 Magento 被用作纯粹的事务引擎,我们必须手动完成整个结帐过程(包括创建自定义 WP 插件来处理购物车中的每个步骤)。
最后将其记录下来,以便我们可以看到您拥有的内容(可能将其放入您编辑的问题中):
Did you set the discountCode?
Later on, in the Quote, did you apply the discount?
etc.
EDIT:
I've worked with a team to do a Wordpress / Magento hybrid and it's definitely left some learning lessons on me. Magento was used as a purely transactional engine and we had to do this entire checkout process by hand (including creating a custom WP plugin to handle each step in the cart).
Log this out at the end so we can see what you have (possibly put this in your edited question):