Price Books and Shopify Connector

For those who already have a Shopify Data Connector set up, you may want to extend the embedded pricings with Standalone Price Books. This guide will help you properly ingest pricings in order to make connections to the correct variant.

Quick Start

  1. Ingestion API Setup

    Setup a custom data source for the ingestion API.

    The Ingestion API REST endpoint is https://ingest.api.nacelle.com/v1/price-book.
    To make use of it, you must provide the following headers in your requests:

    x-nacelle-space-id
    x-nacelle-source-id
    x-nacelle-ingest-token

    You can find the values of these headers on the API Details page. To get there, select a space, navigate to Space Settings, then go to the API Details tab.

    The x-nacelle-ingest-token can be generated by clicking on the Create New Key button.

  2. Create Price Book

    Use the generated ingest token to make a PUT request to the Ingest Price Book endpoint. Here is an example:

     const fetch = require('node-fetch');
    
     const url = 'https://ingest.api.nacelle.com/v1/price-book';
     const options = {
       method: 'PUT',
       headers: {
         accept: 'application/json',
         'x-nacelle-space-id': '1234',
         'x-nacelle-source-id': '1234',
         'x-nacelle-ingest-token': '1234',
         'content-type': 'application/json'
       },
       body: JSON.stringify({
         entries: [
           {
             sourceEntryId: '3858f62230ac3c915f300c664312c63g',
             createdAt: '2023-09-16T00:00:00',
             updatedAt: '2023-09-16T00:00:00',
             name: 'Japanese Experience',
             key: 'japan',
             currencyCode: 'JPY',
             countryCodes: [
               'JP'
             ]
           }
         ]
       })
     };
    
     fetch(url, options)
       .then(res => res.json())
       .then(json => console.log(json))
       .catch(err => console.error('error:' + err));
    
  3. Create Pricing

    Use the generated ingest token to make a PUT request to the Ingest Pricing endpoint. This will create a pricing linking it to the previously created Price Book and a variant in Shopify.

    The entryTypeSourceIdMap ensures that the sourceVariantId belongs to the entry type PRODUCT_VARIANT. The NACELLE_SHOPIFY_SOURCE_ID is the source ID as seen below:

    Make sure the sourceVariantId matches what was ingested by Shopify for that given variant.

    Here is an example:

     const fetch = require('node-fetch');
    
     const url = 'https://ingest.api.nacelle.com/v1/pricing';
     const options = {
       method: 'PUT',
       headers: {
         accept: 'application/json',
         'x-nacelle-space-id': '1234',
         'x-nacelle-source-id': '1234',
         'x-nacelle-ingest-token': '1234',
         'content-type': 'application/json'
       },
       body: JSON.stringify({
         entryTypeSourceIdMap: {
           PRODUCT_VARIANT: 'NACELLE_SHOPIFY_SOURCE_ID'
         },
         entries: [
           {
             sourceEntryId: '3858f62230ac3c915f300c664312c63f',
             sourcePriceBookId: '2855f62230ac3c915f300c664312c62g',
             sourceVariantId: 'gid://shopify/Variant/0000000000000',
             createdAt: '2023-09-16T00:00:00',
             updatedAt: '2023-09-16T00:00:00',
             price: {
               amount: 1200,
               currencyCode: 'JPY'
             }
           }
         ]
       })
     };
    
     fetch(url, options)
       .then(res => res.json())
       .then(json => console.log(json))
       .catch(err => console.error('error:' + err));
    
  4. Query Pricing on a Product Variant:
    You can retrieve order details anytime by using our Storefront API endpoint.

     query allProducts {
       allProducts {
         edges {
           node {
             sourceEntryId
             variants {
               sourceEntryId
               pricing (filter: {currencyCode: "JPY"}) {
                 price {
                   amount
                   currencyCode
                   precisionDigits
                 }
               }
             }
           }
         }
       }
     }