=== Prof Solution Sync for WooCommerce ===
Contributors: silverthinking
Tags: woocommerce, erp, inventory, stock sync, orders
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.9.15
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connects a WooCommerce store to the Prof Solution ERP: products, stock, prices and orders stay in sync, under the store's own rules.

== Description ==

Prof Solution Sync for WooCommerce links your store to [Prof Solution](https://prof-landing.silverthinking.net/), the sales, inventory and accounting system made by Silver Thinking. Once linked, Prof Solution keeps the store's products, stock and prices up to date and receives the store's orders, so they become bills in Prof Solution without typing them again.

**This plugin needs a Prof Solution account.** Prof Solution is a commercial service (see its website for plans); the plugin does nothing until the store is linked from inside Prof Solution. See "External services" below for exactly what is exchanged.

Features:

* **Products:** creates and updates simple and variable products (variations, attributes, categories, brand, SEO title and description) from Prof Solution. The store's existing global attributes are reused; none are created.
* **Stock and prices:** quantity, stock status, regular and sale prices follow Prof Solution.
* **Images:** main image and gallery, without duplicating files already in the media library.
* **Orders:** new orders, status changes and refunds are sent to Prof Solution; Prof Solution can change an order's status (WooCommerce then handles stock as usual).
* **The store decides what may change:** in Settings > Prof Solution Sync Plugin, untick any kind of change (prices, stock, names and descriptions, images, categories, brand and SEO, attributes, SKU and weight, hiding and deleting, order status). An unticked change is refused by the plugin itself, whatever Prof Solution sends.
* **Secure connection:** the store is linked once with a one-time connection key; every later request is signed (HMAC with a server-held secret, timestamp window, one-use nonce and request id).
* **Logging:** optional activity and error log under WooCommerce > Status > Logs.
* Works with WooCommerce's High-Performance Order Storage (HPOS).

== Installation ==

1. Install the plugin from the Plugins screen (or upload the `prof-solution-sync` folder to `/wp-content/plugins/`) and activate it. WooCommerce must be installed and active.
2. Go to Settings > Prof Solution Sync Plugin and copy the Connection Key.
3. In Prof Solution, open Settings > WooCommerce > Connect, enter the store address and paste the key. The key works once: after linking, a new one replaces it on the settings page.
4. (Optional) Untick the kinds of change Prof Solution may not make on this store, and turn on logging.

== Frequently Asked Questions ==

= Do I need a Prof Solution account? =
Yes. The plugin is the store side of the Prof Solution integration and does nothing on its own. Nothing is sent anywhere until the store is linked.

= Is WooCommerce required? =
Yes. The plugin extends WooCommerce and needs it installed and active.

= Where do I find the connection key? =
Settings > Prof Solution Sync Plugin. "Generate New Key" makes and saves a new one (the current link stops until the new key is entered in Prof Solution).

= Can I stop Prof Solution from changing some things? =
Yes. On the settings page, untick any kind of change. Reading products and orders always stays on, so stock and orders keep syncing.

= Does syncing again duplicate images? =
No. Each image is remembered by its source, so the same image is only added to the media library once.

= What happens when I delete the plugin? =
Its settings, connection key and secret, queued order updates and scheduled jobs are removed. Products, images and orders already in the store are kept.

= Is the plugin available in Arabic? =
Yes. The settings page is fully translated to Arabic and follows the site language (right-to-left included).

== Screenshots ==

1. Settings > Prof Solution Sync Plugin: the one-time connection key and the link status.
2. What Prof Solution may change on the store: an unticked kind of change is refused by the plugin itself.
3. The settings page in Arabic.

== External services ==

This plugin connects the store to **Prof Solution**, a business management (ERP) service run by Silver Thinking. It only communicates after a store administrator links the store from inside Prof Solution with the connection key shown on the plugin's settings page, and it stops when the store is unlinked or the plugin is deactivated.

1. **Order updates sent to Prof Solution.** When an order is created, updated, changes status or is refunded, the plugin sends the order to Prof Solution's server (an HTTPS address on silverthinking.net, set when the store is linked). Data sent: order number, status, dates, currency, totals, discounts and shipping, payment method, the order's items (name, SKU, quantity, prices), refunds, the order source (created via, WooCommerce order attribution source and utm_source), and the customer's billing and shipping name, company, address, email and phone. Updates are queued and sent within about a minute; an update that can't be delivered is retried and dropped after at most 30 days.
2. **Connection test.** While linking or checking the connection, Prof Solution asks the store to call back its server once with a random challenge and the store's random site id. No customer or product data is sent.
3. **Requests from Prof Solution.** Prof Solution's server calls this plugin's REST endpoints (`/wp-json/prof-sync/`) to read the store's name, address, products (names, descriptions, SKUs, prices, stock, image addresses, categories, brand, SEO fields) and orders (including customer billing and shipping details), and to make the product and order changes the store allows on the settings page.
4. **Product images.** When Prof Solution sends a product image by its web address, the store downloads that image (from Prof Solution's servers or wherever the image is hosted) to add it to the media library. The request is a plain download that reveals the store's server address to that host.

Prof Solution terms of use: https://prof-landing.silverthinking.net/terms/
Prof Solution privacy policy: https://prof-landing.silverthinking.net/privacy/

== Changelog ==

= 2.9.15 =

Arabic translation of the settings page. Prof Solution now sees whether the store runs the WordPress.org release, so it points to the right place to update.

= 2.9.14 =

SEO: the SEO title and the meta description are each written only when Prof Solution sends that field, so updating one never overwrites the other in Yoast, Rank Math or All in One SEO. Image downloads work on PHP 7.4 again (no PHP 8-only string function).

= 2.9.13 =

Signed requests: the one-use nonce is checked and stored in a single atomic database insert, so concurrent copies of the same signed request can never both pass. Background jobs (order updates, repairs) use the same atomic lock, so overlapping runs never repeat work.

= 2.9.12 =

Images: the file type is read from the image's own bytes (never from the declared type, the server's Content-Type or the URL), and anything that is not a JPEG, PNG, GIF, WebP or AVIF image is refused before it reaches the media library.

= 2.9.11 =

Settings page: works with WordPress translations, its scripts load as files, saving checks the user's rights and returns to the page. Order updates are only queued once the store is linked, are dropped after 30 days if never delivered, are cleared when the store is unlinked, and only go to Prof Solution's own servers. Deleting the plugin removes its data. Declares WooCommerce HPOS compatibility. Requires WordPress 6.5.

= 2.9.10 =

Products now report each variation's own SKU (a variation without one no longer shows its parent's), and a variation found by its PROF code under another product still in the store is never taken over.

