wojodesign / simplecart-js

A simple javascript shopping cart that easily integrates with your current website.
simplecartjs.org
1.79k stars 489 forks source link

Issue adding form data on beforeCheckout #458

Open HarveyEV opened 10 years ago

HarveyEV commented 10 years ago

I am using simplecart 3.0 and am attempting to add additional form data to the simpleCart object before checkout to include in my post event. I am creating an object (allData) by serializing the form data on submission and have validated the data is in the object before I call the following:

// get allData object and append each kv pair to cart before checkout executes
simpleCart.bind( 'beforeCheckout' , function( data ){
    $.each(allData, function(key, value) {
                  data.key = value;
            });
    });

However none of the data is getting passed to the post object. I also tried the simpleCart.extend method to extend the cart with allData and that did not work either. Any suggestions would be great. Thanks.

dceonline commented 10 years ago

First check if data-object is not empty using console.log(allData); before u loop.

regards Ortwin