# Shopify Integration

Connect your BuyerKiosk account to Shopify to push products directly from your buy queue to your online store, complete with images, pricing, and inventory tracking.

---

## What This Integration Does

The Shopify integration lets you list items you've purchased (buys) for resale on your Shopify storefront without leaving BuyerKiosk. When a product is scanned and entered into BuyerKiosk, it can be sent to Shopify with all its details, including:

| Data | What Gets Synced |
|------|-----------------|
| **Product Info** | Title, brand, description, type, tags |
| **Variants** | Color, size, price, SKU |
| **Images** | Product photos uploaded via drag-and-drop |
| **Inventory** | Quantity is set to 1 and tracked by Shopify |

Products flow in one direction -- from BuyerKiosk to Shopify. When a product is successfully posted, its Shopify Product ID is stored locally so it can be managed (returned to listing or removed) later.

---

## Getting Started

### Requirements

Before connecting, make sure you have:

- A Shopify store with API access enabled
- Your Shopify API credentials (API Key, Password, and Store URL)
- Your Shopify Location ID (found in Shopify Admin under **Settings > Locations**)
- Admin access to your BuyerKiosk store

### Configuring the Connection

Shopify credentials are stored at the store level. To configure:

1. Contact BuyerKiosk support to have your Shopify credentials added to your store configuration
2. Provide the following details:
   - `Shopify Store URL` -- your myshopify.com URL (e.g., `your-store.myshopify.com`)
   - `Shopify API Key` -- from your Shopify private app
   - `Shopify Password` -- the API password for your private app
   - `Shopify Location ID` -- the numeric ID of the inventory location to use

> **Tip:** You can find your Location ID in the Shopify Admin URL when viewing a location. It appears as the number at the end of the URL.

---

## Using the Product Upload Page

Once Shopify is connected, your store will have access to the Shopify Product Upload page.

### How Product Scanning Works

1. Products are scanned at the POS or entered via the BuyerKiosk app
2. Product details (SKU, title, brand, color, size, price, type, tags, description) are sent to BuyerKiosk via the API
3. The product appears in real-time on the **Shopify Product Upload** page
4. A team member reviews the product, uploads photos, and posts it to Shopify

### Uploading Product Images

Each product on the upload page has a drag-and-drop zone for images:

1. Drag JPEG or PNG images onto the dropzone area for the product
2. Images are automatically resized to 1200px height to optimize file size
3. Maximum file size is 10 MB per image
4. Multiple images can be uploaded per product

> **Tip:** Images larger than 5 MB are automatically compressed to 90% quality to save storage space.

### Posting a Product to Shopify

After images are uploaded:

1. Click `Post to Shopify` on the product card
2. A spinner will appear while the product is being submitted
3. On success, the product card is automatically removed from the queue
4. The product is now live on your Shopify store

### Removing a Scanned Product

If a product should not be posted to Shopify:

1. Click the red `x` button on the product card
2. Confirm the deletion when prompted
3. The product is removed from the upload queue

---

## Product Details

### What Gets Created in Shopify

When a product is posted, BuyerKiosk creates a Shopify product with:

- **Title** -- the product name
- **Vendor** -- the brand name
- **Product Type** -- the item category
- **Tags** -- searchable tags for your store
- **Description** -- the HTML body description
- **Variants** -- one variant with the SKU, color, and optionally size
- **Price** -- set from the BuyerKiosk price field
- **Inventory** -- tracked by Shopify, quantity adjusted by +1 at your configured location
- **Images** -- all uploaded photos

### Product Variants

Products with a size value will have two variant options (Color and Size). Products without a size will only have a Color option.

---

## Real-Time Updates

The Shopify integration uses real-time messaging (via Ably) to keep the upload page synchronized across devices:

- **New product scanned** -- appears instantly on all open upload pages
- **Product posted to Shopify** -- removed from all open upload pages
- **Product deleted** -- removed from all open upload pages

This means multiple team members can work on the upload queue simultaneously without conflicts.

---

## Re-listing a Returned Product

If a product sold on Shopify is returned, it can be re-listed:

1. The POS system sends the SKU(s) to the return endpoint
2. BuyerKiosk clears the old Shopify Product ID
3. The product is automatically re-posted to Shopify as a new listing
4. A new Product ID and inventory item are created

---

## Troubleshooting

### Product fails to post with "API Error"

- **Cause:** The Shopify API rejected the product data, often due to invalid or missing required fields.
- **Solution:** Check that the product has a valid title, brand, price, and at least a color value. Review the `shopify.log` file for detailed error messages.

### Images not appearing on Shopify listing

- **Cause:** Images must be accessible via a public URL for Shopify to download them.
- **Solution:** Verify that your BuyerKiosk server's upload directory is publicly accessible. Image URLs follow the pattern `/upload/shopify/{typeNum}/{sku}.jpg`.

### "Inventory update failed after 5 retries"

- **Cause:** The product was created on Shopify but the inventory level could not be set. This can happen if the Shopify Location ID is incorrect or the inventory item is not yet ready.
- **Solution:** The product was still created successfully. Update the inventory quantity manually in Shopify Admin. Verify your `Shopify Location ID` is correct.

### Product shows as "Invalid SKU" when submitting

- **Cause:** The SKU was not found in the local database.
- **Solution:** The product may have been deleted before posting. Re-scan the item to create a new entry.

### Duplicate products on Shopify

- **Cause:** If a product is scanned multiple times, each scan creates a separate entry.
- **Solution:** Delete duplicate entries from the upload queue before posting. Each SKU should only be posted once.

---

## Related Articles

- [Adding a Buy to the Queue](/support/articles/adding-a-buy-to-the-queue)
- [QuickBooks Integration](/support/articles/quickbooks-integration)
- [FiveStars Loyalty Integration](/support/articles/fivestars-loyalty-integration)
