Setting Shipping Information

You call the setShipping() function, shown in Listing 28.26, when the user clicks the Continue to Billing button in the cart view. The shipping information needs to be updated in the database to ensure that it is persistent when the customer leaves the website. You call an $http POST method to the /customers/update/shipping route. The POST includes the parameter {updatedShipping:$scope.customer.shipping[0]} in the body. If the request is successful, the view switches to billing.html; otherwise, an alert appears.

Listing 28.26 cart_app.js-setShipping: Implementing the shipping function in the controller


094     $scope.setShipping = function(){
095       $http.post('/customers/update/shipping',
096           { updatedShipping: $scope.customer.shipping[0] })
097         .success(function(data, status, headers, config) {
098           $scope.content = '/static/billing.html';
099         })
100         .error(function(data, status, headers, config) {
101           $window.alert(data);
102         });
103     };


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.100.89