=== PepSpectrum Connect ===
Contributors: moldech
Tags: woocommerce, marketplace, product sync, price comparison, stock sync
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.9.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sync your WooCommerce products, prices and stock to the PepSpectrum marketplace, and receive buyers with their cart and details already filled in.

== Description ==

PepSpectrum Connect links your WooCommerce store to **PepSpectrum**, a
price-comparison marketplace. Shoppers compare offers from several stores on one
page, then click through to buy on *your* store — you keep the customer, the
payment and the order.

You install this plugin, paste the two credentials from your PepSpectrum vendor
dashboard, and everything after that is automatic.

= What it does =

* **Keeps your listings current.** Every published product is sent when you save
  it, so prices, descriptions and images on the marketplace match your store.
* **Keeps stock accurate in real time.** When stock changes — whether you edited
  it or a customer bought something — the new level is pushed straight away.
* **Brings buyers in ready to pay.** A shopper arriving from PepSpectrum lands on
  your checkout with the right items already in the cart, their details filled
  in, and your marketplace discount code applied.
* **Reports marketplace orders.** Completed, cancelled and refunded orders that
  came from PepSpectrum are reported back so commission is tracked correctly.
  Orders from anywhere else are ignored entirely.
* **Shares your lab reports automatically.** Upload a Certificate of Analysis
  PDF to a product the normal way and its link travels with your listing — no
  field to fill in, and nothing added to your product screen.

Everything runs in the background through Action Scheduler, so a sale or an admin
save is never held up waiting on a network call.

= Third-party service disclosure =

**This plugin depends on an external service and is not useful without one.**

