=== Arik Product Fields — WooCommerce Custom Fields, Buy Now, Enquiry Form & Coupon ===
Contributors: wcblogs87
Tags: woocommerce custom fields, buy now button, product enquiry form, product addons, woocommerce coupon
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.0.7
WC requires at least: 6.0
WC tested up to: 9.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Custom product fields with a drag-and-drop builder, Buy Now button, Enquiry Form, Coupon Box, and 20 field types for WooCommerce.

== Description ==

**Arik Product Fields** is a complete toolkit for WooCommerce product pages. Build custom product fields with a drag-and-drop visual builder, add a Buy Now button that skips the cart, accept enquiries through a polished modal form, show coupon codes directly on the product page, and clean up the single product layout all without writing a single line of code.

Designed for store owners who want more conversions, better data collection, and a faster checkout experience.

= Why store owners pick Arik Product Fields =

* **One plugin, five jobs.** Custom fields, Buy Now, Enquiry form, coupon box, and checkout tweaks no need to stack five separate plugins.
* **Beautiful frontend.** Theme-aware styling that inherits your color tokens and looks native in Storefront, Astra, Flatsome, OceanWP, and Blocksy.
* **HPOS compatible.** Declared compatibility with WooCommerce Custom Order Tables and the new cart/checkout blocks.
* **Built for developers.** 11+ public actions and filters, a Support & Docs page with copy-paste examples, and translation-ready strings.
* **No bloat.** Assets load only on the screens that need them. Admin styles never leak into unrelated pages.

= 20 field types =

**Input fields** (collect data from customers):

* Text
* Textarea
* Number
* E-mail
* URL
* Checkbox (multi-option)
* Select / Dropdown
* Radio
* Radio with images (WP Media Library picker)
* Radio with colors (WordPress color picker)
* Time
* Color
* Date

**Display / Content fields** (admin enters content, frontend shows it):

* Heading
* Paragraph
* HTML
* Image (Media Library picker + URL fallback)
* Product Video (YouTube, Vimeo, or direct MP4/WebM/OGG)

**Dynamic fields** (populated from the current product):

* Categories rendered as checkboxes built from the product's own categories
* Tags rendered as checkboxes built from the product's own tags

= Feature highlights =

* **Drag-and-drop field builder** powered by jQuery UI Sortable. Click any field type in the palette to add it. Drag rows by the handle to reorder. Inline editor with per-type controls.
* **Per-product field assignment** through a dedicated Product Data tab. Pick which fields appear on which products. Leave it empty to use global-scope fields.
* **Buy Now button** that skips the cart and lands the customer on checkout (or cart your choice).
* **Enquiry form** in an accessible modal. Sends email to admin, stores submissions as a custom post type, and recommends Contact Form 7 as a more robust alternative.
* **Coupon code box** on the single product page with four position options.
* **Checkout modifications** add an optional Order Reference field, make phone optional, soften default placeholders.
* **Hide SKU and Categories/Tags** on single product pages globally or per-product.
* **Tri-state per-product overrides** for Buy Now and Enquiry: "Use global setting", "Show", or "Hide".
* **Configurable field position** render fields before/after price, before/after Add to Cart, or before/after Buy Now.
* **Support & Docs admin page** with the full developer hook reference and code examples.
* **Translation-ready** with `wp_set_script_translations()` for the builder UI.

= Security =

* WordPress nonces on every form and AJAX endpoint.
* Capability checks on every admin action (`manage_woocommerce`, `edit_product`).
* Honeypot field plus per-IP rate limiting on the enquiry form.
* Type-aware sanitization with a strict allowlist per field type.
* Output escaped per WordPress.org guidelines (`esc_html`, `esc_attr`, `esc_url`, `wp_kses_post`).

= Developer-friendly =

The plugin exposes 11+ public hooks for theme and plugin developers:

* Filters: `arikapf_render_field_definitions`, `arikapf_cart_item_field_values`, `arikapf_buy_now_button_label`, `arikapf_enquiry_button_label`, `arikapf_buy_now_enabled_for_product`, `arikapf_enquiry_enabled_for_product`, `arikapf_hide_sku`, `arikapf_hide_categories`, `arikapf_fields_render_hook`, `arikapf_support_marketing_links`, `arikapf_checkout_fields`.
* Actions: `arikapf_before_render_fields`, `arikapf_after_render_fields`, `arikapf_before_buy_now_button`, `arikapf_after_buy_now_button`, `arikapf_before_enquiry_button`, `arikapf_after_enquiry_button`, `arikapf_enquiry_submitted`, `arikapf_after_save_product_meta`, `arikapf_after_cart_item_meta_added`.

Each hook is documented inside the plugin under **Arik Fields → Support & Docs**, with copy-paste code examples.

= Compatible with =

* WordPress 6.0+
* WooCommerce 6.0+ (tested through 9.4)
* PHP 7.4+
* HPOS (Custom Order Tables)
* WooCommerce Cart & Checkout Blocks
* Contact Form 7 (for the enquiry form)
* Storefront, Astra, Flatsome, OceanWP, Blocksy, and any properly built block theme


== Additional Information ==

