Search code examples
javascriptsimplecartjotform

Can simplecart be integrated with jotform?


I am using Github pages for my website, and it does not allow PHP.

But since I am doing an e-commerce website, I need a shopping cart - with buttons "add item to cart" and "checkout".

The idea is, upon checkout, the user will have to fill out the name, address, email, and contact number. And his/her orders in the shopping cart will be the default message body.

Can I integrate simplecart.js to Jotform? (the orders will be sent as parameter for message body in Jotform)


Solution

  • simplecart-js are my favorite cart script, been using that on every website i made that need an checkout function.

    it has good documentation for your need, to get the simplecart item, you can use simplecart.each function.

    maybe like this:

    var cart = '', total = 0;
    simpleCart.each(function(item, i){
       var subtotal = item.get('price') * item.get('quantity');
       cart += i + '. ' + item.get('fullname') + ' >> $' + item.get('price') + ' x ' + item.get('quantity') + ' = $' + subtotal + '\n';
       total += subtotal;
    });
    cart += '\n\nTotal = $' + total;
    $('#messagebody').val(cart);
    

    the output on content body will be something like this:

    1. product 1 >> $100 x 2 = $200
    2. product 2 >> $75 x 3 = $225
    
    Total = $425