diff --git a/CHANGELOG.md b/CHANGELOG.md index 812011c..7e8ee18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +<<<<<<< HEAD +======= +## [1.3.3] - 2022-12-13 + +### Added + +- Support for Woocomerce - +- a "Return To Shop" button added to ZGo Invoice component +- Open WooCommerce checkout page if popups are allowed in customer's browser + +## [1.3.2] - 2022-10-11 + +>>>>>>> cc881b38a1b0a1fd35863650da445e6179f192bf ### Added - New component added to export orders in CSV format. Allows users to download orders. diff --git a/package.json b/package.json index 0bbd231..bbbe622 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zgo", - "version": "1.3.1", + "version": "1.3.2", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/src/app/invoice/invoice.component.html b/src/app/invoice/invoice.component.html index d682959..c64927a 100644 --- a/src/app/invoice/invoice.component.html +++ b/src/app/invoice/invoice.component.html @@ -116,13 +116,28 @@ background-color: lightgray;" mat-raised-button (click)="copyAmount()">Copy Amount - + + mat-raised-button + (click)="copyMemo()" *ngIf="!isWCOrder">Copy Memo + +
+ + +
diff --git a/src/app/invoice/invoice.component.ts b/src/app/invoice/invoice.component.ts index 4149eb0..77489e5 100644 --- a/src/app/invoice/invoice.component.ts +++ b/src/app/invoice/invoice.component.ts @@ -26,12 +26,11 @@ export class InvoiceComponent implements OnInit { name: string = ''; error: boolean = false; codeString: string = 'Test'; - + public isWCOrder : boolean = false; zcashUrl: SafeUrl = ''; - - + externalURL: string = ''; order:Order = { - _id: '', + _id: '', address: '', session: '', timestamp: '', @@ -60,6 +59,7 @@ export class InvoiceComponent implements OnInit { private notifierService : NotifierService ) { this.orderId = this._ActiveRoute.snapshot.paramMap.get("orderId"); + console.log('constructor - orderId -> ' + this.orderId); this.orderUpdate = receiptService.orderUpdate; this.nameUpdate = receiptService.nameUpdate; receiptService.getOrderById(this.orderId!).subscribe(response => { @@ -83,6 +83,9 @@ export class InvoiceComponent implements OnInit { }); this.orderUpdate.subscribe(order => { this.order = order; + if ( order.session.substring(0,1) == 'W') { + this.isWCOrder = true; + } this.codeString = `zcash:${this.order.address}?amount=${this.order.totalZec.toFixed(8)}&memo=${URLSafeBase64.encode(Buffer.from('ZGo Order::'.concat(this.orderId!)))}`; this.zcashUrl = this.sanitizer.bypassSecurityTrustUrl(this.codeString); }); @@ -92,10 +95,26 @@ export class InvoiceComponent implements OnInit { } ngOnInit(): void { - } + setTimeout(() => this.backToShop(), 10000); + } - ngAfterViewInit(): void { - console.log('Order.externalInvoice -> ' + this.order.externalInvoice); + backToShop() { + if ( this.isWCOrder ) { + console.log('External Invoice -> ' + this.order.externalInvoice ); + const b64URL:string = this.order.externalInvoice.substring(0,this.order.externalInvoice.indexOf("-")); + console.log('encodedURL -> ' + b64URL ); + const shopURL: string = Buffer.from(b64URL, 'base64').toString(); + const tmp_orderid = this.order.externalInvoice.substring(this.order.externalInvoice.indexOf('-')+1); + const wc_order_key = tmp_orderid.substring(tmp_orderid.indexOf('-')+1); + const wc_orderid = tmp_orderid.substring(0,tmp_orderid.indexOf('-')); + console.log('wc_order_id -> ' + wc_orderid); + console.log('wc_order_key -> ' + wc_order_key); + console.log('new URL -> ' + shopURL + '/checkout/order-received/' + wc_orderid + '/?key=' + wc_order_key); + if ( shopURL ) { + console.log('Opening URL....' + shopURL); + window.open( shopURL + '/checkout/order-received/' + wc_orderid + '/?key=' + wc_order_key,"_blank"); + } + } } getIconStyle(order : Order) {