Prestashop
  • Personalization for PrestaShop
  • Installing
  • Configuring
  • Guides
    • Fixing Broken Tagging
    • Adding & Moving Recommendations
    • Overriding or Extending Functionalities
      • Overriding Product Data
      • Overriding Customer Data
    • Bulk Product Updates via Cron
  • Features
    • Variations (Configurable Products)
    • Add to Cart
    • Supplier Cost & Inventory Level
    • Restore Cart Link
    • Ratings & Reviews
    • Multi Currency (Exchange Rates)
    • Marketing permission and GDPR compatibility
  • FAQ
  • Developing & Contributing
  • Visit Nosto
  • Issues
  • Releases
Powered by GitBook
On this page
  • Leveraging Quantities
  • Adding Multiple Products
  • Use Cases

Was this helpful?

  1. Features

Add to Cart

PreviousVariations (Configurable Products)NextSupplier Cost & Inventory Level

Last updated 2 years ago

Was this helpful?

It is possible to add variations (SKUs) directly to cart from recommendations.

3.0.0

Note: The function definition is a part of the extension and is automatically added to all pages. You do not need to define the function or include any additional scripts.

In order to do this, you must pass the product id of the actual variation Nosto.addSkuToCart method.

The first argument is the id of variation, and the second one being the element where the product was added to the cart. If configurable product's id is 123 and the id of the variation is 124 the method call in recommendations template would look like this

Nosto.addProductToCart('124', this);

Leveraging Quantities

As of version 3.0.0 you can also pass the quantity as a parameter.

Nosto.addSkuToCart({productId: '425', skuId: '310'}, this, 5)

Adding Multiple Products

Use Cases

A common way to implement the functionality to add a variation directly to cart is to implement drop down of available variations for recommended products. The selected variation id is then picked up from the drop down and passed to the Nosto.addSkuToCart method. An example implementation can be found below.

#if($product.skus.size() > 0)
  <div class="nosto-sku-select-wrapper">
    <label class="nosto-sku-select">
      <select onChange="document.getElementById('selected_sku').value = this.value">
        <option value="">Choose</option>
          #foreach($sku in $product.skus)
            <option value="$!sku.id">
              #foreach($attr in $sku.customFields)
                $!attr.key: $!attr.value
              #end
            </option>
          #end
      </select>
    </label>
  </div>
  <button onclick="Nosto.addSkuToCart({productId: '$!product.productId', skuId: document.getElementById('selected_sku').value}, this);return false;" class="nosto-btn">
    <img src="$!props.display.buyButtonIcon.url" width="15" height="15">
  </button>
#end
3.0.0

It is not possible to add multiple products to the cart at once. Please see issue

https://github.com/Nosto/nosto-prestashop/issues/263