03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

E-Commerce 265<br />

1 app.controller("products", function(<br />

2 $scope,<br />

3 CategoryService,<br />

4 ProductService,<br />

5 BasketService<br />

6 ) {<br />

7<br />

8 // ...<br />

9<br />

10 this.addToBasket = function(product) {<br />

11 BasketService.add(product);<br />

12 };<br />

13<br />

14 // ...<br />

15<br />

16 });<br />

.<br />

This was extracted from public/js/shared.js.<br />

1 <br />

6 Add to basket<br />

7 <br />

.<br />

This was extracted from app/views/index.blade.php.<br />

Try it out in your browser. You should be able to add items into the basket, change their quantities<br />

and remove them. When you refresh, all should display correctly.<br />

Completing Orders<br />

To complete orders; we need to send the order item data to the server, and process a payment. We<br />

need to pass this endpoint an account ID (to link the orders to an account) which means we also<br />

need to add authentication…

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!