Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkout with multiple items to paypal api #316

Open
liadlevy opened this issue Aug 8, 2020 · 0 comments
Open

checkout with multiple items to paypal api #316

liadlevy opened this issue Aug 8, 2020 · 0 comments

Comments

@liadlevy
Copy link

liadlevy commented Aug 8, 2020

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant