Skip to content

ffl_woo_sync.woocommerce.client_api

Source: apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py · 10 endpoint(s)

Generated by make api-docs — do not edit by hand.

delist_item_now

POST /api/method/ffl_woo_sync.woocommerce.client_api.delist_item_now

Auth (derived from code): Roles: Stock Manager / System Manager

Set the WooCommerce product for an Item to draft + stock 0.

The operator's deliberate delist — the only delist_item caller that raises the republish sentinel.

arg type required default description
item_code string yes — The Item to delist.
site string no 'retail' "retail" (default; the only store).

Returns: {"ok": True, "raw": }.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:296

delist_serial_now

POST /api/method/ffl_woo_sync.woocommerce.client_api.delist_serial_now

Auth (derived from code): Roles: Stock Manager / System Manager

Set the WooCommerce product for a Serial No to draft + stock 0.

arg type required default description
serial_no string yes — The Serial No to delist.
site string no 'retail' "retail" (default; the only store).

Returns: {"ok": True, "raw": }.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:363

pull_product_from_woo

POST /api/method/ffl_woo_sync.woocommerce.client_api.pull_product_from_woo

Auth (derived from code): Roles: Stock Manager / System Manager

Overwrite a POS record's listing content from its WooCommerce product.

The reverse of push_item_now / push_serial_now, for the storefront plugin's product page's "overwrite POS from WooCommerce" button: pulls title, description, price and gallery images from the live WC product and writes them onto the Item (or, for an item_code::serial_no SKU, the Serial No). Stock and attributes are never pulled — the POS stays their source of truth. The save runs under the inbound loop guard, so doc_events does not push the change straight back at WooCommerce.

arg type required default description
sku string yes — WooCommerce product SKU — item_code for an item-level product, item_code::serial_no for a per-serial firearm.
site string no 'retail' "retail" (default; the only store).

Returns: {"ok": True, "doctype": ..., "name": ..., "updated": {field: summary}, "images_imported": n, "image_errors": [...]} — plus "price_note" (optional) when the price was deliberately not written (uniform-priced parent). The Item branch reports the applied price as updated["selling_price"] (it lands via the canonical selling-price helper, not a bare standard_rate write). Refusals (unknown record, never pushed, missing write permission, product deleted on the store) raise a ValidationError with the reason.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:470

push_all_serials

POST /api/method/ffl_woo_sync.woocommerce.client_api.push_all_serials

Auth (derived from code): Roles: Stock Manager / System Manager

Push (create or update) WC products for all Active Serial Nos of an Item.

Uses a single pre-built client and pre-fetched attribute IDs to minimise HTTP round-trips. Returns per-serial results and any errors encountered.

.. note:: Aggregating semantics — every serial is attempted regardless of earlier failures; errors are collected and returned rather than re-raised. This differs from :func:ffl_woo_sync.woocommerce.sync.push_all_serials which is fail-fast (re-raises the first per-serial exception immediately).

arg type required default description
item_code string yes — The Item whose Active serials to push.
site string no 'retail' "retail" (default; the only store).

Returns: {ok, pushed, errors, skipped, total}.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:249

push_item_now

POST /api/method/ffl_woo_sync.woocommerce.client_api.push_item_now

Auth (derived from code): Roles: Stock Manager / System Manager

Push (create or update) the WooCommerce product(s) for an Item.

Routing is determined server-side so all callers (Item form button, MCP, future automation) behave correctly without any client-side detection:

  • Per-serial firearm (is_firearm=1, uniform_sell_price=0): pushes every Active Serial No via :func:ffl_woo_sync.woocommerce.sync.push_serial. Returns {"ok": bool, "pushed": [...], "errors": [...], "skipped": [...], "total": int}. This branch does not pass _relist: a hidden gun stays hidden and lands in skipped (an Item-level bulk relist would also revive guns hidden one-by-one for holds or repairs). The per-gun route is the Serial No form's own button.
  • Non-firearm / uniform-price firearm: single item-level push via :func:ffl_woo_sync.woocommerce.sync.push_item. Returns {"ok": True, "woo_product_id": "<id>", "raw": <WC response>}. A template Item pushes its variable product and every variant; ok is False when a variation failed (variation_errors), and variants whose variation was deleted on the store are listed in dangling_variations.
arg type required default description
item_code string yes — The Item to push.
site string no 'retail' "retail" (default; the only store).

Returns: Per-serial branch: {ok, pushed, errors, skipped, total}; item-level branch: {ok, woo_product_id, raw, variation_errors, dangling_variations}.

Raises: ValidationError: User-facing message on WC / config errors.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:179

