Instant Inventory

Overview

RapNet Instant Inventory enables you to showcase thousands of diamonds and jewelry items from RapNet’s global suppliers on your website as a virtual store.
You can place a diamond feed on one page of your website and a jewelry feed on another page of your website. 

Instant Inventory is a live feed, therefore, all inventory is maintained by RapNet and changes reflect automatically in your Instant Inventory store. 

We offer 2 integration methods:

  1. RapNet’s pre-designed search engine widget
  2. An API that enables you to customize and build your own search engine

Note: 

  • Most e-commerce platforms are compatible with Instant inventory, for example, WordPress, WooCommerce, Wix, and  Shopify.
  • RapNet Instant Inventory is only accessible with a paid RapNet subscription.
  • Please contact RapNet Customer Service to verify that your current subscription includes the Instant Inventory add-on. 

Important: It is forbidden to download diamond data and/or import RapNet diamonds into your database.

Instant Inventory Setup

Members select type of diamonds and/jewelry they want on their site,  select suppliers , and mark up the price to display in the store. 

Requirements :

  1. Set up your feed for Instant Inventory 
  2. Select the diamonds or jewelry you want to display  
  3. Select suppliers 
  4. Choose markup you want to use 
  5. Set up an Login Token for the developer or tech team to access data and work on integration

Instant Inventory Integration

  1. Once you have set up your Instant Inventory feeds, integrate using either the pre-designed widget or API.
  2. RapNet pre-designed widget:
    • Is available for both diamond and jewelry feeds 
    • Is web and mobile-friendly 
    • Offers some customizable features 
    • Integrates into your website quickly and easily using the script provided and is scripted in HTML, so you may need a 3rd party web developer to help with integration

  3. API Integration
    • Available for diamond feeds only 
    • Gives you more freedom, whereby you can design your own website, build your own diamond search engine,and offer multiple currencies, languages 
    • Is ideal if you have existing e-commerce and shopping cart application.

        4. SDK Integration (Software Development Kit) 

    • Available for the diamond feed only 
    • Gives you more freedom, whereby you can design your website, build your diamond search engine, offer multiple currencies and languages.

 

Important:

We recommend that consult your website developer for assistance.   

There is currently no add-to-cart or API option for instant inventory jewelry.

To set up, choose the type of diamonds and jewelry you want on your site, select suppliers to work with, and mark up the price to display in the store.

API Integration Setting Requirements

  • Authentication: Each request must have a Bearer Token Value
  • Request method: All requests should be sent using POST 
  • Content-Type: Application/x-www-form-urlencoded 
  • URL: Encode the request
  • Optional values: Can be omitted or left blank 
  • Response: Always contains an “error code” field:   
    • If the error code field value is 0, the operation succeeded 
    • If the error code field value is not 0, you will need to check your code or contact Tech Support. 

Click here to generate your own sample code. 

To download certificates Use the following link :

https://www.diamondselections.com/GetCertificate.aspx?diamondid=XXX

NOTE: If you are using our old API, you only need to change the

  • Endpoint :

       Diamonds – https://technet.rapnetapis.com/instant-inventory/api/Diamonds 

       Single Stone – https://technet.rapnetapis.com/instant-inventory/api/SingleDiamond

  • Authentication Parameters : Bearer token

Sample Codes

Instant Inventory Diamonds Search

Instant Inventory Diamonds
				
					POST /instant-inventory/api/Diamonds HTTP/1.1
Host: technet.rapnetapis.com
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik56aERNVFkzUmtGRE56WXdOMEZDUVVWRE5qQTFOVU00TXpkRlJUTTVPVFF3T1VGRVEwTkdSUSJ
Content-Length: 1026

{
  "request": {

    "body": {
      "search_type": "White",
      "shapes": [
        "Round",
        "Pear",
        "Princess",
        "Marquise",
        "Oval",
        "Radiant",
        "Emerald",
        "Heart",
        "Cushion",
        "Asscher"
      ],
      "labs": [
        "GIA",
        "IGI",
        "NONE"
      ],
      "fluorescence_intensities": [
                "Faint"
       
      ],
      "fluorescence_colors": [
        "Blue",
        "Yellow",
        "Green",
        "Red",
        "Orange",
        "White"
      ],
      "size_from": "0.2",
      "size_to": "0.5",
      "color_from": "D",
      "color_to": "K",
      "clarity_from": "IF",
      "clarity_to": "SI3",
      "price_total_from": "100",
      "price_total_to": "1000000",
      "fancy_color_intensity_from": "",
      "fancy_color_intensity_to": "",
      "sort_by": "Price",
      "sort_direction": "Asc",
      "page_number": "1",
      "page_size": "20"
    }
  }
}

				
			