It is a client for the PepSpectrum marketplace at
[www.pepspectrum.com](https://www.pepspectrum.com), operated by PepSpectrum. Using
the plugin means store data is transmitted to, and processed by, that service. You
need a PepSpectrum vendor account to use it.

**Nothing is sent until you connect the plugin.** On a fresh install it makes no
outbound requests at all. It begins communicating only after you save an API Key
and Secret on WooCommerce → PepSpectrum — saving those credentials is the act of
consent.

Once connected, the plugin sends to `www.pepspectrum.com`:

* **When you save a published product** — SKU, name, short description, price,
  regular and sale price, currency, stock quantity and status, image URLs,
  category names, the product's public URL, and the link to a Certificate of
  Analysis PDF if one is attached to that product. Draft, private and pending
  products are never sent. Unpublishing, trashing or deleting a product sends
  only its SKU and a "no longer listed" flag.
* **When stock changes** — SKU, quantity and stock status.
* **Once a day** — the same published-product data again, as a full refresh, so
  the marketplace cannot drift out of date.
* **When a PepSpectrum-referred order completes, is cancelled or is refunded** —
  order totals, discount, shipping and tax amounts, currency, status, your order
  number, and the marketplace reference for that order. A refund additionally
  sends the refunded amount and the reason you typed on it. **No customer data
  is ever sent**: no names, email addresses, postal addresses or phone numbers.
  Orders that did not come from PepSpectrum are never reported.
* **With every request** — your site URL and the plugin version, so the service
  knows which store is calling.

The plugin also *receives* two kinds of signed request from the service: checkout
links that carry a buyer to your store with their cart and details, and a request
to re-send your catalogue. Both are rejected unless they carry a valid signature
made with your API Secret and are within their expiry window.

All traffic is signed with HMAC-SHA256 and sent over HTTPS. No data is shared with
any other third party.

By connecting your store you agree to the PepSpectrum
[Terms of Service](https://www.pepspectrum.com/terms) and
[Privacy Policy](https://www.pepspectrum.com/privacy).

= Every product needs a SKU =

The SKU is how the marketplace identifies a product across different stores, so a
product saved without one is not synced and will not appear there.

On a variable product, **every variation needs its own unique SKU**. WooCommerce
reports the parent's SKU for a variation left blank, which would make the
variations overwrite each other into a single listing and break checkout for
buyers sent over. The plugin flags both cases in wp-admin so you are never left
guessing why a product is missing.

== Installation ==

1. In WordPress, go to **Plugins → Add New**, search for "PepSpectrum Connect",
   and click **Install Now**, then **Activate**. (WooCommerce must already be
   installed and active.)
2. Create a free vendor account at
   [www.pepspectrum.com](https://www.pepspectrum.com) and register your store.
   Accounts are reviewed by a person before your listings go public, but you can
   connect the plugin and sync privately straight away.
3. Open your PepSpectrum vendor dashboard and copy the **API Key** and **API
   Secret** shown there.
4. In WordPress, go to **WooCommerce → PepSpectrum**, paste both values, and
   click **Save settings**.
5. Click **Test connection** to confirm the link works.
6. Click **Sync product catalog** once to send your existing products. After
   that, syncing is automatic.

Make sure every product — and every variation — has its own unique SKU before you
run that first sync.

== Frequently Asked Questions ==

= Do I need a PepSpectrum account? =

Yes. The plugin is a connector for that marketplace and does nothing on its own.
Registering a store is free. See the third-party service disclosure above for
exactly what data is shared once you connect.

= Does PepSpectrum take payments, or see my customers? =

No to both. Shoppers check out on your own store, through your own payment
gateway — PepSpectrum never handles the money. Since version 1.6.7 the plugin
sends no customer information at all: order reports carry amounts and references
only.

= Which products get sent to the marketplace? =

Every **published** product that has a SKU. Drafts, private and pending products
never leave your store. Whether a listing is actually shown to shoppers is a
separate switch you control from your PepSpectrum dashboard, not from WordPress.

= Why is one of my products missing from the marketplace? =

Almost always a missing SKU. Check **WooCommerce → PepSpectrum** — it reports how
many published products have no SKU, and how many variations are falling back to
their parent's SKU. Both cases are also flagged on the product edit screen.

= Are my orders reported to PepSpectrum? =

Only orders that PepSpectrum referred. The plugin marks those orders when the
buyer arrives, and checks for that mark before reporting anything. Organic orders
are never involved.

= How do I share a lab report (COA) for a product? =

Edit the product, upload the certificate PDF using the **Add Media** button, and
save. That is all — the plugin finds it and sends the link with your listing. The
file stays on your own server; only its address is shared.

For a variable product, upload the PDF to a variation to give that size its own
certificate, or to the parent product to cover every variation at once.

A PDF uploaded through **Media → Add New** is not matched to any product, so it
is not found this way. Add its link from your PepSpectrum dashboard instead.

= Will this slow down my store? =

No. Every call to the marketplace is queued and runs in the background through
Action Scheduler (which ships with WooCommerce), so checkout and admin saves are
never blocked waiting on the network.

= Where do I see what the plugin is doing? =

**WooCommerce → Status → Logs**, source `pepspectrum-connect`.

= Does it work with HPOS and the block checkout? =

Yes. The plugin declares compatibility with WooCommerce's High-Performance Order
Storage and with the block-based cart and checkout, and uses the WooCommerce CRUD
API throughout.

= How do I disconnect? =

Deactivate the plugin. Your scheduled background sync is cancelled, and nothing
further is sent. Deleting the plugin also removes its settings; your products and
orders are untouched.

== Changelog ==

= 1.9.0 =
* Internal rename: everything the plugin registers or stores in WordPress now
  uses the `pepsc` prefix (the previous `mpc` prefix was shorter than the four
  characters the directory guidelines require). Your settings, marketplace
  order tags, COA links and any queued background work are migrated
  automatically the first time the updated plugin loads — no action needed.
* No functional changes: syncing, checkout links and order reporting behave
  exactly as before, and the connection to PepSpectrum is uninterrupted.

= 1.8.0 =
* Lab reports are now found automatically. Upload a Certificate of Analysis PDF
  to a product the normal way and the plugin sends its link with your listing —
  no address to copy, no field to fill in. On a store with fifty products that
  replaces fifty rounds of copy-and-paste with nothing at all.
* The four COA fields the plugin used to add to the product and variation edit
  screens are gone. The plugin no longer adds anything to your product screen.
* Variations use their own attached PDF, falling back to the parent product's —
  so one certificate uploaded to the parent covers every size.
* Testing lab, batch and test date are no longer collected. The certificate
  itself carries them, and they are on the document a shopper opens.
* A COA link entered on your PepSpectrum dashboard now always wins over a
  discovered PDF, and a sync can no longer erase it.
* If you previously filled in the plugin's COA URL field, that value is still
  read and keeps working — you do not need to re-enter anything.

= 1.7.0 =
* Updates now come from the WordPress Plugin Directory. The plugin's own update
  checker has been removed, along with the version manifest it fetched from
  pepspectrum.com — WordPress handles updates like any other directory plugin.
* The "WooCommerce required" admin notice is now dismissible, and the plugin
  declares its WooCommerce dependency through the standard `Requires Plugins`
  header on WordPress 6.5+.
* Full catalogue and stock syncs now read products in pages instead of loading
  the entire catalogue in one query — large stores no longer risk running out of
  memory when a sync starts. The SKU scan behind the settings-page warning does
  the same.
* Failed requests to the two public endpoints (checkout handoff, sync trigger)
  are now logged at most once a minute per failure type, so a flood of malformed
  requests can no longer fill the log.
* Deactivating the plugin now cancels its daily background sync.
* Renamed for consistency with the plugin's name: the plugin folder, text domain,
  settings-page address and log source are now all `pepspectrum-connect` rather
  than the original `mp-connect`. Your existing log files stay where they are
  under the old name; new entries appear under **WooCommerce → Status → Logs**,
  source `pepspectrum-connect`.
* Internal: the hub API contract moved out of this readme into the developer
  documentation.

= 1.6.7 =
* Privacy: the plugin no longer sends the buyer's email address — or any other
  customer data — to PepSpectrum. Order reports now carry amounts, currency,
  status and order references only. Orders are matched by `mp_order_id`
  instead, which PepSpectrum already issued when it referred the buyer.
* No action needed. Existing installs keep working; the marketplace simply
  receives one field fewer.

= 1.6.6 =
* Fix: the "View details" window on the Plugins screen now shows the plugin's
  own information.
* All plugin links and the update endpoints now use www.pepspectrum.com.

= 1.6.5 =
* Rebrand: the plugin is now named "PepSpectrum Connect" (author PepSpectrum).
  The wp-admin menu is WooCommerce → PepSpectrum. Folder, log source
  (mp-connect) and all APIs are unchanged — existing installs update in place.

= 1.6.4 =
* New: self-hosted automatic updates. (Removed again in 1.7.0, which moves
  updates to the WordPress Plugin Directory.)

= 1.6.3 =
* Commission base change: order events now carry the product-level amounts
  (items_subtotal, discount_total, items_net, shipping_total, tax_total).
  Commission is booked on items_net — products after discounts, excluding
  shipping and tax (the affiliate-industry standard) — instead of the order
  grand total. Refund events carry the refunded product value so reversals
  follow the same base.

= 1.6.2 =
* Fix: variation names that already contain the attribute summary are no longer
  suffixed again — offers arrived as "BPC-157 - 5mg - 5mg" and could not be
  matched.
* Fix: stock changes on a variable *parent* product are no longer pushed —
  parents are never offers, so the push only created a phantom SKU stub.

= 1.6.1 =
* Fix: variations without their own SKU are no longer synced under the SKU they
  inherit from their parent. Previously every strength of a variable product
  overwrote a single marketplace offer and its checkout links could not be
  fulfilled. Such variations are now skipped (with a log warning) until they get
  a unique SKU. Stock pushes and removals follow the same own-SKU rule.
* Fix: catalog batch requests now wait up to 30s instead of 15s.

= 1.6.0 =
* New: the daily full sync and "Sync product catalog" now send products in
  batches of up to 100 instead of one request per SKU. A 500-product catalog
  goes from 500 signed requests to 5 — far less load on the store during a sync.
  Real-time single-product saves are unchanged.

= 1.5.5 =
* Fix: variations now report their size, so a 5/10/15mg product no longer pushes
  three offers with identical names that fail to match.
* Fix: variation links now carry the attribute query string, so a buyer arrives
  with the size they clicked already selected.
* New: products that cannot be listed because they have no SKU now say so
  instead of disappearing silently — a note on the product screen, a warning on
  save, and a store-wide count on the settings page.
* New: variations with no SKU of their own are flagged.

= 1.5.4 =
* Tweak: the sync-card status is now a single clear sentence per state.

= 1.5.3 =
* Fix: on stores that require an account, a buyer who registered or logged in
  mid-handoff was stranded on My Account with the cart silently ready.
  Registration and login now return the buyer straight to checkout.

= 1.5.2 =
* Fix: full catalog sync only delivered one product. Action Scheduler's "unique"
  flag dedupes by hook name alone, so a burst of per-product jobs silently
  dropped every job after the first. Dedupe is now per item.

= 1.5.1 =
* Handoff coupons never discount sale items: codes carried in a marketplace
  checkout link are enforced as "exclude sale items" for that buyer's session,
  so a store sale and the marketplace discount can never stack unexpectedly.

= 1.5.0 =
* Zero-config connection: vendors only paste their API Key + Secret.
* Test/Live mode and the per-feature toggles are removed from the UI. Every sync
  feature is always on.
* Commission rate removed from the plugin entirely — the rate is set per vendor
  on PepSpectrum and shown in the vendor dashboard.
* Coupon sync removed, replaced by a single storewide marketplace discount code
  registered on the dashboard and auto-applied on cart rebuild.
* Sync buttons now show state.

= 1.4.0 =
* Coupon sync (removed again in 1.5.0).
* Certificate of Analysis (COA) fields per product and per variation.
* Checkout handoff applies any coupons carried in the signed link.

= 1.3.0 =
* Thin-connector rework: the plugin is now a pure data pipe. Choosing what
  appears on the marketplace, and mapping SKUs to comparison pages, moved to the
  PepSpectrum dashboard.
* Every published product syncs automatically; unpublishing sends a withdrawal.
* Inbound signed sync trigger, and a daily full-sync safety net.

= 1.2.0 =
* Marketplace screen in wp-admin with per-row listed toggles, mapping picker and
  live status. (Removed in 1.3.0.)

= 1.1.0 =
* Product catalog sync with a per-product "List on marketplace" toggle.

= 1.0.0 =
* Initial release: linking, stock sync, checkout handoff, order/refund events,
  HPOS + block-checkout compatible.

== Upgrade Notice ==

= 1.9.0 =
Internal storage-prefix rename with an automatic one-time migration. Nothing
about syncing or checkout changes, and no action is needed.

= 1.8.0 =
Lab reports are now picked up automatically from a PDF attached to the product,
and the plugin's COA fields are removed from your product screen. Anything you
already entered keeps working.

= 1.7.0 =
Updates now come from WordPress.org instead of pepspectrum.com. Large stores get
a memory-safe catalogue sync. No settings change and no action needed.

= 1.6.7 =
The plugin no longer sends any customer data to PepSpectrum. No action needed.

= 1.6.1 =
Fixes variations without their own SKU overwriting each other into one listing.
If you sell variable products, give every variation a unique SKU after updating.
