latest changes
Showing
| ... | ... | @@ -14,14 +14,24 @@ |
| <div class="product_banner"> | ||
| <div [ngClass]="checkFavStatus(product.prodId)" (click)="changeFav(product.prodId)"></div> | ||
| <div class="featured_badge" *ngIf="product.featured">Featured</div> | ||
| <ion-slides pager="true" [options]="bannerOptions"> | ||
| <ion-slide> | ||
| <img [src]="product.image" onerror="this.src='../assets/[email protected]'"> | ||
| </ion-slide> | ||
| <ion-slide> | ||
| <img [src]="product.image" onerror="this.src='../assets/[email protected]'"> | ||
| </ion-slide> | ||
| <ion-slide> | ||
| <img [src]="product.image" onerror="this.src='../assets/[email protected]'"> | ||
| </ion-slide> | ||
| </ion-slides> | ||
| </div> | ||
| <div class="product_header"> | ||
| <ion-row> | ||
| <ion-col size="8"> | ||
| <h3>{{product.prodName}}</h3> | ||
| <p><strong><span><img src="../assets/Path61_2.png"></span>0</strong> {{product.category}}, {{product.subCate}} | ||
| <br/> | ||
| <br /> | ||
| <span *ngFor="let tag of product.tag">#{{tag}} </span> | ||
| </p> | ||
| </ion-col> | ||
| ... | ... | @@ -41,7 +51,8 @@ |
| <li> | ||
| <button id="custom_check_button"> | ||
| <label> | ||
| <input id="{{color}}" type="radio" name="color" value="{{color}}" (click)="cartService.choose_color(color)" [checked]="i==0"> | ||
| <input id="{{color}}" type="radio" name="color" value="{{color}}" | ||
| (click)="cartService.choose_color(color)" [checked]="i==0"> | ||
| <p>{{color}}</p> | ||
| </label> | ||
| </button> | ||
| ... | ... | @@ -58,7 +69,8 @@ |
| <li> | ||
| <button id="custom_check_button"> | ||
| <label> | ||
| <input id="{{size}}" type="radio" name="services" value="{{size}}" (click)="cartService.choose_size(size)" [checked]="i==0"> | ||
| <input id="{{size}}" type="radio" name="services" value="{{size}}" | ||
| (click)="cartService.choose_size(size)" [checked]="i==0"> | ||
| <p>{{size}}</p> | ||
| </label> | ||
| </button> | ||
| ... | ... | @@ -202,7 +214,8 @@ |
| <li (click)="viewProd(similar)"> | ||
| <div class="product_image"> | ||
| <img [src]="similar.image" onerror="this.src='../assets/[email protected]'"> | ||
| <div [ngClass]="checkFavStatus(similar.prodId)" (click)="changeFav(similar.prodId)"></div> | ||
| <div [ngClass]="checkFavStatus(similar.prodId)" (click)="changeFav(similar.prodId)"> | ||
| </div> | ||
| </div> | ||
| <h5>{{similar.prodName}}</h5> | ||
| <p>{{similar.price}}</p> | ||
| ... | ... |
| ... | ... | @@ -29,7 +29,7 @@ export class CartsService { |
| ) { | ||
| this.custId = ''; | ||
| this.carts = []; | ||
| const users = this.service.get('user').then((data) => { | ||
| const users = this.service.get('user').then(data => { | ||
| if (data) { | ||
| data = JSON.parse(data); | ||
| this.custId = data.uid; | ||
| ... | ... | @@ -40,20 +40,33 @@ export class CartsService { |
| public async buyNow(product: Products) { | ||
| this.prodId = product.prodId; | ||
| const prodRef = firebase.firestore().collection('products').doc(this.prodId); | ||
| const prodRef = firebase | ||
| .firestore() | ||
| .collection('products') | ||
| .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: AngularFirestoreCollection<any> = this.afs.collection('carts', ref => ref.where('size', '==', this.size) | ||
| const cartRef: AngularFirestoreCollection<any> = 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) => { | ||
| cartRef | ||
| .valueChanges() | ||
| .pipe(take(1)) | ||
| .subscribe(value => { | ||
| console.log(value); | ||
| if (value.length === 0) { | ||
| product.image = product.image === undefined ? '../assets/[email protected]' : product.image; | ||
| product.image = | ||
| product.image === undefined | ||
| ? '../assets/[email protected]' | ||
| : product.image; | ||
| const cart: Cart = { | ||
| color: this.color, | ||
| custId: this.custId, | ||
| ... | ... | @@ -68,13 +81,21 @@ export class CartsService { |
| size: this.size | ||
| }; | ||
| console.log(cart); | ||
| this.afs.collection('carts').add(cart).then((docRef) => { | ||
| this.afs | ||
| .collection('carts') | ||
| .add(cart) | ||
| .then(docRef => { | ||
| const neworderId = docRef.id; | ||
| this.afs.collection('carts').doc(neworderId).update({cartId: docRef.id}).then(() => { | ||
| this.afs | ||
| .collection('carts') | ||
| .doc(neworderId) | ||
| .update({ cartId: docRef.id }) | ||
| .then(() => { | ||
| console.log('Booking Successfully'); | ||
| document.body.scrollTop = document.documentElement.scrollTop = 0; | ||
| }); | ||
| }).catch((error) => { | ||
| }) | ||
| .catch(error => { | ||
| console.error('Error adding document: ', error); | ||
| }); | ||
| } else { | ||
| ... | ... | @@ -83,7 +104,11 @@ export class CartsService { |
| 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(() => { | ||
| this.afs | ||
| .collection('carts') | ||
| .doc(cartId) | ||
| .update({ qty: `${qty}` }) | ||
| .then(() => { | ||
| console.log('Booking Successfully'); | ||
| document.body.scrollTop = document.documentElement.scrollTop = 0; | ||
| }); | ||
| ... | ... | @@ -92,13 +117,16 @@ export class CartsService { |
| } | ||
| public async cartList() { | ||
| const cartRef: AngularFirestoreCollection<any> = this.afs.collection('carts', ref => ref.where('custId', '==', this.custId)); | ||
| cartRef.valueChanges().subscribe((value) => { | ||
| const cartRef: AngularFirestoreCollection<any> = this.afs.collection( | ||
| 'carts', | ||
| ref => ref.where('custId', '==', this.custId) | ||
| ); | ||
| cartRef.valueChanges().subscribe(value => { | ||
| this.carts = []; | ||
| const res = value; | ||
| this.cartTotal = 0; | ||
| if (res.length > 0) { | ||
| res.forEach((item) => { | ||
| res.forEach(item => { | ||
| const cartItem: CartItem = { | ||
| cartId: item.cartId, | ||
| color: item.color, | ||
| ... | ... | @@ -109,7 +137,7 @@ export class CartsService { |
| prodName: item.prodName, | ||
| image: item.image, | ||
| qty: item.qty, | ||
| size: item.size, | ||
| size: item.size | ||
| }; | ||
| console.log(item.price, item.qty); | ||
| if (item.price) { | ||
| ... | ... | @@ -142,26 +170,37 @@ export class CartsService { |
| removeCount(index) { | ||
| // tslint:disable-next-line:radix | ||
| const qty = this.carts[index].qty > 1 ? this.carts[index].qty - 1 : this.carts[index].qty; | ||
| const qty = | ||
| this.carts[index].qty > 1 | ||
| ? this.carts[index].qty - 1 | ||
| : this.carts[index].qty; | ||
| this.carts[index].qty = qty; | ||
| console.log(this.carts[index].qty); | ||
| this.afs.collection('carts').doc(this.carts[index].cartId).update({ | ||
| this.afs | ||
| .collection('carts') | ||
| .doc(this.carts[index].cartId) | ||
| .update({ | ||
| qty: this.carts[index].qty | ||
| }); | ||
| } | ||
| addCount(index) { | ||
| const qty = this.carts[index].qty + 1; | ||
| this.cartTotal = 0; | ||
| this.carts[index].qty = qty; | ||
| this.afs.collection('carts').doc(this.carts[index].cartId).update({ | ||
| this.afs | ||
| .collection('carts') | ||
| .doc(this.carts[index].cartId) | ||
| .update({ | ||
| qty: this.carts[index].qty | ||
| }); | ||
| } | ||
| removeItem(index) { | ||
| this.afs.collection('carts').doc(this.carts[index].cartId).delete(); | ||
| this.afs | ||
| .collection('carts') | ||
| .doc(this.carts[index].cartId) | ||
| .delete(); | ||
| } | ||
| checkPromo(promoCode: string) { | ||
| ... | ... |
Please
register
or
sign in
to comment