top of page

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!





 
 
 

35 Comments


donaldharris95570
13 hours ago

Bài viết này giải thích khá kỹ về cách đồng bộ kho hàng giữa Square POS và Wix, giúp người bán tối ưu hóa quy trình quản lý thực tế. Đọc đến phần xử lý dữ liệu tồn kho, tôi chợt nhớ đến mấy người bạn hay bàn tán về các nền tảng như F8BET trong những lúc giải trí, khi họ so sánh sự phức tạp của các hệ thống quản trị với giao diện của những cổng game online thường thấy. Quả thật, việc kết nối hai hệ thống bán hàng đòi hỏi sự tỉ mỉ để tránh sai lệch thông tin, nhất là khi quy mô sản phẩm ngày càng lớn. Việc nắm vững các bước thiết lập…

Like

Bài viết này cung cấp các bước khá chi tiết cho việc đồng bộ kho hàng, giúp ích nhiều cho những ai đang quản lý cửa hàng trực tuyến trên Wix. Đọc xong phần hướng dẫn kết nối dữ liệu này, tôi chợt nhớ đến cậu bạn đồng nghiệp hay tranh thủ thời gian nghỉ trưa để giải trí nhanh trên F8BET. Dù thế giới thương mại điện tử và giải trí trực tuyến hoàn toàn khác biệt, nhưng cả hai đều đòi hỏi sự ổn định về hạ tầng kỹ thuật để vận hành trơn tru. Hệ thống quản trị của Square và Wix trông có vẻ phức tạp, nhưng khi nắm được logic liên kết thì việc quản…

Like

amandayoung42471
13 hours ago

Việc đồng bộ POS với nền tảng Wix giúp chủ doanh nghiệp rảnh tay hơn rất nhiều. Tôi tình cờ nghe người quen nhắc đến F8BET khi bàn về việc quản lý dữ liệu người dùng trên quy mô lớn, điều này làm tôi tò mò về tính bảo mật trong các hệ thống hiện nay. Giải pháp của bạn cung cấp các bước thực hiện khá rõ ràng cho những người không quá rành về kỹ thuật. Hy vọng những chia sẻ này sẽ giúp ích cho những ai đang muốn chuyển đổi số cho cửa hàng nhỏ của mình một cách thuận lợi.

Like

charlesperez09039
17 hours ago

Bài viết hướng dẫn khá chi tiết về việc đồng bộ kho hàng giữa Square POS và Wix, giúp người kinh doanh tối ưu hóa quy trình quản lý tồn kho hiệu quả hơn. Tôi đọc mà nhớ đến một người bạn hay phàn nàn về sự bất tiện khi phải quản lý dữ liệu thủ công trên nhiều nền tảng, kể cả khi cậu ấy giải trí tại F8BET cũng chỉ thích mọi thứ phải gọn gàng, tự động hóa để đỡ tốn thời gian. Dù mình không trực tiếp vận hành cửa hàng hay làm thương mại điện tử, cách cấu trúc dữ liệu như thế này vẫn rất hữu ích để hiểu về tư duy hệ thống. Việc…

Like

marco58710
17 hours ago

Việc đồng bộ kho hàng luôn là nỗi lo thường trực của các doanh nghiệp nhỏ. Khi đọc về sự kết nối giữa hai nền tảng này, tôi lại nhớ đến cơ chế quản lý tài khoản của F8BET mà tôi từng nghe nhắc đến, nơi mọi dữ liệu phải được đồng bộ chính xác từng giây. Công nghệ thực sự đã thay đổi cách chúng ta vận hành công việc kinh doanh một cách chóng mặt. Bài viết này cung cấp những chỉ dẫn rất thực tế, giúp người dùng tiết kiệm được không ít thời gian trong việc quản lý hệ thống bán hàng.

Like
bottom of page