Recommendations > add to cart link — Nosto Community

Recommendations > add to cart link

DistriartisanDistriartisan Posts: 31Member
Hi

Would it be possible to get an 'add-to-cart' link directly on our recommendations ?

Best

Comments

  • DanDan Posts: 65Walking Wisdom admin
    Hey hey!!

    Nosto doesn’t feature add-to-cart button in the recommendations out-of-the-box, yet there is a work-around for the functionality.

    There is an article in the Nosto Help Center, which describes how to achieve this. Please take a look below:

    https://help.nosto.com/recommendations/faq/create-add-to-cart-button-to-your-recommendation-templates

    Just drop a line here to let us know if it worked:)

    Cheers!


  • JacopoJacopo Posts: 41Walking Wisdom, Coding Expert admin
    edited April 5
    Hey @Distriartisan

    I know you enjoy to speak tech so I complete Dan's answer with some code.
    You are on Magento, and we do support the add to cart functionality, an example of a working button could be

    <a href="#" onclick="Nosto.addProductToCart('$!product.productId', this);">AJOUTER AU PANIER</a>

    Try that out and if it raises some problems do let us know, but I am sure it's gonna work!  B)
  • DistriartisanDistriartisan Posts: 31Member
    HI

    @Jacopo

    I've tried this code
    <a href="#" onclick="Nosto.addProductToCart('$!product.productId', this);">AJOUTER AU PANIER</a>

    Unfortunately, I get different results depending on the product
    • redirection to the cart and product is added
    • redirection to the cart and the product is not added
    • redirection to the product page
    on clicking add-to-cart link, we should have
    • if this is a configurable product : redirection to the product page
    • if this is a simple product : add product to the cart and display the pop-in (product added to your cart)
    We have this type of link

    Thanks a lot

    Best




  • JacopoJacopo Posts: 41Walking Wisdom, Coding Expert admin
    Hello @Distriartisan
    this may happen cause products in your shop present variations/SKUs - meaning that, if a product has variations (color, size, etc.) you will have to act differently, and can find instructions and use cases here https://github.com/Nosto/nosto-magento/wiki/Add-to-Cart

    The problem with the ajaxAddToCartLink example that you posted cannot be used as-is because Magento adds some randomly generated tokens in the link (that "craziness" of letters and numbers) which we cannot replicate.

    Try that out and let us know :) 
Sign In or Register to comment.

Read our Terms&Conditions before commenting and posting