minicart icon indicating copy to clipboard operation
minicart copied to clipboard

checkout with multiple items to paypal api

Open liadlevy opened this issue 4 years ago • 0 comments

How can I checkout with multiple items in cart? I've noticed that paypal api using _x doesn't work, but if you do multiple form post data it will. I thought of doing a JS for loop and everytime post it to paypal but it did not work. any ideas? using JS and HTML5

snippet of my code I tried:

<!-- TEST -->
<form id='test' action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="submit" name="submit" value="Add to cart"/>

</form>

<!-- // TEST -->
<script>
      var wrapper = document.getElementById("test");
       var myHTML = '';

		shoe.render();
		shoe.cart.on('shoe_checkout', function (evt) {
			var items, len, i;

			if (this.subtotal() > 0) {
				items = this.items();
				alert(Object.keys(items[0]))
				for (i = 0, len = items.length; i < len; i++) {
				     myHTML = `<input type="hidden" name="cmd" value="_cart"/>
                    <input type="hidden" name="add" value="1"/>
                    <input type="hidden" name="business" value="[email protected]"/>
                    <input type="hidden" name="item_name" value=` + items[i]._data.shoe_item +`/>
                    <input type="hidden" name="quantity" value=` + items[i]._data.quantity +`/>
                    <input type="hidden" name="amount" value=` + items[i]._data.amount +`/>
                    <input type="hidden" name="currency_code" value="USD"/>
                    <input type="hidden" name="shipping" value="1.00">`;

                alert(myHTML)
                wrapper.innerHTML = myHTML


				}

			}
		});



</script>

liadlevy avatar Aug 08 '20 21:08 liadlevy