【问题标题】:Can simplecart be integrated with jotform?simplecart 可以与 jotform 集成吗?
【发布时间】:2017-02-21 08:37:25
【问题描述】:

我在我的网站上使用 Github 页面,它不允许 PHP。

但由于我正在做一个电子商务网站,我需要一个购物车 - 带有“将商品添加到购物车”和“结帐”按钮。

这个想法是,在结帐时,用户必须填写姓名、地址、电子邮件和联系电话。并且他/她在购物车中的订单将是默认的消息正文。

我可以将 simplecart.js 集成到 Jotform 吗? (订单将作为 Jotform 消息正文的参数发送)

【问题讨论】:

    标签: javascript simplecart jotform


    【解决方案1】:

    simplecart-js 是我最喜欢的购物车脚本,在我创建的每个需要结帐功能的网站上都使用它。

    它有很好的documentation 根据您的需要,要获取 simplecart 项目,您可以使用 simplecart.each 函数。

    可能是这样的:

    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);
    

    内容正文的输出将是这样的:

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

    【讨论】: