11import { Component } from '@angular/core' ;
2- import { NavController , NavParams } from 'ionic-angular' ;
2+ import { NavController , NavParams , AlertController } from 'ionic-angular' ;
33import { Storage } from '@ionic/storage' ;
44import * as WC from 'woocommerce-api' ;
5+ import { HomePage } from '../home/home' ;
56
67@Component ( {
78 selector : 'page-checkout' ,
@@ -16,7 +17,7 @@ export class Checkout {
1617 billing_shipping_same : boolean ;
1718 userInfo : any ;
1819
19- constructor ( public navCtrl : NavController , public navParams : NavParams , public storage : Storage ) {
20+ constructor ( public navCtrl : NavController , public navParams : NavParams , public storage : Storage , public alertCtrl : AlertController ) {
2021 this . newOrder = { } ;
2122 this . newOrder . billing_address = { } ;
2223 this . newOrder . shipping_address = { } ;
@@ -110,7 +111,18 @@ export class Checkout {
110111
111112 this . WooCommerce . postAsync ( "orders" , orderData ) . then ( ( data ) => {
112113
113- console . log ( JSON . parse ( data . body ) . order ) ;
114+ let response = ( JSON . parse ( data . body ) . order ) ;
115+
116+ this . alertCtrl . create ( {
117+ title : "Order Placed Successfully" ,
118+ message : "Your order has been placed successfully. Your order number is " + response . order_number ,
119+ buttons : [ {
120+ text : "OK" ,
121+ handler : ( ) => {
122+ this . navCtrl . setRoot ( HomePage ) ;
123+ }
124+ } ]
125+ } ) . present ( ) ;
114126
115127 } )
116128
0 commit comments