是否可以在 Satchmo 中根据特定类别或特定产品配置付款方式?
我有一家由 Satchmo 支持的商店,需要有一个特殊的商品类别,仅适用于通过货到付款方式付款的用户。
除了对结帐流程进行硬编码之外,是否有任何简单的方法可以将特定产品类别的付款选项限制为仅限货到付款?
I have a Satchmo-powered shop that needs to have a special item category available only for users that pay by cash-on-delivery method.
Short of hard-coding the checkout process, is there any easy way I can use to restrict payment options for particular product category to cash-on-delivery only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决方案是 Satchmo 几乎为每个操作发出信号,因此在构建支付方式表单时,您必须侦听特定信号,然后重新定义传递给侦听器的 methods kwarg 变量:
Solution is that Satchmo emits signals almost for every action, so on construction of payment methods form you have to listen to a specific signal and then redefine methods kwarg variable which gets passed to listener:
上一个答案中有一个问题(我知道,因为我刚刚尝试过),在以下行中:
问题是,在原始方法列表中,创建了一个全新的列表,并存储在相同的变量名中。这不会影响Satchmo传入的原始列表,因此Satchmo甚至不会知道。
您需要做的实际上是使用“methods.remove(...)”等方法修改传入的列表对象。
在特定的例子中,它应该是这样的:
也许我的代码不是最优雅的;也许有人可以改进它,并可能将其与原始答案结合起来。
There is one problem in the previous answer (I know because I just tried myself), in the following line:
Problem is, out of the original methods list, a completely new list is created, and stored in the same variable name. This will not affect the original list that Satchmo passed in, so Satchmo won't even know.
What you need to do is actually modify the list object passed in, using methods like 'methods.remove(...)'.
In the particular example, it should be something like this:
Maybe my code is not the most elegant; maybe someone can improve it, and possibly integrate it with the original answer.