SHIPPING + COUPON UPDATE — based on supplied src v6 and Next.js Editor v11.2 ZIP

IMPORTANT
- This is a SOURCE update, not a compiled Next.js deployment.
- Back up the deployed source/env files, WordPress plugin folder and WordPress database first.
- This ZIP contains your supplied env values. Keep it private; do not commit env files to Git.
- No package.json, lockfile, next.config, .htaccess or copy-static.js is replaced.
- No new runtime npm dependency is required by these features.

INSTALL ORDER
1. On WordPress, merge the plugin ZIP into wp-content/plugins/ so its root nextjs-editor/ replaces the SAME existing folder. Do not delete/uninstall the plugin; do not install a duplicate copy.
2. Open Next.js Editor once as an administrator. The Coupon tab and two defaults are initialized without overwriting existing coupons/settings. WooCommerce must be active.
3. Extract this Next.js ZIP into your EXISTING Next.js project root (the folder containing package.json). Root entries are src/, .env, .env.local and .env.production. Merge/replace; do not delete other project files.
4. Run your project's normal production build (normally npm run build), then your existing restart/deployment process. Continue using your existing copy-static/deployment steps where applicable.
5. Test a staging/test order before opening the coupon field on production.

SHIPPING
- Inside Dhaka: existing 70 BDT env rate.
- Dhaka Sub Area: new 100 BDT env rate.
- Outside Dhaka: existing 130 BDT env rate.
- The existing 64-district list is unchanged. Savar is NOT inserted as a district.
- Dhaka district -> Inside Dhaka; Gazipur/Narayanganj/Narsingdi -> Dhaka Sub Area; other districts -> Outside Dhaka.
- Customer may manually override Delivery area. Savar customers can use the Dhaka district and manually select Dhaka Sub Area while entering Savar in the full address.
- Before a district is chosen, the existing Inside Dhaka default remains.
- Free delivery keeps the existing threshold, based on actual product subtotal BEFORE coupon discount.
- Selected variation prices are verified server-side for subtotal/free delivery, not the parent product's minimum price.
- Cart drawer delivery estimate now uses configured zone rates rather than hardcoded 80–130.

NEW ENV KEYS (all three supplied env files have matching values)
NEXT_PUBLIC_DHAKA_SUB_AREA_LABEL="Dhaka Sub Area"
DHAKA_SUB_AREA_LABEL="Dhaka Sub Area"
NEXT_PUBLIC_SHIPPING_DHAKA_SUB_AREA=100
SHIPPING_DHAKA_SUB_AREA=100
NEXT_PUBLIC_DHAKA_SUB_AREA_LOCATIONS=Gazipur,Savar,Narayanganj,Narsingdi
- Keep public/private fee and label pairs equal.
- NEXT_PUBLIC values are build-time client configuration: changing them requires a rebuild/restart.
- Existing secrets, domains and other env values are preserved byte-for-byte before the appended block.

COUPON
- Checkout field defaults to Hidden/OFF. Existing checkout remains usable if plugin coupon endpoints are unavailable.
- Next.js Editor -> Coupon -> Visible -> Save visibility (or Save All Changes), then refresh checkout. No rebuild is needed just for coupon settings/coupon value changes.
- offer100 = fixed 100 BDT; nov100 = 10%.
- Default min/max are 0; maximum 0 means unlimited.
- Minimum/maximum conditions refer to PRODUCT SUBTOTAL, not shipping or the final discounted total.
- One coupon per order; fixed/percentage discounts affect products only.
- Apply previews validate live prices and stock without saving orders or increasing usage.
- Place order revalidates, then WooCommerce applies the native coupon. WooCommerce maintains discount lines/usage counts and status-related reversals.
- A cart product/quantity/price change clears the applied coupon. Apply again.
- Existing coupons with matching default codes are NEVER overwritten; they are not automatically adopted into this module. If a collision exists, create a different managed coupon code in the Coupon tab.
- The managed list does not alter unrelated existing WooCommerce coupons.
- Used coupon codes cannot be renamed, preserving history. Values/status/min/max can be updated.
- The details modal reads WooCommerce order items and works with classic storage and HPOS. History can include cancelled/refunded orders; native usage count may therefore differ from historical order count.
- Coupon settings live in a separate option; no existing settings reset or database-table migration is introduced.
- Server coupon preview uses the existing WooCommerce REST credentials; their permissions must allow the existing checkout write operations.

CHECKS COMPLETED
- PHP lint of all four plugin PHP modules; admin JavaScript syntax check.
- Syntax checked across all supplied Next.js source files; TypeScript check.
- Isolated production build passed using Next 14 / React 18 fixture. Your original root package/config files were not supplied; this does not replace building your actual project.
- 21 mocked server/shipping/checkout regression tests.
- 16 PHP tests using actual WooCommerce WC_Discounts with isolated WordPress/product stubs.
- 11 coupon admin backend tests for create/update/min/max, nonce/capability guards, usage preservation and existing settings preservation (isolated stubs).
- 12 local checkout browser UI tests; 8 local admin browser UI tests with mocked admin AJAX.
- Desktop/mobile layouts reviewed; 64-district list and earlier AddToCart fix unchanged.
- No live plugin install, real WooCommerce database integration, real order or Meta/GA4 delivery test was performed for this update.

POST-DEPLOY SMOKE TEST
1. Coupon Hidden -> checkout stays unchanged.
2. Pick Gazipur/Narayanganj/Narsingdi -> Dhaka Sub Area / 100 BDT; manually change area and verify it stays selected.
3. Enable coupon field; test offer100 and nov100, minimum/maximum failure and inactive code.
4. Place ONE authorized test order; check WooCommerce variation, delivery fee, coupon line, discount, final total, native usage count and modal history.
5. Check purchase dataLayer value against the final WooCommerce total. Cancel the test order when finished.

ROLLBACK
Restore the backed-up src/env files and plugin folder, then rebuild/restart Next.js. New coupon posts/options are not deleted automatically; existing orders/history are preserved. Do not uninstall the plugin to roll back.