Parameters Details Mandatory\ optional
shapes
Allowed values : “Round”, “Pear”,
“Princess”, “Marquise”, “Oval”,
“Radiant”, “Emerald”, “Heart”,
“Cushion”, “Asscher”

optional

color_from
color_to
Allowed values : “D”, “E”, “F”, “G”,
“H”, “I”, “J”, “K”, “L”, “M”
optional
size_from
size_to
Example: 2.10
optional
fancy_colors
Allowed values :
“Yellow”,”Pink”,”Orange”,”Green”,
“Gray”, “Brown”,”Blue”,
“Black”,”Red”,”Purple”,”Violet”,”
Champagne”,”Cognac”,”Chameleon”
optional
fancy_color_intensity_from fancy_color_intensity_to
Allowed values : “Faint”,”Very Light”,”Light”,”Fancy Light”, “Fancy Dark”, “Fancy Intense”,”Fancy Vivid”, “Fancy Deep”
optional
clarity_from clarity_to
Allowed values : “IF”, “VVS1”, “VVS2”, “VS1”, “VS2”, “SI1”, “SI2”, “SI3”, “I1″,”I2″,”I3”
optional
cut_from cut_to
optional Allowed values : “Excellent”, “Very Good”, “Good”, “Fair”, “Poor”
optional
polish_from polish_to
Allowed values : “Excellent”, “Very Good”, “Good”, “Fair”, “Poor”
optional
symmetry_from symmetry_to
Allowed values : “Excellent”, “Very Good”, “Good”, “Fair”, “Poor”
optional
price_total_from price_total_to
Example : 100000
optional
labs
Allowed values : “GIA”, “IGI”, “AGS”, “HRD”, “PGS”, “DCLA”, “VGR”, “GCAL”,”NGTC”, “GSI”, “DBGIS”, “NONE”
optional
fluorescence_intensities
Allowed values : “Very Slight”, “Faint”, “Medium”, “Slight”, “Strong”, “Very Strong”,”None”
optional
fluorescence_colors
Allowed values : “Blue”, “Yellow”, “Green”, “Red”, “Orange”, “White”
optional
depth_percent_from depth_percent_to
Example : 66.7
optional
table_percent_from table_percent_to
Example : 54.2
optional
meas_length_from meas_length_to
Example : 6.41
optional
meas_width_from meas_width_to
Example : 3.91
optional
meas_depth_from meas_depth_to
Example : 3.12
optional
girdle_min girdle_max
Allowed values : “Extr Thin”, “Very Thin”, “Thin”, “Slightly Thin”, “Medium”, “Slightly Thick”, “Thick”, “Very Thick”, “Extr Thick”
optional
culet_sizes
Allowed values : “Very Small”, “Small”, “Medium”, “Large”
optional
eye_cleans
Allowed values : “Yes”, “Borderline”, “No”
optional
page_number
Example : 1
mandatory
page_size
Example : 20
mandatory
sort_by
Allowed values : “Price”,”Shape”,”Size”,”Color”, “Clarity”, “Cut”,”Lab”
optional
sort_direction
Allowed values : “Asc”,”Desc”
optional
Instant Inventory Diamond-Response
				
					{
    "response": {
        "header": {
            "error_code": 0,
            "error_message": ""
        },
        "body": {
            "diamond": {
                "sarine_file": null,
                "total_purchase_price": 540.0,
                "city": "New York",
                "country": "USA",
                "diamond_id": 76276757,
                "shape": "Radiant",
                "size": 0.36,
                "color": "",
                "fancy_color_dominant_color": "Yellow",
                "fancy_color_secondary_color": "",
                "fancy_color_overtone": "None",
                "fancy_color_intensity": "Fancy",
                "clarity": "SI2",
                "cut": "",
                "symmetry": "Good",
                "polish": "Very Good",
                "depth_percent": 57.4,
                "table_percent": 69.0,
                "meas_length": 4.37,
                "meas_width": 4.08,
                "meas_depth": 2.34,
                "girdle_min": "TK",
                "girdle_max": "VTK",
                "girdle_condition": "",
                "culet_size": "N",
                "culet_condition": "",
                "fluor_color": "",
                "fluor_intensity": "Faint",
                "has_cert_file": true,
                "lab": "GIA",
                "currency_code": "AUD",
                "currency_symbol": "AUD$",
                "cert_num": "5172950048",
                "stock_num": "PP3615-17-01-10",
                "video_url": "https://certimage.s3-accelerate.amazonaws.com/V360_viewers/v4.0/Vision360.html?surl=https://certimage.s3-accelerate.amazonaws.com/V360/_v4.0/&d=PP3615-17-01-10&sv=0,1,2,3,4,5",
                "has_video": true,
                "eye_clean": "",
                "has_image_file": true,
                "has_sarineloupe": false,
                "image_file": "https://certimage.s3-accelerate.amazonaws.com/V360_viewers/v4.0/Vision360.html?surl=https://certimage.s3-accelerate.amazonaws.com/V360/_v4.0/&d=PP3615-17-01-10&sv=0,1,2,3,4,5",
                "total_sales_price": 829.0,
                "total_sales_price_in_currency": 1268.0,
                "ratio": null,
                "is_bgm": false
            },
            "seller": {
                "account_id": 54505,
                "company": "M.I.D House Of Diamonds (Los Angeles)",
                "name": "Diamond Consultant",
                "email": "rapnet@middiamonds.com",
                "phone": "+ (1) 213 689-4355",
                "country": "United States",
                "state": "California",
                "city": "Los Angeles"
            }
        }
    }
}
				
			
Instant Inventory Diamonds – Fancy Color
				
					POST /instant-inventory/api/Diamonds HTTP/1.1
