我是 prestashop 的新手,我需要知道是否有一种方法(通过代码)可以根据客户邮政编码限制可用的支付网关数量。例如,假设任何人在纽约购物只能通过 PayPal 付款,但美国其他城市可以使用任何支付网关。
我试过了,但它禁用了每个人的模块,而不是特定客户端的模块:
if (strcmp($postcode, "12345")) // postcode I want to restrict
{
// disabling other payment modules
$modules = PaymentModuleCore::getInstalledPaymentModules();
foreach ($modules as $module)
{
// fetch all installed module names
$name = $module['name'];
if (strcmp($name, "Paypal") != 0)
Module::getInstanceByName($name)->disable();
}
}
最佳答案
由于没有人回答,我已经用 Jquery 解决了这个问题,删除了模块 .tpl 中的其他选项
-- 编辑--
在模板的最后,我添加了这行JS:
<script type="text/javascript">
$(".payment_module").not(".mypaymentmodule").remove();
</script>
关于payment-gateway - Prestashop:付款方式取决于邮政编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23252889/