magento“X 购买”依靠交易

发布于 2024-11-02 23:41:46 字数 746 浏览 0 评论 0原文

我设法修改了一些magento的代码来实现我们自己的第3方网关, 但我在交易中遇到了错误的“购买”计数问题 当有人执行订单时,当 saveOrderAction 运行时,计数会直接增加(在成功或失败页面之前 - 失败时计数会再次减少,这是正确的 - 但我不希望它在成功页面之前增加) 在这个阶段,订单在系统中保存为“正在处理”,

我没有的代码基本上是: 在“saveOrderAction”中,我有一个条件检查所选的付款方式,

如果是我们的第3方,它会重定向到第3方页面, 然后我将一些参数从第3方页面传递回magento到“successAction”或“failureAction”(无论哪种情况),

然后相应地保存订单,将其状态设置为完成,依此类推......

我想要什么要做的只是在付款成功后增加“购买”计数,如果有人可以让我了解如何在 magento 中实现“购买”的逻辑,

我确实知道这发生在函数 saveOrder() 中model mage\checkout\model\type\onepage.php :

$service = Mage::getModel('sales/service_quote', $this->getQuote());
$service->submitAll(); 

但我无法弄清楚它发生在submitAll中的哪里...... 我想也许一开始我不应该保存订单,或者可能将其设置为不计入的不同状态,或者我不知道是什么?

任何帮助/建议将不胜感激! 谢谢 :)

I managed to modify some of magento's code to implement our own 3rd party gateway,
but I'm having trouble with incorrect "bought" count on the deal
when someone does the order, the count is increasing directly when saveOrderAction runs (before success or fail page - on fail the count is decreasing back again, which is right - but I do not want it to increase before success page)
at this stage, the order is saved as 'processing' in the system

the code I have no basically is:
in the "saveOrderAction" I have a condition that checks the payment method selected,

if it is our 3rd party, it redirects to the 3rd party page,
then I pass some parameters from the 3rd party page back to magento to the 'successAction' or 'failureAction' (whichever is the case),

then accordingly save the order, set its state as complete, and so on...

what I want to do is only increase the 'bought' count after payment is successful, if someone can give me insight of the logic of how the 'bought' is implemented in magento

I do know this occurs in the function saveOrder() in model mage\checkout\model\type\onepage.php :

$service = Mage::getModel('sales/service_quote', $this->getQuote());
$service->submitAll(); 

but I can't figure out where in submitAll it is occuring...
I assume maybe at first I should not save the order, or maybe set it at a different state where it is not counted or I don't know what?

any help/suggestion would be greatly appreciated!
thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半葬歌 2024-11-09 23:41:46

执行此操作的一种方法(可能会省去一些麻烦)是将观察者添加到符合您需要的事件中。特别是,有几个可能适合 Mage_Sales_Model_Order_Payment 的事件:

sales_order_payment_save_after
sales_order_payment_capture
sales_order_payment_pay
... several more ...

如果您查看这些事件,您可能会发现其中一个事件是添加到您的销售数量的合理时间。同样,该对象上有用于取消或退款订单的事件,您可以根据需要使用这些事件来减少销售额。

我通常避免挂钩此类行为的控制器操作,因为我无法保证 Magento 始终按照我假设的方式使用该操作。

无论如何,请告诉我这是否有帮助或者您是否仍然有同样的问题。希望有帮助!

谢谢,

One way to do this, that might save some trouble, would be to add an Observer to an event that matches your need. Particularly, there are several events for Mage_Sales_Model_Order_Payment that might be appropriate:

sales_order_payment_save_after
sales_order_payment_capture
sales_order_payment_pay
... several more ...

If you take a look at these events, you may find that one of them is a reasonable time to add to your sold count. Similarly, there are events on that object for cancelling or refunding orders, which you could use to decrement sales as necessary.

I usually avoid hooking into controller actions for this type of behavior because I cannot guarantee that Magento will always use that action in the way that I assume.

Anyway, let me know if that was helpful or if you still have the same question. Hope that helps!

Thanks,
Joe

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文