push_serial_now

POST /api/method/ffl_woo_sync.woocommerce.client_api.push_serial_now

Auth (derived from code): Roles: Stock Manager / System Manager

Push (create or update) the WooCommerce product for a single Serial No.

An operator's explicit push is the clearest relist there is, so this overrides the hidden-serial guard (a human may always undo a human's hide).

arg type required default description
serial_no string yes — The Serial No to push.
site string no 'retail' "retail" (default; the only store).

Returns: {"ok": True, "woo_product_id": "", "raw": } — or a skipped response when the sync guard refuses.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:325

reconcile_now

POST /api/method/ffl_woo_sync.woocommerce.client_api.reconcile_now

Auth (derived from code): Roles: Stock Manager / System Manager

Push the item product + all Active serials in a single call.

Uses a shared client and pre-fetched attribute IDs. Returns combined results: the item push result plus per-serial results and any errors.

Suitable for "initial listing" of a per-serial firearm item where you want to bring everything live in one operation.

FULL-PAYLOAD by design: as a deliberate, confirmed bulk action it keeps the manual-push semantics — which means it WILL overwrite wp-admin content edits (title / description / images) with the POS versions on every product it touches. Routine drift healing belongs to the scheduled reconcile, which is pos_fields_only and content-safe.

arg type required default description
item_code string yes — The Item to reconcile.
site string no 'retail' "retail" (default; the only store).

Returns: {ok, item_result, item_error, dangling, pushed_serials, serial_errors, skipped_serials, variation_errors, dangling_variations}.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:388

test_connection

POST /api/method/ffl_woo_sync.woocommerce.client_api.test_connection

Auth (derived from code): Roles: System Manager

Probe the WooCommerce store via GET /products?per_page=1 (read auth only).

arg type required default description
site string no 'retail' "retail" (default; the only store).

Returns: {"ok": True, "store_url": ..., "raw": }.

Raises: ValidationError: Settings incomplete or the API call fails — a clean user-facing message in both cases.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:148

web_events

POST /api/method/ffl_woo_sync.woocommerce.client_api.web_events

Auth (derived from code): Roles: Stock Manager / System Manager

Take the website's visitor events: a newsletter signup, a back-in-stock or model alert request.

Each event is processed on its own; one that fails leaves nothing behind and does not stop the rest. A repeated event id is answered as accepted again and processed only once. Nothing is emailed. The whole call is refused while Marketing Settings › Enabled is off, and the website sends the events again later.

arg type required default description
events — yes — A list (or its JSON) of at most 100 events, each {"id", "type", "occurred_at", "data"}. Types: contact.subscribed (data: email, first_name, last_name, source, page_url, ip, tags, interests, coupon) and alert.requested (data: email, kind back_in_stock or model, sku, product_id, product_name, url, model_key, model_label).

Returns: {"accepted": [id, ...], "rejected": [{"id": ..., "reason": ...}, ...]}. reason is unknown_type, invalid_email or invalid_data; an event in neither list failed unexpectedly (an Error Log is written) and should be sent again.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:547

web_inquiry

POST /api/method/ffl_woo_sync.woocommerce.client_api.web_inquiry

Auth (derived from code): Roles: Stock Manager / System Manager

File a website form submission in CRM: a price request, a sell-your-gun form or a question.

The email decides where it goes, as for incoming mail: a customer's open deal (one is opened when they have none), else their existing lead, else a new lead. The text goes on it as a note and as a received mail from the customer (staff answer it with Reply), and the gun asked about as a product line. A sell-your-gun request always makes a deal of its own, its known fields on the deal and its photos (links on the store's website) copied in later. Nothing is emailed to the customer. A repeat of the same event_id files nothing more. Does nothing when CRM is not installed.

arg type required default description
kind string yes — map_price, sell_gun or ask; anything else is refused.
event_id string yes — The website's id for this submission; makes a retry harmless.
email string yes — The sender's email address (required, validated).
full_name string no '' The sender's name.
phone string no '' The sender's phone number.
message string no '' What they wrote.
sku string no '' The gun asked about, item_code or item_code::serial_no; unknown ones are only noted.
url string no '' The product page, shown as a link in the note.
details — no None A flat object of label -> value (the sell-your-gun form's fields), as JSON or a dict.
photos — no None A list of https photo URLs, as JSON or a list.

Returns: {"filed": True, "doctype": "CRM Lead" | "CRM Deal", "name": ..., "created": bool}, or {"filed": False, "reason": ...} when CRM is not installed. Fields are length-capped and stored escaped.

apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:510