Host: technet.rapnetapis.com
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik16aERRMFExTURFeVJqSTNRa0k0TTBGRVJUZzFNekUzTWtOQ09UTXhNREZDTVVZM1JURkNNZyJscyJ9.MrXXQVrqdKJgdg
Content-Length: 1330


  {
  "request": {

    "body": {
      "search_type": "Fancy",
      "shapes": [
        "Round",
        "Pear",
        "Princess",
        "Marquise",
        "Oval",
        "Radiant",
        "Emerald",
        "Heart",
        "Cushion",
        "Asscher"
      ],
      "labs": [
        "GIA",
        "IGI",
        "NONE"
      ],
      "fluorescence_intensities": [
                 "Very Slight",
        "Faint",
        "Medium",
        "Slight",
        "Strong",
        "Very Strong",
        "None"
       
      ],
      "fluorescence_colors": [
        "Blue",
        "Yellow",
        "Green",
        "Red",
        "Orange",
        "White"
      ],
      "fancy_colors": [
        "Yellow",
        "Pink",
        "Orange",
        "Green",
        "Gray",
        "Brown",
        "Blue",
        "Black"
      ],
      "size_from": "0.2",
      "size_to": "0.5",
      "color_from": "D",
      "color_to": "K",
      "clarity_from": "IF",
      "clarity_to": "SI3",
      "price_total_from": "100",
      "price_total_to": "1000000",
      "fancy_color_intensity_from": "",
      "fancy_color_intensity_to": "",
      "sort_by": "Price",
      "sort_direction": "Asc",
      "page_number": "1",
      "page_size": "20"
    }
  }
}

				
			
Parameters Details Mandatory\ optional
shapes
Allowed values : “Round”, “Pear”,
“Princess”, “Marquise”, “Oval”,
“Radiant”, “Emerald”, “Heart”,
“Cushion”, “Asscher”

optional

