Developer forum

Forum » CMS - Standard features » Add installation with product

Add installation with product

Sofia Soje
Reply

I've looked into AddMulti, but I can't get it to work with related products, as it is there the choices for installation with the product is.

Is it possible to have a function that let's you choose an installation through a dropdown at the product details page, and then add the product to cart, and therefore get both the related product for installation and the product whose page you're on in the cart?


Replies

 
Nicolai Pedersen
Reply

Hi Sofia

I do not understand the question. Can you show a screen dump?

Anyways - if you add any product into the same form and use addmulti you can add as many product and variant combination to the cart in one go as you want.

BR Nicolai

 
Sofia Soje
Reply

I've added a picture. (where you choose an installation which is radiobutton triggered)

Radiobutton for the related products aka. installation

<input type="radio" name="installID" value="@related.GetValue("Ecom:Product:Page.ID"), '@related.GetValue("Ecom:Product.ID")', '@related.GetValue("Ecom:Product.Number")'">

The buy button for the main product which we're currently on

<button id="btnBuy" onclick="addToBasket(@GetValue("Ecom:Product:Page.ID"), '@GetValue("Ecom:Product.ID")', '@GetValue("Ecom:Product.Number")', this);" class="btn btn-default" type="button"><i class="fa fa-shopping-cart"></i> KÖP</button>

 Add to cart function

function addToBasket(pageId, itemId, produktNumber, domElem) {
    $("#buyAlert").modal()

    //debugger;
    var tempHtml = $(domElem).html();
    var workingElement = $(domElem);

    workingElement.find('i').removeClass('fa-shopping-cart');
    workingElement.html(workingElement.html().replace('Köp', ''));
    workingElement.attr('disabled', true);

    //Send product info to notification and show notification.
    //Close is called from the success callback of updateCart(); 
    var clickedButton = workingElement;
    //buyBtnNotification(clickedButton);

    $(document).ajaxComplete(function () {
        setTimeout(function () {
          workingElement.html(tempHtml);
        }, 10000);

        workingElement.removeAttr('disabled');
        workingElement.blur();

        // show response from the script.
        $(workingElement)
            .removeAttr('disabled')
    });

    // Update the cart 
    updateCart('/default.aspx?id=' + pageId + '&amp;productid=' + itemId + '&amp;quantity=' + $('#antal_' + produktNumber).val() + '&amp;cartcmd=add', undefined, true, domElem, true);
}

 

I guess I can't just take the chosen related products value and add it to the onclick function for the buy button?

onclick="addToBasket(@GetValue("Ecom:Product:Page.ID"), '@GetValue("Ecom:Product.ID")', '@GetValue("Ecom:Product.Number")', this); addToBasket(@related.GetValue("Ecom:Product:Page.ID"), '@related.GetValue("Ecom:Product.ID")', '@related.GetValue("Ecom:Product.Number"), this)"
issue01.jpg
 
Sofia Soje
Reply

A great example is this site: https://varmepumpshopen.se/produkt/mitsubishi-msz-ln25wg/

Choose an installation, add the product to cart, and you get both the installation and product added at the same time.

 
Nicolai Pedersen
Reply
This post has been marked as an answer

There are different ways of doing it. Adding an extra add to basked action is an option.

Based on your screen using Parts Lists or variants would also have been an option.

Votes for this answer: 1

 

You must be logged in to post in the forum