= 2.9.9 =

An order the plugin can't read (a PHP error inside it, often from another plugin) no longer crashes the orders list with "There has been a critical error": it is skipped and reported to PROF with its error, and logged under WooCommerce > Status > Logs (source prof-sync). Saving such an order in the store, or changing its status from PROF, never fails because of it.

= 2.9.8 =

Store settings 'What PROF Solution may change' (Settings > Prof Solution Sync Plugin): twelve kinds of change (create, prices, stock, name/description, status, images, categories, brand/SEO, attributes, SKU/weight, hide/delete, order status), all on by default; an unticked one is refused by the plugin itself, whatever PROF sends. Attributes: the Local/Global setting is gone; an attribute the store has as a global attribute is always used as that global attribute (no more custom duplicates such as a local Flavor beside pa_flavor), and PROF never creates a global attribute. Variations the store keeps on sale keep options the product offers. Grouped/external products are never reshaped; refusals happen before anything is written; delete only removes products linked with PROF.

= 2.9.7 =

products/brand-attribute can also correct a brand: it replaces a product's only brand when PROF names that exact brand as the one to replace.

= 2.9.6 =

PROF can set the theme's brand attribute on its products that have none (products/brand-attribute): only an existing brand, never replacing one already set.

= 2.9.5 =

One-time repair after updating: PROF products that lost the theme's brand attribute (Woodmart pa_brands) to earlier syncs get it back, from the brand PROF pushed, the WooCommerce Brands term, or the brand named in the product title. Products with no match or two brands in the title are left as they are and listed in the report.

