=== Jalma Conditional Payment Methods ===
Contributors: jonashjalmarsson
Tags: woocommerce, payment methods, payment gateways, checkout, conditional
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.3.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Hide WooCommerce payment methods with simple rules — cart total, item count, country, customer role or cart contents.

== Description ==

A small, single-purpose plugin: hide a payment method when the cart matches a rule. No sprawling settings, no upsell, nothing phoning home.

Each rule is one line — pick a payment method, choose a condition, and set the value. Add as many rules as you like, under **WooCommerce → Payment Rules**.

**Conditions you can check:**

* **Cart total** — less/greater than an amount (tick a box to compare without shipping).
* **Item count** — less/greater than a number of items.
* **Shipping country** — is / is not one of a list of ISO codes (e.g. `SE, NO`).
* **Customer role** — is / is not a given role (including "Guest" for logged-out visitors).
* **Cart contents** — digital only, or contains a physical product.

Typical uses: hide the invoice option on orders under 500 kr, restrict a gateway to one country, offer a B2B method only to a wholesale role, or hide cash-on-delivery on digital-only carts.

== Installation ==

1. Install and activate the plugin.
2. Go to **WooCommerce → Payment Rules**.
3. Add one or more rules and save. Each rule hides its payment method when the cart matches.

== Frequently Asked Questions ==

= Which cart amount is compared? =

By default the order total (what the customer pays). On the "Cart total" condition you can tick **excl. shipping** to compare the total without the shipping cost.

= Does it work with the block checkout? =

Yes. It filters `woocommerce_available_payment_gateways`, which WooCommerce uses to build the payment list on both the classic and block checkout.

= Can I show a method only in some cases instead of hiding it? =

Rules hide methods. To "only show X for role Y", add a rule that hides X when the role **is not** Y.

== Screenshots ==

1. The rules table under WooCommerce → Payment Rules — hide a payment method by cart total (with or without shipping), shipping country, customer role, or cart contents.

== Changelog ==

= 1.3.0 =
* Developer: added extension hooks (jcpm_rule_matches, jcpm_save_rule, jcpm_rule_row_extra, jcpm_settings_enqueue) and a public Rules::condition_matches() so add-ons can extend the rule engine. No change to how the plugin behaves on its own.

= 1.2.1 =
* Cleaner rule layout — reads When → Is → Value → Hide this method — and a nicer on/off toggle for "exclude shipping".

= 1.2.0 =
* A rule can now target several payment methods at once (searchable multi-select), instead of one method per rule.

= 1.1.0 =
* New conditions: shipping country, customer role, and cart contents (digital vs physical).
* "Cart total" can now compare with or without shipping (excl. shipping checkbox).

= 1.0.0 =
* First release. Rule table: hide a payment method by cart total or item count, less/greater than a value.
