Woocomerce integration in Invoice component
This commit is contained in:
commit
b6502a3f36
4 changed files with 58 additions and 11 deletions
13
CHANGELOG.md
13
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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "zgo",
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
|
|
|
@ -120,9 +120,24 @@
|
|||
<button style="margin-top: 20px;
|
||||
font-weight: 700;
|
||||
background-color: lightgray;"
|
||||
mat-raised-button
|
||||
(click)="copyMemo()">Copy Memo</button>
|
||||
mat-raised-button
|
||||
(click)="copyMemo()" *ngIf="!isWCOrder">Copy Memo</button>
|
||||
|
||||
<div style="display: flex;
|
||||
justify-content: space-between;"
|
||||
*ngIf="isWCOrder">
|
||||
<button style="margin-top: 20px;
|
||||
font-weight: 700;
|
||||
background-color: lightgray;"
|
||||
mat-raised-button
|
||||
(click)="copyMemo()">Copy Memo</button>
|
||||
|
||||
<button style="margin-top: 20px;
|
||||
font-weight: 700;
|
||||
background-color: lightcyan;"
|
||||
mat-raised-button
|
||||
(click)="backToShop()" >Return to Shop</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue