Opencart extensions free download · 5 min read · Updated

Payment Method Rules for OpenCart 4 and 3: Show Payment Methods by Customer Group, Total and Category (Free Extension)

Limit Cash on Delivery, Bank Transfer and other payment methods by customer group, sub-total, shipping method and category, in OpenCart 4 and 3.

Opencart payment method rules

OpenCart lets you limit a payment method by geo zone and order total, and that’s about it. Real stores need more. Cash on Delivery is fine for a $40 order but risky for a $900 one. Bank Transfer makes sense for wholesale accounts, not for every guest. And some products, like expensive cameras, should never ship COD at all.

Payment Method Rules is a free extension that adds those conditions. You write a rule per payment method: which customer groups can use it, the cart sub-total range, which shipping methods it works with, and which categories block it. At checkout, a method only shows up when its rule matches. It comes in two builds, one for OpenCart 4.1.0.4 and one for OpenCart 3.0.5.1, and we tested both on real checkouts.

Download Payment Method Rules

Payment Method Rules settings in OpenCart 4 with two rules: Cash On Delivery at most 300 and hidden for the Cameras category, and Bank Transfer only for the Wholesale customer group
Two rules: COD only up to $300 and never for cameras, and Bank Transfer only for wholesale accounts.

What each rule can check

  • Payment method: any installed payment extension, such as Cash On Delivery, Bank Transfer, Cheque or PayPal.
  • Only for customer groups: tick the groups that may use it. Leave all unticked for any group. Guests are matched by the customer group they picked at checkout, or the store’s default group.
  • Only when the cart sub-total is at least / at most: the sub-total before shipping and taxes, in your default currency. Leave a box empty for no limit.
  • Only with shipping methods: for example, allow COD only with Store Pickup. This is only checked when the cart needs shipping, so downloads and gift cards aren’t blocked.
  • Hide when the cart has products from: one or more categories. If any product in the cart is in one of them, the method is hidden.
  • Admin note: a reminder for yourself, such as “COD only for local orders under $200”.

Every filled-in condition must match. Empty conditions are ignored, and payment methods without a rule are left alone. That makes it safe to install: until you add a rule, nothing changes.

Install in OpenCart 4

  1. Go to Extensions > Installer, upload paymentrules.ocmod.zip and click the green +.
  2. Go to Extensions > Extensions, choose Modules, and install Payment Method Rules.
  3. Click the blue pencil to edit it, turn Status on, click Add rule and fill in the conditions. Save.

Install in OpenCart 3

  1. Go to Extensions > Installer and upload paymentrules.ocmod.zip. No modification refresh is needed.
  2. Go to Extensions > Extensions, choose Modules, and install Payment Method Rules.
  3. Edit it, set Status to Enabled, add your rules and click Save.
Payment Method Rules settings page in the OpenCart 3 admin with rule panels for payment method, customer groups, sub-total, shipping methods and categories
The same rules form in OpenCart 3.0.5.1.

What happened when we tested it

We used the two rules from the screenshot above on both stores, with Cash On Delivery and Bank Transfer enabled, and ran real checkouts with iPhones ($101 each in the demo data) and the Canon EOS 5D from the Cameras category.

CartCustomer groupPayment methods shown
2 iPhones, $202 sub-totalDefaultCash On Delivery only
3 iPhones, $303 sub-totalDefaultNone
3 iPhones, $303 sub-totalWholesaleBank Transfer only
iPhone and Canon EOS 5DDefaultNone

The results were the same on OpenCart 4.1.0.4 and 3.0.5.1. Bank Transfer was hidden for the Default group in every case, because its rule only allows Wholesale.

OpenCart 4 checkout payment step offering only Cash On Delivery for a 202 dollar cart
A $202 cart for a regular customer: only Cash On Delivery is offered.
OpenCart 4 checkout payment step offering only Bank Transfer to a wholesale customer
The same store for a Wholesale customer with a $303 cart: only Bank Transfer.

Be careful with rules that can hide every method. With a $303 cart and a regular account, both methods were hidden, and OpenCart showed its own message: “No Payment options are available. Please contact us for assistance!” The customer can’t finish the order. Keep at least one method without limits, such as a card gateway, unless that’s what you want.

OpenCart 4 checkout payment step showing the message No Payment options are available. Please contact us for assistance
When every method is filtered out, OpenCart shows “No Payment options are available”.

How it works

The extension doesn’t touch core files or payment extensions. In OpenCart 4 it adds one event on catalog/model/checkout/payment_method.getMethods/after. OpenCart builds the list of available methods, and the event removes the ones whose rule doesn’t match:

$cart = $this->cartFacts();

foreach ($rules as $rule) {
    $code = $rule['payment'] ?? '';

    if (isset($output[$code]) && !$this->matches($rule, $cart)) {
        unset($output[$code]);
    }
}

The rule check itself is short. Each condition only runs if you filled it in:

private function matches(array $rule, array $cart): bool {
    if (!empty($rule['customer_group']) && !in_array($cart['customer_group_id'], array_map('intval', $rule['customer_group']))) {
        return false;
    }

    if (($rule['total_min'] ?? '') !== '' && $cart['subtotal'] < (float)$rule['total_min']) {
        return false;
    }

    if (($rule['total_max'] ?? '') !== '' && $cart['subtotal'] > (float)$rule['total_max']) {
        return false;
    }

    // Shipping only matters when the cart needs shipping.
    if (!empty($rule['shipping']) && $cart['has_shipping'] && !in_array($cart['shipping'], $rule['shipping'])) {
        return false;
    }

    if (!empty($rule['category']) && array_intersect($cart['categories'], array_map('intval', $rule['category']))) {
        return false;
    }

    return true;
}

OpenCart 3 has no single “get all methods” model call. Each payment extension has its own getMethod(), so the OpenCart 3 build registers one wildcard event, catalog/model/extension/payment/*/getMethod/after, and empties the result for a method whose rule fails:

if (!preg_match('#^extension/payment/([a-z0-9_]+)/getMethod$#', $route, $match)) {
    return;
}

$rules = $this->config->get('module_paymentrules_rule');

if (!is_array($rules)) {
    return;
}

$cart = null;

foreach ($rules as $rule) {
    if (!isset($rule['payment']) || $rule['payment'] != $match[1]) {
        continue;
    }

    if ($cart === null) {
        $cart = $this->cartFacts();
    }

    if (!$this->matches($rule, $cart)) {
        $output = array();

        return;
    }
}

Because the filtering happens where OpenCart builds the list, the rules also apply when an admin creates an order, since the admin order screen uses the same catalog code.

Ideas for rules

  • COD for local pickup only: Cash On Delivery, shipping method Store Pickup.
  • No COD on big orders: Cash On Delivery, sub-total at most 300.
  • Invoice payment for trade accounts: Bank Transfer or Cheque, customer group Wholesale.
  • No pay-later on high-risk products: your buy-now-pay-later method, hidden for the categories where fraud happens most.

Please let us know if you have any questions or suggestions, and subscribe to our YouTube channel for more OpenCart video tutorials. You can also find us on Twitter and Facebook.

Rupak Nepali
Written byRupak Nepali

Rupak Nepali is a web developer, manage Webocreation website and the author of six books:
Getting Started with OpenCart Module Development (Packt, 2013),
OpenCart Theme and Module Development (Packt, 2015),
OpenCart 4: Dev Guide for Themes & Extensions (2024),
OpenCart 4: User Manual (2025),
Cloudflare for the Enterprise Website (2026) and
The Technical Web Guide for Marketers (2026).
Rupak has built OpenCart stores and extensions since 2010, has published more than 600 tutorials on Webocreation, and shares free OpenCart extensions on GitHub.
Find Rupak on
GitHub | Amazon | LinkedIn | X | YouTube.

Leave a Reply

Your email address will not be published. Required fields are marked *