= 2.9.4 =

Syncing a variable product keeps the store's own attributes (a theme's brand attribute such as Woodmart's pa_brands, descriptive specs). Only the variation attributes PROF sends are replaced; before, every other attribute was removed and its terms unlinked.

= 2.9.3 =

Generate New Key now saves the new connection key at once (it used to only fill the box, so a key copied without pressing Save was never valid). Save Changes no longer posts the key, so a page left open can't put back a key PROF already replaced. Adds a Copy button and explains that each key links once and is replaced after linking.

= 2.9.2 =

Products made with WooCommerce Duplicate no longer carry the source product's PROF identity (the copy and its variations start clean; copies made earlier are treated as products of their own).

= 2.9.1 =

Changes made in WordPress are reported as the store shows them: the brand term and the Yoast / Rank Math / AIOSEO fields come first. A product sold as itself reports its attributes and takes the app's back by label (only attributes PROF wrote are ever removed). A product with no app category leaves the categories PROF manages (the store's own stay).

= 2.9.0 =

Images: URLs with non-ASCII characters (such as en dashes) now download instead of failing; a failed image download keeps the product's current images; images served through the store's own CDN (EWWW Easy IO, Jetpack) reuse the existing attachment instead of creating a copy.

= 2.8.0 =

Products changed in the WooCommerce admin are reported to PROF for review: the product list can return the products modified since a time (oldest first), and every push answers with the product as saved. An image of this very store sent back by PROF reuses the attachment instead of downloading a copy.

= 2.7.0 =

A variable product with no variations now syncs as one product: its attributes come into PROF as specs and its stock is updated on the product itself, instead of failing the import.

= 2.6.0 =

A product can sit in several categories: PROF sends all of them and the product gets every one (categories added by hand on the store are kept). Older PROF servers that send a single category keep working.

= 2.4.0 =

The products list can be searched by title, SKU or id (PROF's add-product wizard looks for a product already on the store). A store product PROF never managed is updated in place when PROF links a product to it, instead of a second product being created.

= 2.3.0 =

Orders report where they came from (created via, and WooCommerce's order attribution source type and utm_source), so PROF can fill the sales channel of the bill made from them.

= 2.2.0 =

A renamed or regrouped product group adopts its existing parent (previousKey) instead of creating a second product; single products grouped together hand their SKUs to the new variations.

Field presence: description, slug, brand, SEO title and meta description are only written when PROF sends them, so empty PROF fields never wipe store data. Images change only with an explicit replace or clear.

Products PROF never managed report their brand from the store brand taxonomy and SEO from the active SEO plugin, so imports keep them.

= 2.1.0 =

Added canonical, idempotent product-group upserts for durable server jobs.

Product parents are identified by PROF group keys, variants by local product codes, and batch responses report success or failure per group.

Removed global cache purges from the v2 product path in favor of targeted product cache invalidation.

= 2.0.0 =

Added the versioned /prof-sync/v2 handshake and capabilities contract.

Added HMAC request signing, timestamp validation, nonce replay protection, and request IDs.

Added capability adapters for WooCommerce HPOS, product brands, and SEO plugins.

Added server-side signing-secret rotation. Legacy v1 reads remain available during migration; v1 write routes are read-only by default in Plugin v2.

= 1.0.0 =

Initial release.

Added support for Simple and Variable products sync.

Added smart image and gallery handling.

Added Global/Local attributes toggle.

Added WooCommerce logging integration.
