Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
https://example.com/cart?vendorCode[]=wallpaper_1&quantity[]=2&vendorCode[]=wallpaper_2&quantity[]=1

On your side you need to handle the user clicking on such a link. You need to put items by SKU (vendorCode) in the shopping cart with the appropriate quantity.

Example:

Code Block
languagejs
<script>
  window.addEventListener("load", function(event) {
    // get parameters from url
    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    
    // get values from query-string
    const sku = urlParams.getAll('vendorCode[]');
    const quantity = urlParams.getAll('quantity[]');
    
    // print the result
    console.log(sku); // ['wallpaper_1', 'wallpaper_2'];
    console.log(quantity); // ['2', '1'];
    
    // Next you need to put the sku and quantity
    // into the shopping cart on your website.
  });
</script>