size_from
size_to
Example: 2.10
optional
fancy_colors
Allowed values :
“Yellow”,”Pink”,”Orange”,”Green”,
“Gray”, “Brown”,”Blue”,
“Black”,”Red”,”Purple”,”Violet”,”
Champagne”,”Cognac”,”Chameleon”
optional
fancy_color_intensity_from fancy_color_intensity_to
Allowed values : “Faint”,”Very Light”,”Light”,”Fancy Light”, “Fancy Dark”, “Fancy Intense”,”Fancy Vivid”, “Fancy Deep”
optional
clarity_from clarity_to
optional Allowed values : “Excellent”, “Very Good”, “Good”, “Fair”, “Poor”
optional
polish_from polish_to
Allowed values : “Excellent”, “Very Good”, “Good”, “Fair”, “Poor”
optional
symmetry_from symmetry_to
Allowed values : “Excellent”, “Very Good”, “Good”, “Fair”, “Poor”
optional
price_total_from price_total_to
Example : 100000
optional
labs
Allowed values : “GIA”, “IGI”, “AGS”, “HRD”, “PGS”, “DCLA”, “VGR”, “GCAL”,”NGTC”, “GSI”, “DBGIS”, “NONE”
optional
fluorescence_intensities
Allowed values : “Very Slight”, “Faint”, “Medium”, “Slight”, “Strong”, “Very Strong”,”None”
optional
fluorescence_colors
Allowed values : “Blue”, “Yellow”, “Green”, “Red”, “Orange”, “White”
optional
depth_percent_from depth_percent_to
Example : 66.7
optional
table_percent_from table_percent_to
Example : 54.2
optional
meas_length_from meas_length_to
Example : 6.41
optional
meas_width_from meas_width_to
Example : 3.91
optional
meas_depth_from meas_depth_to
Example : 3.12
optional
girdle_min girdle_max
Allowed values : “Extr Thin”, “Very Thin”, “Thin”, “Slightly Thin”, “Medium”, “Slightly Thick”, “Thick”, “Very Thick”, “Extr Thick”
optional
culet_sizes
Allowed values : “Very Small”, “Small”, “Medium”, “Large”
optional
eye_cleans
Allowed values : “Yes”, “Borderline”, “No”
optional
page_number
Example : 1
mandatory
page_size
Example : 20
mandatory
sort_by
Allowed values : “Price”,”Shape”,”Size”,”Color”, “Clarity”, “Cut”,”Lab”
optional
sort_direction
Allowed values : “Asc”,”Desc”
optional
Instant Inventory Fancy Diamonds-Response
				
					{
    "response": {
        "header": {
            "error_code": 0,
            "error_message": ""
        },
        "body": {
            "search_results": {
                "diamonds_returned": 20,
                "total_diamonds_found": 352,
                "sorted_by": "Price",
                "sort_direction": "Asc"
            },
            "diamonds": [
                {
                    "diamond_id": 142649117,
                    "shape": "Round",
                    "size": 0.3,
                    "color": "",
                    "fancy_color_dominant_color": "Brown",
                    "fancy_color_secondary_color": "",
                    "fancy_color_overtone": "None",
                    "fancy_color_intensity": "Very Light",
                    "clarity": "SI2",
                    "cut": "Very Good",
                    "symmetry": "Excellent",
                    "polish": "Excellent",
                    "depth_percent": 59.2,
                    "table_percent": 58.5,
                    "meas_length": 4.33,
                    "meas_width": 4.38,
                    "meas_depth": 2.58,
                    "girdle_min": "",
                    "girdle_max": "",
                    "girdle_condition": "",
                    "culet_size": "M",
                    "culet_condition": "",
                    "fluor_color": "",
                    "fluor_intensity": "Slight",
                    "has_cert_file": true,
                    "lab": "IGI",
                    "currency_code": "AUD",
                    "currency_symbol": "AUD$",
                    "cert_num": "262774416",
                    "stock_num": "C05019",
                    "video_url": null,
                    "has_video": false,
                    "eye_clean": "",
                    "has_image_file": false,
                    "has_sarineloupe": false,
                    "image_file": null,
                    "total_sales_price": 231.0,
                    "total_sales_price_in_currency": 354.0,
                    "ratio": null,
                    "is_bgm": false
                },
				
			

Instant Inventory Get Diamond Sample Code

Diamond_ID This is the diamond Id that is generated from the response above.

Single diamond Details
				
					POST /instant-inventory/api/SingleDiamond HTTP/1.1
Host: technet.rapnetapis.com
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik16aERRMFExTURFeVJqSTNRa0k0TTBGRVJUZzFNekUzTWtOQ09UTXhNREZDTVVZM1JURkNNZyJ9s
Content-Length: 142

{
    "request": {
        "header": {
            
        },
        "body": {
            "diamond_id": 118134969
        }
    }
}
				
			
Response
				
					
{
"response": {
"header": {
"error_code": 0,
"error_message": ""
},
"body": {
"diamond": {
"diamond_id": 118134969,
"shape": "Round",
"size": 0.2,
"color": "H",
"fancy_color_dominant_color": "",
"fancy_color_secondary_color": "",
"fancy_color_overtone": "",
"fancy_color_intensity": "",
"clarity": "I1",
"cut": "Good",
"symmetry": "Good",
"polish": "Very Good",
"depth_percent": 61.8,
"table_percent": 58,
"meas_length": 3.68,
"meas_width": 3.71,
"meas_depth": 2.35,
"girdle_min": "M",
"girdle_max": "STK",
"girdle_condition": "",
"culet_size": "N",
"culet_condition": "",
"fluor_color": "",
"fluor_intensity": "None",
"has_cert_file": true,
"country": "",
"city": "",
"lab": "NONE",
"currency_code": "CAD",
"currency_symbol": "CAD$",
"cert_num": "",
"stock_num": "2559",
"video_url": "",
"has_sarineloupe": false,
"sarineloupe_url": "",
"has_imagefile": false,
"has_image_file": false,
"imagefile_url": "",
"total_purchase_price": 68,
"total_sales_price": 96,
"total_sales_price_in_currency": 122
},
"seller": {
"account_id": 12345,
"company": "Rapaport",
"name": "Mr Rapaport",
"email": "Help@diamonds.net",
"phone": "",
"country": "USA",
"state": "NJ",
"city": "Teaneck"
}
}
}
}
				
			

SDK Integration

Get Diamonds:

$response = $iinventory->getDiamondInfo($token, $feedId, $filters);

Get Diamond Info:

$response = $iinventory->getDiamondInfo($token, $feedId, $filters);

Get Diamonds:

response = jewelryRouters.getDiamondInfo(token, feedId, data);

Get Diamond Info:

response = jewelryRouters.getDiamondInfo(token, feedId, data);

Add to Cart Integration

Developers need to integrate code for the Add to Cart button to function.
They must first create the product in the e-commerce platform inventory and then save the output to the platform inventory. 
As well as the sample code below, please also read this article for a full understanding of the Add to Cart integration.

Add to Cart integration
				
					<script type="text/javascript">

(function(d, w) {
function observeAddToCart() {
jQuery(w).on('ds.addtocart', function(event, data) {
jQuery.ajax({
//This is the API to where to POST the data to.
url: '/api/add_to_inventory_and_add_to_cart',
type: 'POST',
data: data
}).done(function(res) {
//On success of the API call
w.location = '/success';
}).fail(function(res) {
//On fail of the API call
alert(res.message);
});
});
}
if (d.addEventListener) {
d.addEventListener('ds.ready', function() {
observeAddToCart();
}, false);
} else if (d.attachEvent) {
d.documentElement.attachEvent('onpropertychange', function(event) {
if (event.propertyName === 'ds.ready')
observeAddToCart();
});
}
}(document, window));

</script>
				
			

<script type=”text/javascript”>
(function(d, w) {
function observeAddToCart() {

// console.error(‘TRIGGER’);

window.addEventListener(
‘ds.addtocart’,
ev => {
// console.log(‘!!!’, JSON.stringify(ev.detail.diamond, null, 2));
jQuery.getJSON(‘/products/’+ ev.detail.diamond.id +’.js’, function(product, status, xhrr) {
console.log(`product = ${JSON.stringify(product, null, 2)}`);
ev.detail.diamond[`shopify_product_id`] = product.id;
jQuery.post(‘https://[email protected]/createProduct’, ev.detail.diamond, function(data){
console.log(`data = ${JSON.stringify(data)}`);
var productJSON = [{
quantity: 1,
id: product.variants[0].id,
properties: {
Colour: ev.detail.diamond.color.color,
Clarity: ev.detail.diamond.clarity,
Shape: ev.detail.diamond.shape,
Polish: ev.detail.diamond.polish,
Cut: ev.detail.diamond.cut
}
}];
console.log(`productJSON = ${JSON.stringify(productJSON)}`);
var xhr = new XMLHttpRequest();
xhr.open(“POST”, ‘/cart/add.js’, true);
xhr.setRequestHeader(‘Content-Type’, ‘application/json’);
xhr.send(JSON.stringify({
items: productJSON}))
xhr.onload = function(res) {
jQuery(‘body’).trigger(‘added.ajaxProduct’);
};
})

}).fail(function(err){
if(err.status == 404) {
$(“#overlay”).fadeIn(300); 
jQuery.post(‘https://[email protected]/createProduct’, ev.detail.diamond, function(data){
console.log(`data = ${JSON.stringify(data)}`);
var productJSON = [{
quantity: 1,
id: parseInt(data.id.replace(“gid://shopify/ProductVariant/”,””)),
properties: {
Colour: ev.detail.diamond.color.color,
Clarity: ev.detail.diamond.clarity,
Shape: ev.detail.diamond.shape,
Polish: ev.detail.diamond.polish,
Cut: ev.detail.diamond.cut
}
}];
console.log(`productJSON = ${JSON.stringify(productJSON)}`);
var xhr = new XMLHttpRequest();
xhr.open(“POST”, ‘/cart/add.js’, true);
xhr.setRequestHeader(‘Content-Type’, ‘application/json’);
xhr.send(JSON.stringify({
items: productJSON}))
xhr.onload = function(res) {
$(“#overlay”).fadeOut(300);
jQuery(‘body’).trigger(‘added.ajaxProduct’);
};
})
.fail(function(err){
console.log(`err = ${JSON.stringify(err)}`);
})
}
})
}
);

// window.document.addEventListener(‘ds.addtocart’, e => {
// console.error(‘!!!+++’);
// });
}
if (d.addEventListener) {
d.addEventListener(‘ds.ready’, function() {
// console.error(‘2222’);
observeAddToCart();
}, false);
} else if (d.attachEvent) {
d.documentElement.attachEvent(‘onpropertychange’, function(event) {
if (event.propertyName === ‘ds.ready’)
observeAddToCart();
});
}
}(document, window));

</script>

Understanding the Add to Cart code

This is an example of ‘Add to Cart’ code simplified.

  1. Create the product in the e-commerce platform inventory (ie. Shopify/Magento etc) by creating an event listener. This is the event listener code:
    window.addEventListener(

    ‘ds.addtocart’,

  2. Save the output to platform inventory: In our example, the developer uses

    1. product.id to get all the diamond details: ev.detail.diamond[`shopify_product_id`] = product.id;

    2. Jquery code shown above to get details of the stones. Here’s what it looks like once you’ve pulled the data which the developer stores before posting on the website:

      jQuery.post(‘https://your-website.net/createProduct‘, ev.detail.diamond, function(data){

      console.log(`data = ${JSON.stringify(data)}`);

      var productJSON = [{

      quantity: 1,

      id: product.variants[0].id,

      properties: {

      Colour: ev.detail.diamond.color.color,

      Clarity: ev.detail.diamond.clarity,

      Shape: ev.detail.diamond.shape,

      Polish: ev.detail.diamond.polish,

      Cut: ev.detail.diamond.cut

      }

      }]

       

  3. Add a trigger to the details above. This is the trigger:

    console.log(`productJSON = ${JSON.stringify(productJSON)}`);

    var xhr = new XMLHttpRequest();

    xhr.open(“POST”, ‘/cart/add.js’, true);

    xhr.setRequestHeader(‘Content-Type’, ‘application/json’);

    xhr.send(JSON.stringify({

    items: productJSON}))

    xhr.onload = function(res) {

    jQuery(‘body’).trigger(‘added.ajaxProduct’);

    };

    })

     

  4. If the trigger is false, it will give this error code 404:

    }).fail(function(err){

    if(err.status == 404) {

    $(“#overlay”).fadeIn(300); 

    jQuery.post(‘https://[email protected]/createProduct’, ev.detail.diamond, function(data){

    console.log(`data = ${JSON.stringify(data)}`);

    var productJSON = [{

    quantity: 1,

    id: parseInt(data.id.replace(“gid://shopify/ProductVariant/”,””)),

    properties: {

    Colour: ev.detail.diamond.color.color,

    Clarity: ev.detail.diamond.clarity,

    Shape: ev.detail.diamond.shape,

    Polish: ev.detail.diamond.polish,

    Cut: ev.detail.diamond.cut

    }

    }];

    console.log(`productJSON = ${JSON.stringify(productJSON)}`);

    var xhr = new XMLHttpRequest();

    xhr.open(“POST”, ‘/cart/add.js’, true);

    xhr.setRequestHeader(‘Content-Type’, ‘application/json’);

    xhr.send(JSON.stringify({

    items: productJSON}))

    xhr.onload = function(res) {

    $(“#overlay”).fadeOut(300);

    jQuery(‘body’).trigger(‘added.ajaxProduct’);

    };

    })

    .fail(function(err){

    console.log(`err = ${JSON.stringify(err)}`);

    })

    }

    })

    }

    );

     

  5. If the trigger is true:

    // window.document.addEventListener(‘ds.addtocart’, e => {

    // console.error(‘!!!+++’);

    // });

    }

    if (d.addEventListener) {

    d.addEventListener(‘ds.ready’, function() {

    // console.error(‘2222’);

    observeAddToCart();

    }, false);

    } else if (d.attachEvent) {

    d.documentElement.attachEvent(‘onpropertychange’, function(event) {

    if (event.propertyName === ‘ds.ready’)

    observeAddToCart();

    });

    }

    }(document, window));

<script>

$(function() {
// Current Ajax request.
var currentAjaxRequest = null;
// Grabbing all search forms on the page, and adding a .search-results list to each.
var searchForms = $(‘form[action=”/search”]’).css(‘position’,’relative’).each(function() {
// Grabbing text input.
var input = $(this).find(‘input[name=”q”]’);
// Adding a list for showing search results.
var offSet = input.position().top + input.innerHeight();
$(‘<ul class=”search-results”></ul>’).css( { ‘position’: ‘absolute’, ‘left’: ‘0px’, ‘top’: offSet } ).appendTo($(this)).hide();
// Listening to keyup and change on the text field within these search forms.
input.attr(‘autocomplete’, ‘off’).bind(‘keyup change’, function() {
// What’s the search term?
var term = $(this).val();
// What’s the search form?
var form = $(this).closest(‘form’);
// What’s the search URL?
var searchURL = ‘/search?type=product&q=’ + term;
// What’s the search results list?
var resultsList = form.find(‘.search-results’);
// If that’s a new term and it contains at least 3 characters.
if (term.length > 3 && term != $(this).attr(‘data-old-term’)) {
// Saving old query.
$(this).attr(‘data-old-term’, term);
// Killing any Ajax request that’s currently being processed.
if (currentAjaxRequest != null) currentAjaxRequest.abort();
// Pulling results.
currentAjaxRequest = $.getJSON(searchURL + ‘&view=json’, function(data) {
// Reset results.
resultsList.empty();
// If we have no results.
if(data.results_count == 0) {
// resultsList.html(‘<li><span class=”title”>No results.</span></li>’);
// resultsList.fadeIn(200);
resultsList.hide();
} else {
// If we have results.
$.each(data.results, function(index, item) {
var link = $(‘<a></a>’).attr(‘href’, item.url);
link.append(‘<span class=”thumbnail”><img src=”‘ + item.thumbnail + ‘” /></span>’);
link.append(‘<span class=”type”>’ + item.type + ‘</span>’);
link.append(‘<span class=”title”>’ + item.title + ‘</span>’);
link.append(‘<span class=”price”>’ + item.price + ‘</span>’);
link.wrap(‘<li></li>’);
resultsList.append(link.parent());
});
// The Ajax request will return at the most 10 results.
// If there are more than 10, let’s link to the search results page.
if(data.results_count > 10) {
resultsList.append(‘<li><span class=”title”><a href=”‘ + searchURL + ‘”>See all results (‘ + data.results_count + ‘)</a></span></li>’);
}
resultsList.fadeIn(200);
}
});
}
});
});
// Clicking outside makes the results disappear.
$(‘body’).bind(‘click’, function(){
$(‘.search-results’).hide();
});
});

</script>
=====================================================================================================================================================


Add to cart page
<script>window.ShopifyAnalytics = window.ShopifyAnalytics || {};
window.ShopifyAnalytics.meta = window.ShopifyAnalytics.meta || {};
window.ShopifyAnalytics.meta.currency = ‘ZAR’;
var meta = {“page”:{“path”:”\/checkout\/contact_information”,”search”:”?_ga=2.47235943.1103702442.1622464711-71421577.1622464711″,”url”:”https:\/\/www.example.co.za\/27854504025\/checkouts\/011b1397d62d50f0909238b3161243c4?_ga=2.47235943.1103702442.1622464711-71421577.1622464711″},”page_view_event_id”:”df19d90a76727b8257d918a80466619bb8c928cbe7e8a4ec88715120b0858e01″,”cart_event_id”:”16723cbaed35a8f9e87a08df047446ec758681d9a6c758b6f2746a5a86d6c7e0″};
for (var attr in meta) {
window.ShopifyAnalytics.meta[attr] = meta[attr];
}</script>

To import the Instant Inventory into your system, we recommend that you program your software to retrieve and import complete datasets 

 

Links & Help Articles

Accessibility