=== Stackedboost COD Deposit Rules for WooCommerce ===
Contributors: stackedboost
Tags: woocommerce, cash on delivery, cod, fake orders, advance payment
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Require an advance payment or hide Cash on Delivery for risky orders, using rules based on your own store data.

== Description ==

Cash on Delivery is convenient for customers, but it is also the order type most likely to be refused at the door. The customer never answers, the courier goes back, and the merchant pays for shipping in both directions with nothing to show for it.

Stackedboost COD Deposit Rules lets you set rules that catch the orders most likely to fail. When a rule matches it either asks for a partial advance payment, so the customer pays some of it now and the rest on delivery, or it simply takes Cash on Delivery off the table for that order.

Every rule runs on data your own store already has. There is no external service, no API key, no account to create, and no data leaves your site.

**What the free version does, in full:**

* Require an advance payment, as a percentage or a flat amount. When a rule matches, the checkout total drops to the deposit, the customer pays that with any normal payment method, and the balance is collected on delivery as usual. Cash on Delivery itself is withdrawn for that order, because Cash on Delivery collects nothing at checkout and so cannot take a deposit.
* Or skip the deposit entirely and simply hide COD when a rule matches, so the customer pays the full amount up front.
* Rules you can combine, all checked locally:
    * Cart total is above a threshold you set
    * Shipping country is different from billing country
    * Guest checkout with no previous completed order on the store
    * Customer has a previous order that was cancelled or failed while paying by COD
* Works with the classic checkout and the block based checkout.
* Compatible with High-Performance Order Storage (HPOS).
* Shows the balance still due on delivery on the order screen, in the admin order list, and in the order emails sent to the customer.

None of this is a fraud guarantee. It reduces your exposure by moving part of the payment up front on the orders most likely to be refused. Customers can still refuse a COD order after paying a deposit, though it happens far less often once money has changed hands.

**Stackedboost COD Deposit Rules Pro**

The paid version adds per-customer history of COD refusals and returns, CSV export of that history, a rule builder that supports AND/OR across multiple conditions, and the ability to bulk-apply a rule to existing pending orders. The free version does not need Pro to be useful. Pro is for stores that want deeper history and more rule combinations.

== Installation ==

1. Upload the `stackedboost-cod-deposit-rules` folder to `/wp-content/plugins/`, or install it through the Plugins screen in WordPress by searching for "Stackedboost COD Deposit Rules".
2. Activate the plugin through the Plugins screen.
3. Go to WooCommerce > Settings > COD Deposit Rules to set your rules and your advance payment amount or percentage.
4. Save. The rules take effect on the next checkout that matches them.

== Frequently Asked Questions ==

= Does this work with the WooCommerce block based checkout, or only the classic shortcode checkout? =

Both, and the block checkout needed real work rather than a claim. The advance payment is applied as a cart fee, which both checkouts calculate the same way. Hiding Cash on Delivery is different: the block checkout does not honour the usual payment gateway filter, so a plugin that only filters the gateway will appear to work on the classic checkout and quietly do nothing on the block one. This plugin publishes the decision onto the Store API cart and registers the front end callback WooCommerce documents for this, so the method is genuinely withdrawn in both. The gateway filter stays in place as well, so even if the script fails to load, an order cannot be placed with Cash on Delivery when a rule matched.

= Does this plugin send any of my store or customer data anywhere? =

No. Every rule is evaluated using data already stored in your WordPress database, on your own server. There is no external API call, no license check that phones home for the free version, and no analytics collection. Nothing about your orders or customers leaves your site.

= What actually happens to the advance payment and the balance? =

The advance payment is charged at checkout through whichever payment gateway you already use for prepaid methods on your store, exactly like a normal order paid in full. The remaining balance is recorded as a separate amount on the order (visible on the order screen, in the admin order list, and in the emails sent to the customer) so you and the customer both know what is still owed on delivery. The plugin does not automatically charge the balance. Collecting it on delivery is a manual, real-world step, the same as any other COD order.

= Does it work with my payment gateway? =

Yes, with any gateway. The advance payment is simply charged as the order total at checkout, using whatever gateway is enabled for that order. COD Deposit Rules does not require a specific gateway or add one of its own.

= Will this affect my sales reports or accounting? =

Be aware of this before you rely on it: when an advance payment applies, the order total recorded in WooCommerce is the amount actually charged at checkout, not the full cart value. The remaining balance is recorded separately, not folded into the order total. If you build reports directly off order totals, a COD order with an advance payment will show the deposit amount, not the full order value, so factor that in when reading revenue reports for COD orders.

= Can I set different rules for different amounts or countries at the same time? =

In the free version, all your active rules are checked together and if any one matches, the action you configured (require advance payment or hide COD) applies. Combining rules with AND/OR logic, so you can require different behavior depending on which combination of conditions is met, is a Pro feature.

= Does this stop chargebacks or guarantee I won't get a fake order? =

No. Nothing can guarantee that. This plugin reduces the financial exposure of a refused COD delivery by collecting part of the payment before the order ships. It does not detect fraud, verify identity, or block anyone from ordering.

== Screenshots ==

1. The COD Deposit Rules settings screen: when to act, how much to take up front, and the rules that decide.
2. The four built-in rules with their thresholds: order value, shipping versus billing country, guest with no prior order, and previous cancelled or failed COD orders.
3. The block checkout from the customer's side once a rule has matched. The order summary shows the subtotal, the balance held back for delivery, and the reduced amount payable now.
4. The order screen, showing what was paid at checkout, what the driver should collect, and which rules matched.
5. The orders list with the On delivery column, so a matching order is obvious without opening it.

== Changelog ==

= 1.0.0 =
* Initial release.
* Advance payment (percentage or flat amount) before COD is allowed.
* Option to hide COD entirely when a rule matches.
* Built-in rules: cart total threshold, shipping/billing country mismatch, guest checkout with no prior order, prior cancelled or failed COD order.
* Classic checkout and block checkout support.
* HPOS compatible.
* Balance due on delivery shown on the order, in admin, and in order emails.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
