From 0793a1ee824121ffd149c20597fc014be2c9d05d Mon Sep 17 00:00:00 2001 From: kristianwind Date: Fri, 2 Oct 2026 12:28:45 +0200 Subject: [PATCH] 1.7.0: shipping rule "Only" reserves a method, "Show" no longer does Since 1.6.0 "Show" both whitelisted a method for its group and hid it from everybody else. A group shown ordinary methods next to a free one therefore took the ordinary ones away from every stranger, who was left with only the free method. "Only" now carries the reservation; "Show" is just the group's whitelist. Existing show rules are converted to only once on update so the checkout does not change until the shop chooses. Co-Authored-By: Claude Code --- README.txt | 8 +++- docs/CONTRACT.md | 2 +- docs/README.md | 9 ++-- docs/RELEASE.md | 4 +- docs/SETUP.md | 16 ++++---- includes/class-admin-shipping.php | 8 +++- includes/class-db.php | 44 ++++++++++++++++---- includes/class-frontend.php | 10 +++-- includes/class-rest-api.php | 4 +- tests/smoke.php | 57 +++++++++++++++++++++++--- woocommerce-email-discount-manager.php | 4 +- 11 files changed, 129 insertions(+), 37 deletions(-) diff --git a/README.txt b/README.txt index a09285f..19a0cf6 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Tags: woocommerce, discount, email, shipping, coupon Requires at least: 5.8 Tested up to: 7.1.2 Requires PHP: 7.4 -Stable tag: 1.6.3 +Stable tag: 1.7.0 WC requires at least: 6.0 WC tested up to: 11.1.2 License: GPLv2 or later @@ -50,7 +50,8 @@ coupons in a dropdown. * Per discount group, choose which shipping methods are shown or hidden. * No rules for a group means all shipping methods behave normally. -* If any method is set to "Show", only "Show" methods are offered (whitelist). +* If any method is set to "Show" or "Only", only those methods are offered to the group (whitelist). +* "Only" also hides the method from every customer outside the group; "Show" does not. * Drag & drop reordering controls the order methods appear in at checkout. = How discounts are applied = @@ -96,6 +97,9 @@ The most specific match wins: exact email, then domain, then partial match. == Changelog == += 1.7.0 = +* Shipping rules have a new choice, "Only". "Only" shows a method to the group and hides it from everybody else, which is what free delivery for one company needs. "Show" goes back to meaning just that: the group is offered the method, and nobody else is affected. Since 1.6.0 "Show" did both, so a group that was shown ordinary methods next to a free one took the ordinary ones away from every other customer. Every "Show" rule saved before this update is changed to "Only" automatically, so the checkout looks the same after updating. To give a group its ordinary methods without reserving them, set those to "Show" and leave the free ones on "Only". + = 1.6.3 = * The WooCommerce version this plugin declares as tested is now the same in both places it is written. The readme still said 11.1.0 while the plugin itself said 11.1.2. diff --git a/docs/CONTRACT.md b/docs/CONTRACT.md index 68b1df3..cabe15c 100644 --- a/docs/CONTRACT.md +++ b/docs/CONTRACT.md @@ -1,6 +1,6 @@ # Contract -Every hook this plugin offers, and every family hook it answers. Version 1.6.3. +Every hook this plugin offers, and every family hook it answers. Version 1.7.0. A contract is a name somebody else has to know. Core hooks this plugin merely listens to — `init`, `admin_menu`, `wp_enqueue_scripts` — are not here; diff --git a/docs/README.md b/docs/README.md index 9f0b4f3..edd2142 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # Nolimit Discounts -Version 1.6.3 · a WooCommerce plugin · slug `woocommerce-email-discount-manager` +Version 1.7.0 · a WooCommerce plugin · slug `woocommerce-email-discount-manager` Gives a customer a discount, and decides which shipping methods they may choose, based on the email address they check out with. @@ -29,11 +29,14 @@ address, then domain, then fragment. A discount group can be given shipping rules, which is the half worth reading twice because it decides what a stranger sees. -A method a group is told to **show** is *reserved* for that group. Customers +A method a group is set to **only** is *reserved* for that group. Customers who match no group do not see it. Before 1.6.0 a method set up for approved company addresses stayed on the checkout for everybody, so free delivery meant for one customer could be chosen by anyone who found it — the bug that release -fixed. +fixed. **Show** is the weaker rule and reserves nothing: it offers the method +to the group and leaves everyone else alone. 1.6.0 made show do both, which +took ordinary methods away from strangers whenever they were listed beside a +free one; 1.7.0 split them and turned every old show rule into only. The plugin never leaves a customer with no shipping method at all. If applying the rules would empty the list, every method comes back. diff --git a/docs/RELEASE.md b/docs/RELEASE.md index b3bc740..6eef1d1 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -1,6 +1,6 @@ # Releasing -One release a day at most, cut by hand. Version 1.6.3 is current. +One release a day at most, cut by hand. Version 1.7.0 is current. ## The sequence @@ -233,7 +233,7 @@ derives everything from the header, so splitting them was a one-line change — and it means the source repository's visibility is a separate decision from the feed's. -⚠️ The source repository is **still public** as of 1.6.3. Making it private is +⚠️ The source repository is **still public** as of 1.7.0. Making it private is safe only once no installation is still pointing its `Update URI` at the old address; an install on a pre-1.5.0 build reads its feed from `kw/nolimit-discounts`, and making that private would silently stop its diff --git a/docs/SETUP.md b/docs/SETUP.md index eda02ff..328f02f 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -53,13 +53,15 @@ A fragment pattern (`john`) matches `john@anywhere.com` and also ### Shipping -Per group, per shipping method, one of **show** or **hide**. +Per group, per shipping method, one of **show**, **only** or **hide**. -The consequence worth understanding before using this tab: a method any group -is told to **show** becomes reserved. Customers who match no group stop seeing -it everywhere on the shop, not only inside that group. That is the point — it -is how "free delivery for approved addresses" stays unavailable to everybody -else — but it means adding one show rule changes what strangers see. +**Show** offers the method to the group (and, once any method is shown, the +group is offered only the methods marked show or only). Nobody else is +affected. **Only** does the same and also *reserves* the method: customers +outside the group stop seeing it everywhere on the shop. That is how "free +delivery for approved addresses" stays unavailable to everybody else — set the +free methods to **only** and the ordinary ones (parcel shops, pickup) to +**show**. Adding one only rule changes what strangers see. ## How to tell it is working @@ -81,7 +83,7 @@ Not "no errors". A specific number on a specific screen: 4. **Shipping, if you set any rules.** With rules in place, compare the checkout as a matching customer and in a private window as a stranger. The - reserved method must be absent for the stranger. Both should show at least + method marked only must be absent for the stranger. Both should show at least one method; if the stranger sees *everything*, the rules emptied the list and the never-leave-them-stranded fallback returned all of them. diff --git a/includes/class-admin-shipping.php b/includes/class-admin-shipping.php index ca1f586..33ba854 100644 --- a/includes/class-admin-shipping.php +++ b/includes/class-admin-shipping.php @@ -51,7 +51,7 @@ class WC_EDM_Admin_Shipping { $action = isset( $raw_rules[ $method_id ] ) ? $raw_rules[ $method_id ] : ''; - if ( ! in_array( $action, array( 'show', 'hide' ), true ) ) { + if ( ! in_array( $action, array( 'show', 'hide', 'only' ), true ) ) { continue; } @@ -84,7 +84,7 @@ class WC_EDM_Admin_Shipping { ?>

- +

@@ -175,6 +175,10 @@ class WC_EDM_Admin_Shipping { > +