Manage in product code by product

How can I edit the products in my store, one by one, to add a feature that needs to be included in each product? I’ve already connected my ERP, but now I need to display that stock information.

This function is in JS but I cannot find a way to show the information of my products (in Wix) one by one and call the function from the backend. If someone can help me,
I’ll appreciate it

To display stock information from your ERP in Wix, you can use a combination of Wix’s built-in features and custom JavaScript. Here’s a general approach:

  1. Integrate ERP with Wix: Ensure your ERP is properly connected to your Wix store. This might involve using APIs or third-party apps to sync inventory data.
  2. Fetch Stock Information: Use JavaScript to fetch stock information from your ERP. You can use AJAX or Fetch API to retrieve the data.
  3. Display Stock Information: Update your product pages to display the stock information dynamically.

Here’s a basic example of how you might implement this:

// Fetch stock information from ERP
async function fetchStockInfo(productId) {
    const response = await fetch('YOUR_ERP_API_ENDPOINT');
    const data = await response.json();
    return data[productId].stock;
}

// Update stock information on product pages
document.addEventListener('DOMContentLoaded', () => {
    const products = document.querySelectorAll('.product-item');
    products.forEach(product => {
        const productId = product.dataset.productId;
        fetchStockInfo(productId).then(stock => {
            product.querySelector('.stock-info').textContent = `In Stock: ${stock}`;
        });
    });
});

In this example, replace 'YOUR_ERP_API_ENDPOINT' with the actual endpoint of your ERP API. The fetchStockInfo function retrieves stock information for a given product ID, and the event listener updates the stock information on your product pages when they load.