How to Sync your Inventory from Square POS to Wix
Who is our client and what problem did they want to solve?
Our client owns a store that sells disc golf products from their physical store and on-demand at different events.
They needed a way to sync inventory levels between products sold in their brick-and-mortar store through their Square Point of Sales system to their product inventory in Wix.
What solution did we provide?
To do this, we imported their products from Wix into Square, then took the resulting catalog and imported it into a content manager database containing the Square Product ID, the Wix Inventory Item ID, and the Wix Product ID. Then we created a webhook within Square to send data to the Wix site whenever inventory was updated within Square.

What is a webhook?
Webhooks are a service many software providers offer to allow for custom integrations. Essentially, when a specific event happens in their system, they send the data from that event to a URL you provide where you can have code set to receive data from that URL.
For this specific client, whenever the webhook fires, it tells us which Square product has an inventory update and we can look it up in the content manager database to find out which Wix Product it correlates to and then use the 'incrementInventory' or 'decrementInventory' API from the 'wix-stores-backend' module to make the inventory adjustment.
Check out the code we used below:
import { ok, badRequest } from 'wix-http-functions';
import wixData from 'wix-data';
import wixStoresBackend from 'wix-stores-backend';
export async function post_inventoryUpdate(request) {
const body = await request.body.json();
const objectData = body.data.object.inventory_counts[0];
const squareId = objectData.catalog_object_id;
const quantity = objectData.quantity;
const squareProduct = await wixData.query("SquareProducts").eq("squareId", squareId).find({ suppressAuth: true }).then(results => results.items[0]).catch(err => err);
const wixProduct = await wixData.query("Stores/Products").eq("_id", squareProduct.productId).find({ suppressAuth: true }).then(results => results.items[0]).catch(err => err);
const amountToChange = Math.abs(quantity - wixProduct.quantityInStock);
if (quantity > wixProduct.quantityInStock) {
// increment inventory
console.log("Incrementing inventory");
const incrementInfo = { productId: squareProduct.productId, variantId: squareProduct.variantId, incrementBy: amountToChange, inventoryId: squareProduct.inventoryId }
wixStoresBackend.incrementInventory([incrementInfo]).then(() => {
console.log("Inventory incremented by " + amountToChange)
return ok();
}).catch(err => console.log(err));;
} else {
// decrement inventory
console.log("Decrementing inventory");
const decrementInfo = { productId: squareProduct.productId, variantId: squareProduct.variantId, decrementBy: amountToChange, inventoryId: squareProduct.inventoryId }
wixStoresBackend.decrementInventory([decrementInfo]).then(() => {
console.log("Inventory decremented by " + amountToChange)
return ok();
}).catch(err => console.log(err));
}
return badRequest({body: 'Invalid request'});
}
Need help syncing your inventory or something else? Contact us at 225-250-1888 or email robert@roberthebertmedia.com.
About our company
RHM specializes in helping businesses of all sizes and across all industries achieve their digital and web marketing needs. Whether you are designing a new website, building an app, performing custom development, or running Google Ads, our goal is to showcase how you are the best at what you do and help people connect with you. Contact us at 225-250-1888 to get started!



Phần đồng bộ kho hàng làm tôi nhớ tới cái lần mẹ tôi ghi sổ tay bán hàng, cái nào hết thì gạch, cái nào về thì thêm, chỉ một sơ suất nhỏ là cả buổi tính lại từ đầu. Bài viết mô tả việc nối hai hệ thống với nhau theo kiểu đó, và tôi thấy cách giải thích từng bước khá dễ nghe. Nghe kể chuyện, tôi còn nhớ anh hàng xóm hay khoe chuyện đánh tài xỉu md5 lúc rảnh, mình chỉ cười trừ vì không rành, coi như một thú kill khác của người ta. Xong bài, tôi nghĩ người bán lẻ thiệt cần bình yên trong đầu trước, dữ liệu chỉ là phần sau.
Tôi đang bán mấy món đồ nhỏ trên sàn trực tuyến nên phần đồng bộ tồn kho từ máy tính tiền vào website khá sát với việc của mình. Bài viết giải thích quy trình khá dễ hình dung, từ bán hàng xong thì mã hàng ghi ra, rồi trên website mới hiện theo. Cái khó chắc là phải phân biệt hàng nào bán ở cửa hàng với hàng nào chỉ bán online mà tôi đang gộp chung, bài có đề cập chứ tôi chưa nắm rõ cách xử lý. Đọc cũng thấy có phần hơi mơ hồ về việc cập nhật xong có bao lâu mới hiện trên trang, tùy vào tần suất cũng như cấu hình. Lúc kho…
Mình vừa đọc bài này vì đang định nối Square với Wix, phần giải thích quy trình khá dễ theo. Nhưng mình không rành mảng kỹ thuật nên vẫn phải đọc đi đọc lại vài đoạn mới thấy chỗ nào quan trọng. Nghe nhắc tới app tài xỉu online khi đang nghĩ về việc quản lý bán hàng, thấy hơi lệch mạch, nhưng cũng thú vị vì cùng là mấy thứ chạy trên điện thoại. Nói chung bài cho mình cái nhìn tổng quan, còn phần thực tế chắc phải xem thêm.
Bài hướng dẫn nối kho với Square POS và Wix làm mình nhớ cảnh bà chị bán đồ nhỏ ghi sổ tay rồi lại đối chiếu máy. Hôm ngồi chờ đóng hàng, chị mở keonhacai trên máy tính cho khuây, mình mới bảo để đó rồi tính tiếp chuyện nhập kho, vì hai việc khác nhau mà dễ làm chị quên bên nào mới cần chú ý. Bài này đi thẳng vào bước đồng bộ, phần cảnh báo về cập nhật hai đầu khá hữu ích, riêng mình vẫn chưa rõ dữ liệu cũ sẽ xử lý thế nào khi bắt đầu.
Đoạn về đồng bộ kho là phần mình đọc kỹ nhất vì tiêu đề rất thực dụng, nhưng bài lại chưa giải thích rõ chuyện gì xảy ra khi hai bên lệch dữ liệu. Phần hướng từng bước khá dễ theo, chỉ có đoạn edge case là mình phải đọc lại. Nhà mình có người làm bán hàng nhỏ, thỉnh thoảng họ nói chuyện phần mềm, mình ngồi nghe chứ không rành; có lần nghe kèm tên Sunwin trong một câu về game nên cái tên đi theo đầu mình một lát, còn lại mình không biết gì thêm. Giữa bài có một đoạn chuyển khá gọn, làm mình nghĩ đây là chỗ bài đang trả lời đúng câu hỏi nhất.