=== Beziworld - Payment Rules ===
Contributors: beziworld
Tags: woocommerce, payment methods, payment gateways, conditional payments, checkout fees
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Show, hide, limit, sort and price WooCommerce payment methods by shipping, country, cart, products and customer. Classic and block checkout.

== Description ==

Beziworld - Payment Rules decides which payment methods a customer sees at checkout and what they cost. It works the same in the classic checkout, the checkout block, the order-pay page and the Store API.

= Quick matrix =

Tick which payment methods are not available for each shipping method. Cash on delivery for parcel lockers, bank transfer for local pickup: a common setup takes a minute.

= Rules =

Every rule has conditions and actions. Conditions in a group must all match, and a rule applies when any of its groups matches.

Conditions:

* Shipping: shipping method or rate, shipping zone, shipping country, whether the order needs shipping.
* Cart: cart total (with or without discounts, tax and shipping), number of items, weight, coupons.
* Products: product, category, tag, shipping class, product type (including virtual and downloadable), stock status.
* Customer: billing country, logged in, role, number of previous orders, total spent, business customer with a VAT number.
* Store: currency, language (WPML, Polylang), day of the week, time of day, date range.

Actions:

* Hide payment methods, or show only some of them.
* Show a payment method as unavailable, with a reason the customer can read.
* Allow a payment method only between a minimum and a maximum order amount.
* Add a fee or a discount: fixed, percentage, per item or in tiers by order amount, with a minimum, a maximum, a tax class and amounts per currency.
* Highlight a payment method with a badge, change its position, preselect it, or change its title and description.

= Built for real checkouts =

* Fees are added only after the customer actually chooses a payment method, and express payment buttons never get a fee.
* When the fee changed between the moment the customer saw the total and the moment they placed the order, the order is stopped with a message instead of being charged a different amount.
* On the order-pay page only payment methods with the same fee as the order are offered, so a placed order is never repriced.
* A fallback payment method keeps customers able to pay when the rules leave nothing.
* Every decision can be written to the WooCommerce log.

= Surcharge restriction for the EU =

EU and Polish law do not allow a consumer surcharge for using a payment card, a bank transfer, BLIK or other common payment instruments. Assign a type to every payment method and the plugin will not charge consumers a fee for restricted types. Business customers, recognised by a VAT number, can still be charged, and discounts are always allowed. Payment methods without a type count as restricted until you classify them.

= Tools =

* Simulator: describe an order and see which payment methods remain, which fees apply and which rule decided.
* Diagnostics: finds rules that point to removed payment or shipping methods, fees that will not be charged and settings that leave customers without a way to pay.
* Report: orders, revenue and fees per payment method.
* Templates for common Polish store setups.
* Import and export as JSON, from the screen, from WP-CLI or through GraphQL.

= Display anywhere =

* Shortcode `[bwpr_payment_methods]`, a "Payment methods" block and an Elementor widget show which payment methods the current cart can use.
* All front-end output comes from templates a theme can override, and the small stylesheet can be switched off, so classic themes and page builders can restyle everything.

= For developers =

Every part can be extended or replaced with WordPress filters and actions: condition types, action types, the evaluator, the context, the result, the surcharge policy, the templates, the REST routes and the admin screen (through wp.hooks). See the hooks reference in README.md.

= Integrations =

* WooCommerce checkout block and Store API, classic checkout, order-pay page, HPOS.
* WPML, Polylang, WPML Multi-Currency, CURCY, Aelia Currency Switcher and WOOCS for language and currency.
* WP-CLI: `wp bwpr list`, `export`, `import`, `diagnose`, `simulate`, `report`.
* WPGraphQL: the decision for the current cart and the configuration for shop managers.

Documentation and support: https://beziworld.eu/projekty/payment-rules

== Installation ==

1. Install and activate WooCommerce.
2. Upload the plugin folder to `/wp-content/plugins/` or install it from the Plugins screen, then activate it.
3. Go to WooCommerce > Payment rules.
4. Start with the quick matrix or add a rule, then check the result in the Simulator.

== Frequently Asked Questions ==

= Does it work with the checkout block? =

Yes. The block receives the decision from the server with the cart, so the payment list, the fees and the totals always match what the classic checkout would show.

= Can I charge a fee for card or bank transfer payments? =

Not to consumers in the EU. The surcharge restriction is on by default and blocks such fees for consumers. You can classify your payment methods, set a maximum fee for allowed types or switch the restriction off if your store is outside the EU. This is not legal advice; check the rules that apply to your store.

= What happens if no payment method is left? =

The fallback payment method from the settings is offered. Without a fallback the customer sees the message you set, or the standard WooCommerce message.

= Will my rules be removed when I delete the plugin? =

No, unless you switch off "Keep rules and settings when the plugin is deleted". Data stored on orders is never removed.

= Can I change how the lists look in my theme? =

Copy a file from `templates/` in the plugin folder to `beziworld-payment-rules/` in your theme and edit the copy. To drop the plugin stylesheet, use `add_filter( 'bwpr_enqueue_frontend_styles', '__return_false' );`.

= Does it slow down the checkout? =

Rules are evaluated in memory once per request and cached for that request. Customer history is read only when a rule uses it.

= Where do I report a problem? =

Use the "Report a problem" form on the plugin page: https://beziworld.eu/projekty/payment-rules. Please include your WooCommerce version, the checkout you use (classic or block) and, if you can, an export of your rules from Tools.

== Screenshots ==

1. Quick matrix: choose which payment methods go with each shipping method.
2. Rule editor with conditions, actions, fees and a readable summary of every rule.
3. Surcharge restriction: payment types that consumers are never charged a fee for.
4. Simulator: describe an order and see which payment methods remain and why.
5. Report: orders, revenue and fees per payment method.
6. About the author, with an optional way to support the development.

== Changelog ==

= 1.0.2 =
* Fix: the checkout block no longer stops responding with a "Maximum call stack size exceeded" error after an order is refused.

= 1.0.1 =
* Fix: select fields in the settings screen keep readable colours on hover, on focus and in the opened list, in both the dark and the light theme.
* Fix: links styled as buttons are no longer underlined or recoloured on hover.
* Change: the plugin name is now "Beziworld - Payment Rules".
* Change: the text domain now matches the plugin slug, beziworld-payment-rules-for-woocommerce.

= 1.0.0 =
* First release.
* "About the author" tab with the author details and an optional way to support the development, linked from the Plugins screen.

== Upgrade Notice ==

= 1.0.2 =
The checkout block keeps working after a refused order.

= 1.0.1 =
Readable select fields and button links in the settings screen.

= 1.0.0 =
First release.
