TypeError: Cannot read property 'id' of undefined


#1

hi
when i click on “PLACE ORDER” Instead of doing submit my order in WooCommerce show me this error
how can i fix it ?!

.controller('CheckoutPaymentCtrl', function($scope, $state, $ionicHistory, $ionicPopup, $rootScope, OrderService, UserService, CartService, appConfig, $injector) {
	$scope.orderInfo = {};
	$scope.orderInfo.payment = '';
	$scope.orderInfo.shipping = '';
	$scope.orderInfo.server_cart_id = '';
	$scope.cartInfo = CartService.getCartInfo();
	$scope.cartSubTotal = CartService.getCartTotal();
	$scope.cartTotal = 0;
	$scope.listPayment = [];
	$scope.listShipping = [];
	$scope.userInfo = UserService.getUser();
	$scope.orderInfo.coupon = "";
	$scope.orderShipping = JSON.parse(OrderService.getOrderInfo().shipping);
	$scope.shippingCost = 0;
	$scope.discountCost = 0;
	OrderService.createServeCart($scope.orderInfo.coupon, $scope.cartInfo.products, $scope.orderShipping.country, $scope.orderShipping.state, $scope.orderShipping.postcode).then(function(result) {
		$scope.listShipping = result.shipping_methods;
		var firstshipping = '';
		for(firstshipping in $scope.listShipping) break;
		$scope.orderInfo.shipping = $scope.listShipping[firstshipping].id;
		if($scope.listShipping[firstshipping].cost !== undefined) {
			$scope.shippingCost = $scope.listShipping[firstshipping].cost;
		}
		$scope.cartTotal = parseFloat($scope.shippingCost) + OrderService.getOrderGrandTotal();
		var firstPayment = '';
		for(firstPayment in result.payment_methods) break;
		$scope.orderInfo.payment = firstPayment;
		$scope.listPayment = result.payment_methods;
		$scope.orderInfo.server_cart_id = result.server_cart_id;
	});
	$scope.changeShippingMethod = function() {
		angular.forEach($scope.listShipping, function(shipping, key) {
			if (shipping.id === $scope.orderInfo.shipping) {
				if(shipping.cost !== undefined && shipping.cost !== "0" && shipping.cost !== "") {
					$scope.shippingCost = shipping.cost;
					$scope.cartTotal = parseFloat($scope.shippingCost) + OrderService.getOrderGrandTotal();
				}
				else {
					$scope.shippingCost = 0;
					$scope.cartTotal = OrderService.getOrderGrandTotal();
				}
				
			}
		});
	},