= Support & Connect =
* **Email Support:** helpwcblog@gmail.com
* **Website:** **[https://gernx.com/](https://gernx.com/)** 
* **Support Forum:** [WordPress.org Support](https://wordpress.org/support/plugin/arik-product-fields/)
* **LinkedIn:** [Tanmoy Biswas](https://www.linkedin.com/in/is-tanmoy/)


== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install through the **Plugins** menu in WordPress.
2. Activate **Arik Product Fields** through the **Plugins** screen.
3. Go to **Arik Fields → Field Builder** to create your custom fields.
4. Go to **Arik Fields → Settings** to configure Buy Now, Enquiry, Coupon, and field position.
5. Edit any product and open the **Arik Fields** tab to assign which fields appear on that product.

== Frequently Asked Questions ==

= Does this work with the WooCommerce Block Checkout? =

Yes. HPOS and `cart_checkout_blocks` compatibility is declared in the plugin header.

= Can I use Contact Form 7 instead of the built-in enquiry form? =

Yes. Enable it under **Arik Fields → Settings → Enquiry Form**, then pick the CF7 form you want to display in the modal.

= Where do submitted enquiries go? =

By default, enquiries are emailed to the address in **Settings → Enquiry Form → Recipient Email** AND stored as a custom post type at **Arik Fields → Enquiries**. Either destination can be disabled.

= Can I override Buy Now or Enquiry on a single product? =

Yes. Each product has its own tri-state dropdown in the **Arik Fields** tab: *Use global setting*, *Show on this product*, or *Hide on this product*.

= My theme has different button styles. Will the plugin's buttons look out of place? =

The frontend stylesheet inherits theme color tokens like `--wp--preset--color--primary` where available. Buttons and form controls pick up your theme's accent color automatically in modern themes.

= Does the plugin slow down my site? =

No. CSS and JavaScript only load on single product pages, the cart, and the checkout. Admin assets only load on the plugin's own screens. The fields table is indexed and cached via the WordPress object cache.

= Can I extend the plugin from a child theme or custom plugin? =

Yes. See the full hook reference at **Arik Fields → Support & Docs**, or check the Description section above. There are 11+ documented hooks plus a `arikapf_fields_render_hook` filter that lets you move the field render position to any WooCommerce action you want.

= Is the plugin translation-ready? =

Yes. Text domain is `arik-product-fields`, all translatable strings use proper translator comments, and `wp_set_script_translations()` is wired up for the builder UI.

= What happens to my data if I delete the plugin? =

Nothing, by default. The uninstaller only runs if you opt in via **Settings → Advanced → Remove all data on uninstall**. Otherwise your fields, settings, and enquiries remain in the database.

== Changelog ==

= 1.0.7 — Field Type Expansion =

**New**

* Redesigned the field type set. The plugin now ships **20 field types**: Text, Textarea, Number, E-mail, URL, Checkbox, Select, Radio, Radio with images, Radio with colors, Time, Color, Heading, Paragraph, Image, HTML, Product Video, Date, Categories (dynamic), Tags (dynamic).
* Builder palette now groups field types into three sections: **Input Fields**, **Display / Content**, **Dynamic**.
* Per-option **Image picker** for "Radio with images" — uses the WP Media Library with a URL fallback input.
* Per-option **Color picker** for "Radio with colors" — uses the core `wp-color-picker`.
* Dedicated content editor for **Heading**, **Paragraph**, **HTML**, **Image**, and **Video** field types.
* **Categories** and **Tags** field types render as dynamic checkbox groups built from the current product's assigned terms.
* **Product Video** embed supports YouTube, Vimeo, and direct MP4/WebM/OGG files.
* Cart and order detail screens now translate option slugs to their human-readable labels, and taxonomy slugs to term names.
* CF7 recommendation banner inside the enquiry modal — admin-only, capability-gated so customers never see it.

**Fixed**

* New checkbox / dropdown / multi-select / radio fields failing to save options on first creation. The builder now writes the full field JSON to a `data-field-data` attribute on each list row, so editing existing option-type fields after a page reload hydrates correctly.
* Silent save failures — the status bar now shows a clear error message and focuses the offending field.
* Customer-facing error messages no longer mention "Contact Form 7" or other plugin recommendations.
* Multi-select listbox cramped rendering — now uses dynamic `size` attribute and per-option padding so options read consistently across themes.
* Dropdown vertical alignment — the selected value was clipped on some themes due to insufficient padding.
* Checkbox field renders as a proper multi-option group instead of a single boolean toggle.
* `Notice: Function _load_textdomain_just_in_time was called incorrectly` on WordPress 6.7+ — translation calls in default option arrays moved out of the bootstrap phase.
* Builder UI required both `value` and `label` to be filled; now mirrors the missing field automatically.

**Database**

* DB schema bumped to **1.1.0**. New `field_content` column added for display-only types.
* **DESTRUCTIVE migration**: existing custom fields are wiped on upgrade. The previous type set is not forward-compatible with the new shape registry. Recreate your fields in the builder.

**Removed**

* `Multi-select` and `File Upload` field types from the previous set — replaced by the redesigned 20-type catalog. (Multi-select behavior is now covered by the new multi-option **Checkbox** field; file uploads are planned for a future release.)

= 1.0.6 — Developer Hooks & Display Controls =

**New**

* Configurable position for custom fields (before/after price, ATC button, or Buy Now button).
* Option to hide SKU and Categories/Tags on single product pages — globally and per-product.
* Tri-state per-product override for Buy Now and Enquiry Form: *Default / Show / Hide*.
* **Support & Docs** admin page with the full hook reference and developer code examples.
* Marketing card with Fiverr, LinkedIn, and donate links.
* 11+ public actions and filters for theme and plugin developers.

**Fixed**

* Enquiry button visibility logic — per-product override now correctly resolves against the global setting.
* Admin CSS scoped to plugin screens only — no longer leaks onto unrelated admin pages.
* Tightened admin enqueue — assets load only on the plugin's own screens and the product edit screen.

= 1.0.5 — Critical Activation Fix =

**Fixed**

* Fatal error on activation/upgrade caused by re-running the activator on `plugins_loaded` (before `$wp_rewrite` was initialised).

**Refactored**

* DB upgrade path moved to `admin_init`.
* CPT registration consolidated to the main class on the `init` action.

= 1.0.4 — Initial Feature Release =

**New**

* Complete drag-and-drop field builder powered by jQuery UI Sortable.
* Per-product field assignment via the Product Data tab.
* Enquiry form modal with database storage, email delivery, and Contact Form 7 fallback.
* Coupon code box with four position options.
* HPOS and cart/checkout blocks compatibility declared.
* Clean uninstaller with opt-in data removal.
* Type-aware sanitization and validation pipeline.

== Upgrade Notice ==

= 1.0.7 =
DESTRUCTIVE: existing custom fields will be wiped on upgrade (schema redesigned). The new 20-type catalog adds image, color, video, date, time, and dynamic taxonomy field types. Recreate your fields in the builder after upgrading.

= 1.0.6 =
Major: developer hooks, configurable field position, SKU/categories hide options, Support & Docs page.

= 1.0.5 =
Critical fix for a fatal error on activation. Update immediately.

= 1.0.4 =
Major release: drag-and-drop builder, HPOS support, enquiry custom post type.

== Screenshots ==

1. screenshot-1.png
2. screenshot-2.png
3. screenshot-3.png
4. screenshot-4.png
5. screenshot-5.png
