=== PSBDx Custom Product Fields ===
Contributors: psbdx, mfhamim
Tags: woocommerce, product fields, custom fields, product addons, checkout
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Add custom product fields to WooCommerce products, validate user input, and optionally increase product price based on number field values.
== Description ==
PSBDx Custom Product Fields adds dynamic custom fields to WooCommerce product pages and seamlessly carries the submitted values through the cart, checkout, and order screens.
Core capabilities:
 * Add multiple field types: text, textarea, number, email, mobile, website URL, date, dropdown, radio, and checkbox.
 * Mark fields as required and define custom error messages per field.
 * Increase product price dynamically using the Price Per Unit setting on Number fields.
 * Allow decimal (point) values in Number fields with the Allow Decimals setting.
 * Edit captured field values directly from the Admin order screen (works with both classic and High-Performance Order Storage).
 * Conflict-safe runtime guard: pauses plugin execution and shows admin notices when conflicts are detected.
 * Full WordPress Multisite compatibility with network activation support.
 * Includes extensive developer hooks for custom integrations.
For complete details, advanced setups, and guides, please visit our official documentation: https://dev.psbdx.xyz/documentations/psbdx-custom-product-fields/

== Compatibility Warning ==
If a custom plugin or theme fully replaces the standard WooCommerce product, cart, checkout, or order creation flow (instead of using standard WooCommerce hooks), this plugin may not be able to capture field data or apply price adjustments.
Possible impacts of custom overrides:
 * Custom field values may not be saved into cart/order item meta.
 * Pricing field adjustments may not be added to line item totals.
 
== Solution Hooks (For Custom Checkout/Flow Integrations) ==

If your checkout flow is highly customized, you can use these developer hooks to pass data through your own pipeline.

Plugin filters/actions:

 * psbdx_cpf_product_fields - Filter field definitions before display/validation.
 * psbdx_cpf_required_message - Customize required field message output.
 * psbdx_cpf_cart_item_data - Inject/adjust cart item data before WooCommerce stores it.
 * psbdx_cpf_adjusted_cart_price - Control the final adjusted price for cart items.
 * psbdx_cpf_after_validation - Run custom logic after field validation.
 * psbdx_cpf_loaded - Fire integration bootstrapping after plugin init.
WooCommerce hook points commonly used for compatibility:
 * woocommerce_add_cart_item_data
 * woocommerce_get_item_data
 * woocommerce_before_calculate_totals
 * woocommerce_checkout_create_order_line_item
For advanced implementation examples, please check the documentation:
https://dev.psbdx.xyz/documentations/psbdx-custom-product-fields/

== Installation ==

 1. Upload the plugin files to the /wp-content/plugins/psbdx-custom-product-fields directory, or install the plugin directly through the WordPress plugin installer.
 2. Activate the plugin through the 'Plugins' screen in WordPress.
 3. Ensure WooCommerce is installed and active.
 4. Edit any product and configure your new fields in the **Custom Product Fields** meta box.
 
== Frequently Asked Questions ==

= Where can I find more details and documentation? =
To know more, read advanced guides, or view developer documentation, please visit:
https://dev.psbdx.xyz/documentations/psbdx-custom-product-fields/

= Does this plugin support WooCommerce variable products? =
Yes, it fully supports variable products. You can even assign custom fields to specific variations.

= Does this plugin require WooCommerce? =
Yes. WooCommerce is required for this plugin to function.

= How does the number-based price increase work? =
For Number type fields, you can set a **Price Per Unit**. If a customer enters a quantity of N, the plugin automatically calculates and adds N x Price Per Unit to that specific cart item.

= Can I allow decimal values in number fields? =
Yes. Simply enable the **Allow Decimals** option for that specific number field.

= Can I customize the required field error message? =
Absolutely. Each individual field has its own **Required Message** setting so you can tailor the prompt to the user.

== Screenshots ==
 1. The Custom Product Fields meta box on the backend product edit screen.
 2. Frontend view showing the custom fields on a single product page.
 3. Custom field values carried over successfully into the Cart and Checkout pages.
 4. Viewing and editing the captured customer inputs directly on the WooCommerce Order screen.

== Changelog ==

= 1.2.0 =

 * Fix: the "Show/Hide" password toggle button on the WooCommerce order edit screen did nothing on stores using High-Performance Order Storage (HPOS) — admin CSS/JS now correctly loads on both the classic and HPOS order editor screens.
 * Fix: hid the native browser password reveal/clear icon (seen in Edge/IE) so it no longer visually overlaps and intercepts clicks meant for the custom Show/Hide button.
 * Fix: added a dedicated nonce check when saving edited field values from the order admin screen.
 * Fix: replaced an unreliable filter_input(INPUT_POST) call (known to silently fail on some PHP-FPM setups) with direct, sanitized $_POST access when saving product fields.
 * Fix: checkbox fields marked "Required" now also carry the native HTML5 required attribute.
 * Added new field types: Textarea, Website URL, and Date — each with matching server-side and client-side validation.
 * Textarea values now keep their line breaks through cart, checkout, and order storage instead of being flattened to a single line.
 * Added a `languages` translation loader for self-hosted installs.
 * Fix: corrected a malformed License/License URI header in readme.txt (they were incorrectly split across the same line) that caused "invalid license" and "license mismatch" plugin-check errors.
 * Fix: readme.txt "Tested up to" bumped to the current WordPress version.
 * Fix: the `languages` folder referenced by the "Domain Path" header now actually exists in the package.

= 1.1.0 =

 * Improved visuals and backend admin UI.
 * Added backend server verification for tighter security.
 * Added support for Variable Products (Admins can now add a field for a specific variation).
 
= 1.0.0 =

 * First public release.
 * Added field types: text, number, email, mobile, dropdown, radio, and checkbox.
 * Added required message support per field.
 * Added number-based price increment support with optional decimal values.
 * Added admin safety checks and multisite support.
