Skip to content

Commit

Permalink
Clean up of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffharrell committed Jul 25, 2014
1 parent 8d71b65 commit a722c64
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
40 changes: 40 additions & 0 deletions examples/checkout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="example@minicartjs.com" />
<input type="hidden" name="item_name" value="Test Product" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="amount" value="1.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="shipping" value="1.00">
<strong>Test Product</strong>
<input type="submit" name="submit" value="Add to cart" />
</form>


<script src="../dist/minicart.js"></script>
<script>
paypal.minicart.render();

paypal.minicart.cart.on('checkout', function (evt) {
var items, len, i;

if (this.subtotal() > 0) {
items = this.items();

for (i = 0, len = items.length; i < len; i++) {
items[i].set('shipping', 0);
items[i].set('shipping2', 0);
}
}
});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/fixedquantity.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<fieldset>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="labs-feedback-minicart@paypal.com" />
<input type="hidden" name="business" value="example@minicartjs.com" />
<input type="hidden" name="item_name" value="Test Product" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="amount" value="1.00" />
Expand Down
2 changes: 1 addition & 1 deletion examples/minquantity.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<fieldset>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="labs-feedback-minicart@paypal.com" />
<input type="hidden" name="business" value="example@minicartjs.com" />
<input type="hidden" name="item_name" value="Test Product" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="amount" value="1.00" />
Expand Down
4 changes: 2 additions & 2 deletions examples/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="labs-feedback-minicart@paypal.com" />
<input type="hidden" name="business" value="example@minicartjs.com" />
<input type="hidden" name="item_name" value="Test Product" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="amount" value="1.00" />
Expand Down Expand Up @@ -36,7 +36,7 @@

if (!hasAgreed) {
alert('You must agree to the terms!');
evt.preventDefault();
evt.preventDefault();
}
});
</script>
Expand Down
10 changes: 10 additions & 0 deletions test/unit/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,14 @@ describe('Cart Model', function () {

cart.destroy();
});


it('checkout() fires an event', function (done) {
cart.on('checkout', function () {
assert(true);
done();
});

cart.checkout();
});
});

0 comments on commit a722c64

Please sign in to comment.