Added CAD/USD pricing options

This commit is contained in:
Zakary Timson 2018-07-23 12:09:11 -04:00
parent 9645a6b81f
commit 7c9e272a86
4 changed files with 14 additions and 9 deletions

View File

@ -25,7 +25,6 @@ export const checkout = functions.https.onRequest((request, response) => {
transactions: [
{
item_list: {items: []},
amount: {total: 0, currency: 'CAD'},
description: 'Purchase of equipment and suplies from FH & Sons'
}
]
@ -46,7 +45,7 @@ export const checkout = functions.https.onRequest((request, response) => {
let products = await Promise.all(promises);
req.transactions[0].item_list.items = products.map((row, i) => {
const data = row.data();
return {name: data.name, sku: data.name, price: data.price, currency: 'CAD', quantity: cart[i].quantity};
return {name: data.name, sku: data.name, price: data.price, currency: data.currency, quantity: cart[i].quantity};
});
req.transactions[0].amount.total = req.transactions[0].item_list.items.reduce((acc, row, i) => {
return acc + row.price * row.quantity;

View File

@ -15,9 +15,14 @@
<textarea matInput rows="5" placeholder="Description" name="description" [(ngModel)]="description"></textarea>
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Price" type="number" name="price" [(ngModel)]="price">
<span matPrefix>$&nbsp;</span>
<input matInput placeholder="Price" type="number" name="price" [(ngModel)]="price">
<mat-hint *ngIf="!price" align="start">0 will display "Contact For Price"</mat-hint>
</mat-form-field>
<mat-radio-group [(ngModel)]="currency" name="currency">
<mat-radio-button value="CAD" class="pl-3">CAD</mat-radio-button>
<mat-radio-button value="USD" class="pl-3">USD</mat-radio-button>
</mat-radio-group>
<input #fileInput type="file" (change)="imageChanged()" hidden>
</form>
</mat-dialog-content>

View File

@ -11,8 +11,9 @@ export class NewProductComponent {
categories;
category;
name: string;
currency = 'CAD';
description: string;
name: string;
price: number = 0.0;
image: string;
@ -26,8 +27,9 @@ export class NewProductComponent {
if (data.product) {
this.category = data.product.category;
this.name = data.product.name;
this.currency = data.product.currency;
this.description = data.product.description;
this.name = data.product.name;
this.price = data.product.price;
}
}
@ -40,15 +42,14 @@ export class NewProductComponent {
submit() {
let newProduct = {
name: this.name,
category: this.category,
currency: this.currency,
description: this.description,
name: this.name,
price: Number(this.price)
};
if (this.image) newProduct['image'] = this.image;
console.log(newProduct.description);
if (!this.data.product) {
this.db
.collection('products')

View File

@ -12,7 +12,7 @@
</button>
</div>
<h2 class="roboto">{{product.name}}</h2>
<h5 *ngIf="product.price" class="text-muted">{{product.price | currency}}</h5>
<h5 *ngIf="product.price" class="text-muted">{{product.currency}} {{product.price | currency}}</h5>
<h5 *ngIf="!product.price" class="text-muted">Contact For Price</h5>
<hr class="ml-4" />
<p [innerHtml]="product.description"></p>