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