如果库存低于阈值,则隐藏指定的付款方式

Hide Specified Payment method if stock is below threshold

如果产品的库存低于阈值或为 0,我想禁用卡支付方式,因为我有很多产品可以延期交货,但我不想通过借记卡或信用卡 因为已经有很多客户在下单后取消订单并付款,即使明确说明该产品是延期交货。

有人知道我该怎么做吗?

我建议在您的模块中编辑或覆盖 hookPaymentOption

检查 $this->context->cart->getProducts(),遍历产品,如果有问题就 return;

这是我根据 Krystian Podemski 的建议使用的解决方案

        $products = $this->context->cart->getProducts();
        foreach($products as $product){
            //var_dump($product);
            if($product['quantity_available'] == 0){
                return;
            }
        }