如何从 Magento 的 Onepage Checkout 获取发布数据?
为了在 Magento Checkout 中添加客户评论字段,我在相应的模板文件中添加了一个文本字段,并使用如下观察器将评论添加到订单中:
$comment = strip_tags(Mage::app()->getRequest()->getParam('cpOrderComment'));
if(!empty($comment)){
$observer->getEvent()->getOrder()->setCustomerNote($_comments);
}
这在使用 OnestepCheckout 扩展时效果很好,但它不适用于Magento 的单页结账。 “getParam('cpOrderComment')”始终为空,现在我不确定如何获取文本字段的值。
任何想法将不胜感激!
in order to add a customers comment field in the Magento Checkout, I added a text field in the appropriate template file and added the comment to the order using an observer like this:
$comment = strip_tags(Mage::app()->getRequest()->getParam('cpOrderComment'));
if(!empty($comment)){
$observer->getEvent()->getOrder()->setCustomerNote($_comments);
}
This worked perfectly using the OnestepCheckout extension, however it does not work with Magento's Onepage Checkout. The "getParam('cpOrderComment')" is always empty and now I not sure how to get the value of my text field.
Any ideas would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题就解决了。结账的审核部分由skin/frontend/base/default/js/opcheckout.js中第820行左右的save函数提交。
该函数不会考虑agreements.phtml中的所有字段,而只会考虑其中的字段$('ol#checkout-agreements') - 想想看...
解决方案显然是将字段放在 ul#checkout-agreements 中,或者更改 opcheckout.js 以包含协议.phtml 中的所有字段。
This problem is solved. The review part of the checkout is submited by the save function in skin/frontend/base/default/js/opcheckout.js around line 820.
This function does not take all fields into account from the agreements.phtml, but only the ones inside $('ol#checkout-agreements') - go figure...
The solution is obviously to to put the field inside the ul#checkout-agreements or to change opcheckout.js to include all the fields from the agreements.phtml.