Update invoice component for Woocommerce

This commit is contained in:
Rene V. Vergara A. 2022-12-17 19:18:28 -05:00
parent b6502a3f36
commit d66b956773
2 changed files with 23 additions and 15 deletions

View file

@ -136,7 +136,14 @@
font-weight: 700;
background-color: lightcyan;"
mat-raised-button
(click)="backToShop()" >Return to Shop</button>
(click)="backToShop()" >
<fa-icon style="color: #FB4F14;
margin-bottom: -2px;
margin-right: 5px;
font-size: 20px;
cursor: pointer;"
[icon]="faArrowUpRightFromSquare"> </fa-icon>
Return to Shop</button>
</div>
</div>

View file

@ -4,7 +4,7 @@ import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { ReceiptService } from '../receipt.service';
import { Order} from '../order/order.model';
import { Observable } from 'rxjs';
import { faCheck, faHourglass } from '@fortawesome/free-solid-svg-icons';
import { faCheck, faHourglass, faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons';
import { NotifierService } from '../notifier.service';
@ -20,6 +20,7 @@ var Buffer = require('buffer/').Buffer;
export class InvoiceComponent implements OnInit {
faCheck = faCheck;
faHourglass = faHourglass;
faArrowUpRightFromSquare = faArrowUpRightFromSquare;
orderId;
public orderUpdate: Observable<Order>;
public nameUpdate: Observable<string>;
@ -95,23 +96,22 @@ export class InvoiceComponent implements OnInit {
}
ngOnInit(): void {
setTimeout(() => this.backToShop(), 10000);
}
backToShop() {
if ( this.isWCOrder ) {
console.log('External Invoice -> ' + this.order.externalInvoice );
// console.log('External Invoice -> ' + this.order.externalInvoice );
const b64URL:string = this.order.externalInvoice.substring(0,this.order.externalInvoice.indexOf("-"));
console.log('encodedURL -> ' + b64URL );
// 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);
// 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);
// console.log('Opening URL....' + shopURL);
window.open( shopURL + '/checkout/order-received/' + wc_orderid + '/?key=' + wc_order_key,"_blank");
}
}
@ -138,6 +138,7 @@ export class InvoiceComponent implements OnInit {
// console.error("Error", err);
}
}
copyAmount() {
if (!navigator.clipboard) {
// alert("Copy functionality not supported");