=== SR Partial Payments for WooCommerce ===
Contributors: suhanurrashid
Tags: woocommerce, partial payment, deposit, split payment, cod
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
WC requires at least: 6.0
WC tested up to: 9.5
Stable tag: 1.3.8
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Allows customers to make partial payments at checkout, with the remaining balance collected as Cash on Delivery (COD).

== Description ==

**SR Partial Payments for WooCommerce** enables a flexible payment system for your WooCommerce store. It allow customers to pay a specific amount (Percentage or Fixed) online while placing an order, and the rest via Cash on Delivery (COD).

This helps in reducing fake orders and securing shipping charges upfront.

### Key Features:
*   **Flexible Options:** Set minimum payment as a **Percentage (%)** or **Fixed Amount**.
*   **Smart Checkout:** Customers can choose between **Full Payment** (Recommended) or **Partial Payment**.
*   **Surcharge Fee:** Add an optional fee when customers choose partial payment.
*   **Trust Badges:** Secure Checkout, Easy Return, and Encryption badges to boost conversion.
*   **Mobile Optimized:** Fully responsive UI with a smooth experience on mobile devices.
*   **COD Integration:** Automatically calculates and displays the remaining COD amount.
*   **Order Notes:** Adds clear notes to the order regarding paid amount and due balance.

### Support & Feedback
Found a bug or have a feature request? Get in touch:
*   **Email:** [support@suhanur.com](mailto:support@suhanur.com)
*   **Website:** [suhanur.com](https://suhanur.com)
*   **WhatsApp:** [+880 1521-226362](https://wa.me/8801521226362)

== Installation ==

1.  Upload the plugin files to the `/wp-content/plugins/sr-partial-payments-for-woocommerce` directory, or install the plugin through the WordPress plugins screen directly.
2.  Activate the plugin through the 'Plugins' screen in WordPress.
3.  Navigate to **WooCommerce > Partial Payment** to configure settings.

== Frequently Asked Questions ==

= Does this work with any payment gateway? =
Yes, it works with any standard WooCommerce payment gateway. The initial partial amount is collected via your active gateway.

= Can I force partial payment for all orders? =
Currently, it gives customers a choice. You can incentivize Full Payment using the "Recommended" badge.

== Screenshots ==

1.  **Checkout UI** - Shows the Full and Partial payment options with trust badges.
2.  **Mobile View** - Optimized responsive view for mobile customers.
3.  **Admin Settings** - Easy configuration panel.

== Upgrade Notice ==

= 1.3.8 =
Checkout AJAX update fix for partial payment wrapper.

= 1.3.7 =
General updates and optimizations.

= 1.3.6 =
UI simplification: Removed manual amount input, fixed currency position styling, added static visibility to Partial Payment surcharge badge.

= 1.3.5 =
Critical fix: Fractional value display and rounding improvements across all checkout, order, and email interfaces.

= 1.3.3 =
Minor UI updates for surcharge labels.

= 1.3.2 =
Bug fixes for surcharge calculations, improved admin UI, and cache-busting.

= 1.3.1 =
Added Surcharge (Partial Payment Fee) feature, collapsible UI, dynamic checkout calculations, and multiple UI improvements.

= 1.3.0 =
Security and stability improvements. Includes critical server-side validation, payment hook fixes, and CSS cleanup. Recommended update for all users.

== Changelog ==

= 1.3.8 =
*   Fixed: Partial payment UI now dynamically refreshes when cart quantities or shipping options change via WooCommerce AJAX checkout updates.

= 1.3.7 =
*   Improved: General plugin stability and optimizations.

= 1.3.6 =
*   Fixed: Currency symbol positioning in JS now respects WooCommerce native settings (left, right, spaces).
*   Fixed: Extra Fee surcharge badge was hidden until selected, now permanently visible for better transparency.
*   Improved: Simplified Checkout UI by removing the manual amount input. Surcharge now strictly calculates up to minimum payment.

= 1.3.5 =
*   Fixed: Fractional values in checkout infobox (surcharge, COD, order total) — all financial values now rounded to integers.
*   Fixed: Browser JS cache serving stale scripts — added filemtime() cache busting for frontend CSS/JS.
*   Fixed: Unrounded cart totals in validate_checkout, save_partial_payment_data, and ajax_update_payment.
*   Fixed: Unrounded partial_amount and shipping_total in POST data processing.
*   Improved: Complete integer enforcement across all 6 cart total computation points.
*   Improved: JS calculateSurcharge now uses Math.floor(Math.round()) for guaranteed integer output.

= 1.3.3 =
*   Improved: Reduced misleading "Percentage of partial amount" text to "Percentage" since basis is now dynamic.

= 1.3.2 =
*   Added: "Calculate On" basis option — surcharge on Partial Payment Amount or Total Order Value.
*   Fixed: Cart total circular inflation bug — JS preview and PHP now use consistent clean totals.
*   Fixed: jQuery slideDown on table-row elements causing hidden Calculate On row.
*   Fixed: Admin JS/CSS cache-busting — switched to filemtime() for automatic invalidation.
*   Fixed: Tax components now included in cart total calculation for accuracy.
*   Improved: Modern segmented-control UI for Calculate On options.
*   Removed: All 16 dead V2 (class-wcog-*) files.

= 1.3.1 =
*   Added: Surcharge / Partial Payment Fee system (Percentage or Fixed).
*   Added: Surcharge visibility on checkout, emails, and order details.
*   Added: Collapsible Help and Support cards in Settings.
*   Fixed: Recursive calculate fee bug in WooCommerce checkout.
*   Improved: Dynamic settings UI and side-by-side card layout.

= 1.3.0 =
*   Fixed: Server-side validation to prevent negative COD amounts from tampered inputs.
*   Fixed: Payment complete hook conflict — no longer adds incorrect order notes on remaining payment.
*   Fixed: Replaced `$_REQUEST` with `$_GET` for WC AJAX checkout security.
*   Fixed: Added WC_Order type guard in gateway to prevent potential fatal errors.
*   Fixed: Added null-check guard in `set_partial_paid_status` to prevent crash.
*   Fixed: Missing ABSPATH direct access guards in two include files.
*   Fixed: Removed duplicate CSS rules in frontend stylesheet.
*   Fixed: Removed duplicate docblock in main plugin file.
*   Improved: Added recommended option glow effect for better checkout UX.

= 1.2.0 =
*   Fixed: Critical JavaScript initialization error (object name mismatch).
*   Fixed: Checkout field name inconsistency between HTML, JavaScript, and PHP.
*   Fixed: Duplicate order total filter that could cause conflicts.
*   Fixed: Added nonce verification in gateway for security.
*   Fixed: Invalid sanitize callback for float settings.
*   Improved: Moved inline trust badge styles to CSS file.
*   Improved: CSS now loads on thank-you page and my-account order view.
*   Fixed: Author tags in all PHP files.
*   Added: uninstall.php for proper cleanup on plugin deletion.

= 1.1.1 =
*   Improved Mobile UI: Smaller and better positioned 'Recommended' badge.
*   Fixed: CSS caching issue with duplicate icons.
*   UX: Enhanced visual hierarchy and active states.

= 1.1.0 =
*   Fixed: Duplicate truck icons in COD amount.
*   Added: Robust CSS selectors.

= 1.0.0 =
*   Initial release.
