Merge branch 'master' into arjunlatest
Showing
... | @@ -30,67 +30,77 @@ let CartsService = class CartsService { | ... | @@ -30,67 +30,77 @@ let CartsService = class CartsService { |
.doc(this.prodId); | .doc(this.prodId); | ||
this.size = this.size === undefined ? product.size[0] : this.size; | this.size = this.size === undefined ? product.size[0] : this.size; | ||
this.color = this.color === undefined ? product.color[0] : this.color; | this.color = this.color === undefined ? product.color[0] : this.color; | ||
const cartRef = this.afs.collection('carts', ref => ref | this.service.get('cartCenter').then((centerData) => { | ||
.where('size', '==', this.size) | console.log(centerData); | ||
.where('color', '==', this.color) | if (centerData === null || (centerData === product.centerId)) { | ||
.where('custId', '==', this.custId) | this.service.set('cartCenter', product.centerId).then(() => { | ||
.where('product', '==', prodRef)); | const cartRef = this.afs.collection('carts', ref => ref | ||
cartRef | .where('size', '==', this.size) | ||
.valueChanges() | .where('color', '==', this.color) | ||
.pipe(take(1)) | .where('custId', '==', this.custId) | ||
.subscribe(value => { | .where('product', '==', prodRef)); | ||
// console.log(value); | cartRef | ||
if (value.length === 0) { | .valueChanges() | ||
product.image = | .pipe(take(1)) | ||
product.image === undefined | .subscribe(value => { | ||
? '../assets/[email protected]' | // console.log(value); | ||
: product.image; | if (value.length === 0) { | ||
const cart = { | product.image = | ||
color: this.color, | product.image === undefined | ||
custId: this.custId, | ? '../assets/[email protected]' | ||
shopperId: product.shopperId, | : product.image; | ||
product: firebase.firestore().doc(`products/${this.prodId}`), | const cart = { | ||
image: product.image, | color: this.color, | ||
prodId: product.prodId, | custId: this.custId, | ||
price: product.price, | shopperId: product.shopperId, | ||
prodName: product.prodName, | product: firebase.firestore().doc(`products/${this.prodId}`), | ||
shopper: product.shopper, | image: product.image, | ||
qty: 1, | prodId: product.prodId, | ||
size: this.size | price: product.price, | ||
}; | prodName: product.prodName, | ||
// console.log(cart); | shopper: product.shopper, | ||
this.afs | qty: 1, | ||
.collection('carts') | size: this.size | ||
.add(cart) | }; | ||
.then(docRef => { | // console.log(cart); | ||
const neworderId = docRef.id; | this.afs | ||
this.afs | .collection('carts') | ||
.collection('carts') | .add(cart) | ||
.doc(neworderId) | .then(docRef => { | ||
.update({ cartId: docRef.id }) | const neworderId = docRef.id; | ||
.then(() => { | this.afs | ||
// console.log('Booking Successfully'); | .collection('carts') | ||
document.body.scrollTop = document.documentElement.scrollTop = 0; | .doc(neworderId) | ||
.update({ cartId: docRef.id }) | |||
.then(() => { | |||
// console.log('Booking Successfully'); | |||
document.body.scrollTop = document.documentElement.scrollTop = 0; | |||
}); | |||
}) | |||
.catch(error => { | |||
console.error('Error adding document: ', error); | |||
}); | |||
} | |||
else { | |||
// console.log(value); | |||
// alert('Item already added in the cart'); | |||
const cartId = value[0].cartId; | |||
// tslint:disable-next-line:radix | |||
const qty = parseInt(value[0].qty) + 1; | |||
this.afs | |||
.collection('carts') | |||
.doc(cartId) | |||
.update({ qty: `${qty}` }) | |||
.then(() => { | |||
// console.log('Booking Successfully'); | |||
document.body.scrollTop = document.documentElement.scrollTop = 0; | |||
}); | |||
} | |||
}); | }); | ||
}) | |||
.catch(error => { | |||
console.error('Error adding document: ', error); | |||
}); | }); | ||
} | } | ||
else { | else { | ||
// console.log(value); | this.service.showToast('Your cart is not empty', 'top', 'my-error', 2000); | ||
// alert('Item already added in the cart'); | |||
const cartId = value[0].cartId; | |||
// tslint:disable-next-line:radix | |||
const qty = parseInt(value[0].qty) + 1; | |||
this.afs | |||
.collection('carts') | |||
.doc(cartId) | |||
.update({ qty: `${qty}` }) | |||
.then(() => { | |||
// console.log('Booking Successfully'); | |||
document.body.scrollTop = document.documentElement.scrollTop = 0; | |||
}); | |||
} | } | ||
}); | }); | ||
}); | }); | ||
... | @@ -134,6 +144,7 @@ let CartsService = class CartsService { | ... | @@ -134,6 +144,7 @@ let CartsService = class CartsService { |
}); | }); | ||
} | } | ||
else { | else { | ||
this.service.remove('cartCenter'); | |||
// alert('No Products Found'); | // alert('No Products Found'); | ||
} | } | ||
}); | }); | ||
... | ... |
... | @@ -41,7 +41,7 @@ | ... | @@ -41,7 +41,7 @@ |
<div class="cart_detail"> | <div class="cart_detail"> | ||
<h4>{{unEscape(carts.prodName)}}</h4> | <h4>{{unEscape(carts.prodName)}}</h4> | ||
<h4>{{carts.size}}, {{carts.color}}</h4> | <h4>{{carts.size}}, {{carts.color}}</h4> | ||
<h5>A$ {{carts.price}}</h5> | <h5>A$ {{service.formatNumber(carts.price)}}</h5> | ||
</div> | </div> | ||
<div class="cart_count"> | <div class="cart_count"> | ||
<div class="add" (click)="cartService.addCount(i)">+</div> | <div class="add" (click)="cartService.addCount(i)">+</div> | ||
... | @@ -59,7 +59,8 @@ | ... | @@ -59,7 +59,8 @@ |
<p class="textLeft">Total Price:</p> | <p class="textLeft">Total Price:</p> | ||
</ion-col> | </ion-col> | ||
<ion-col> | <ion-col> | ||
<p class="textRight">A$ {{cartService.cartTotal.toFixed(2)}}</p> | <p class="textRight">A$ | ||
{{service.formatNumber(cartService.cartTotal.toFixed(2))}}</p> | |||
</ion-col> | </ion-col> | ||
</ion-row> | </ion-row> | ||
</div> | </div> | ||
... | @@ -75,7 +76,7 @@ | ... | @@ -75,7 +76,7 @@ |
<h5> | <h5> | ||
<span class="floatLeft">ITEMS</span> | <span class="floatLeft">ITEMS</span> | ||
<span class="floatRight" *ngIf="cartService.cartTotal">A$ | <span class="floatRight" *ngIf="cartService.cartTotal">A$ | ||
{{cartService.cartTotal}}</span> | {{service.formatNumber(cartService.cartTotal.toFixed(2))}}</span> | ||
<div class="clear"></div> | <div class="clear"></div> | ||
</h5> | </h5> | ||
<ion-grid class="p0" *ngIf="cartService.carts && cartService.carts.length > 0"> | <ion-grid class="p0" *ngIf="cartService.carts && cartService.carts.length > 0"> | ||
... | @@ -88,7 +89,7 @@ | ... | @@ -88,7 +89,7 @@ |
</ion-col> | </ion-col> | ||
<ion-col size="4" class="p0"> | <ion-col size="4" class="p0"> | ||
<h6 class="textRight"> | <h6 class="textRight"> | ||
<strong>A$ {{carts.price}}</strong> | <strong>A$ {{service.formatNumber(carts.price)}}</strong> | ||
</h6> | </h6> | ||
</ion-col> | </ion-col> | ||
</ion-row> | </ion-row> | ||
... | @@ -99,12 +100,13 @@ | ... | @@ -99,12 +100,13 @@ |
<span class="floatRight" (click)="istoggle()">EDIT</span> | <span class="floatRight" (click)="istoggle()">EDIT</span> | ||
<div class="clear"></div> | <div class="clear"></div> | ||
</h5> | </h5> | ||
<ion-grid class="p0" *ngIf="custAddress"> | <ion-grid class="p0" *ngIf="addressService.custAddress"> | ||
<ion-row> | <ion-row> | ||
<ion-col class="p0"> | <ion-col class="p0"> | ||
<h6> | <h6> | ||
{{custAddress.building}},<br /> {{custAddress.landmark}}, | {{addressService.custAddress.building}},<br /> | ||
<br /> {{custAddress.address}} | {{addressService.custAddress.landmark}}, | ||
<br /> {{addressService.custAddress.address}} | |||
</h6> | </h6> | ||
</ion-col> | </ion-col> | ||
</ion-row> | </ion-row> | ||
... | @@ -115,16 +117,16 @@ | ... | @@ -115,16 +117,16 @@ |
<!-- <span class="floatRight">CHANGE</span> --> | <!-- <span class="floatRight">CHANGE</span> --> | ||
<div class="clear"></div> | <div class="clear"></div> | ||
</h5> | </h5> | ||
<div class="payment_method"> | <!-- <div class="payment_method"> | ||
<input type="radio" name="payments" id="cod" name="radio-group" checked="true" | <input type="radio" name="payments" id="cod" name="radio-group" checked="true" | ||
(click)="getwaycod()" /> | (click)="getwaycod()" /> | ||
<label for="cod"> | <label for="cod"> | ||
<p>COD</p> | <p>COD</p> | ||
</label> | </label> | ||
</div> | </div> --> | ||
<div class="payment_method"> | <div class="payment_method"> | ||
<input type="radio" name="payments" id="paypal" name="radio-group" | <input type="radio" name="payments" id="paypal" name="radio-group" | ||
(click)="getwaypaypal()" /> | (click)="getwaypaypal()" checked="true" /> | ||
<label for="paypal"> | <label for="paypal"> | ||
<p>PayPal</p> | <p>PayPal</p> | ||
</label> | </label> | ||
... | @@ -185,25 +187,25 @@ | ... | @@ -185,25 +187,25 @@ |
<h6> | <h6> | ||
<span class="floatLeft">PRODUCT COST</span> | <span class="floatLeft">PRODUCT COST</span> | ||
<span class="floatRight" *ngIf="cartService.cartTotal">A$ | <span class="floatRight" *ngIf="cartService.cartTotal">A$ | ||
{{cartService.cartTotal.toFixed(2)}}</span> | {{service.formatNumber(cartService.cartTotal.toFixed(2))}}</span> | ||
<div class="clear"></div> | <div class="clear"></div> | ||
</h6> | </h6> | ||
<h6> | <h6> | ||
<span class="floatLeft">DELIVERY CHARGE</span> | <span class="floatLeft">DELIVERY CHARGE</span> | ||
<span class="floatRight" *ngIf="cartService.cartTotal">A$ | <span class="floatRight" *ngIf="cartService.cartTotal">A$ | ||
{{getDeliveryCharge(cartService.cartTotal)}}</span> | {{service.formatNumber(getDeliveryCharge(cartService.cartTotal))}}</span> | ||
<div class="clear"></div> | <div class="clear"></div> | ||
</h6> | </h6> | ||
<h6> | <h6> | ||
<span class="floatLeft">GST/TAX</span> | <span class="floatLeft">GST/TAX</span> | ||
<span class="floatRight" *ngIf="cartService.cartTotal">A$ | <span class="floatRight" *ngIf="cartService.cartTotal">A$ | ||
{{getTax(cartService.cartTotal)}}</span> | {{service.formatNumber(getTax(cartService.cartTotal))}}</span> | ||
<div class="clear"></div> | <div class="clear"></div> | ||
</h6> | </h6> | ||
<h6 *ngIf="discountApplied"> | <h6 *ngIf="discountApplied"> | ||
<span class="floatLeft">DISCOUNT</span> | <span class="floatLeft">DISCOUNT</span> | ||
<span class="floatRight">(-) A$ {{discount}}</span> | <span class="floatRight">(-) A$ {{service.formatNumber(discount)}}</span> | ||
<div class="clear"></div> | <div class="clear"></div> | ||
</h6> | </h6> | ||
<hr /> | <hr /> | ||
... | @@ -214,7 +216,7 @@ | ... | @@ -214,7 +216,7 @@ |
</ion-col> | </ion-col> | ||
<ion-col> | <ion-col> | ||
<p class="textRight" *ngIf="cartService.cartTotal"> | <p class="textRight" *ngIf="cartService.cartTotal"> | ||
A$ {{getTotal(cartService.cartTotal)}} | A$ {{service.formatNumber(getTotal(cartService.cartTotal))}} | ||
</p> | </p> | ||
</ion-col> | </ion-col> | ||
</ion-row> | </ion-row> | ||
... | @@ -226,8 +228,8 @@ | ... | @@ -226,8 +228,8 @@ |
<img src="../assets/[email protected]" /> | <img src="../assets/[email protected]" /> | ||
<h4>Order Placed</h4> | <h4>Order Placed</h4> | ||
<p>{{bookDate}}</p> | <p>{{bookDate}}</p> | ||
<h3>The product will be delivered in</h3> | <h3>Your order is due for delivery in</h3> | ||
<h1>{{deliveryTime}} Mins</h1> | <h1>{{deliveryTime}}</h1> | ||
<button class="view_order" (click)="goToPage('myorder')"> | <button class="view_order" (click)="goToPage('myorder')"> | ||
VIEW ORDERS</button><br /> | VIEW ORDERS</button><br /> | ||
<button class="home_btn" (click)="goToPage('home')">HOME</button> | <button class="home_btn" (click)="goToPage('home')">HOME</button> | ||
... | @@ -240,7 +242,7 @@ | ... | @@ -240,7 +242,7 @@ |
</ion-content> | </ion-content> | ||
<ion-footer> | <ion-footer> | ||
<div class="footer_btnbay" *ngIf="cartService.carts && cartService.carts.length > 0" [hidden]="currentIndex != 0"> | <div class="footer_btnbay" *ngIf="cartService.carts && cartService.carts.length > 0" [hidden]="currentIndex != 0"> | ||
<div class="continue" (click)="goToPage('home')"> | <div class="continue" (click)="goToPage('productlist')"> | ||
CONTINUE SHOPPING | CONTINUE SHOPPING | ||
</div> | </div> | ||
<div class="checkout" (click)="next(1)">CHECKOUT</div> | <div class="checkout" (click)="next(1)">CHECKOUT</div> | ||
... | @@ -262,7 +264,7 @@ | ... | @@ -262,7 +264,7 @@ |
<div *ngIf="isShow" [@slideInOut]> | <div *ngIf="isShow" [@slideInOut]> | ||
<div class="nav_header"> | <div class="nav_header"> | ||
<button class="nav_btn nav_back floatLeft" (click)="istoggle(); setAddress()"> | <button class="nav_btn nav_back floatLeft" (click)="istoggle();"> | ||
<img src="../assets/Group17_2.png" /> | <img src="../assets/Group17_2.png" /> | ||
</button> | </button> | ||
<div class="nav_title floatLeft"> | <div class="nav_title floatLeft"> | ||
... | ... |
Please
register
or
sign in
to comment