I have an app (WordPress Plugin) called from an iFrame in Wordpress Woocommerce store. All works fine. The app generates products and adds them to the cart and allowing the visitor to get to the cart and pay. Using jQuery Modals.
Currently I am using redirect to provide the visitor access to the cart. BUT, I would like the visitor to stay (come back) after the checkout. The idea is that all visitor interaction is handled with Modals Such that the visitor can continue using the app and generate more products.
Is that possible? Is there a better option?
My current code is as follows:
function contact_woo_shop(orderfilename, urlAtts, counts, table){
var pid=0
jQuery.post(
ts_woo.ajax_url,
{'action': 'do_ts_woo','order': orderfilename,
'board': urlAtts,'table': table},
function(response) {
if(response.success){
pid = response.data;
console.log("do_ts_woo. SUCCESS response="+response.data);
/* I WISH TO CANCEL THIS REDIRECT in favor of another MOdal with Iframe below*/
window.location.replace("https://orig-site.co.il/cart/?add-to-cart="+response.data);
} else {
console.log("do_ts_woo. FAILURE response="+response.data);
}
}
).done(function(response) {
console.log("DONE do_ts_woo. DONE response="+response.data);
/* I wish to have the Modal & Iframe here */
jQuery("#dialog").dialog({
autoOpen: false,
show: "fade",
hide: "fade",
modal: true,
open: function (ev, ui) {
jQuery('#myIframe').attr('src',"https://orig-site.co.il/cart/?add-to-cart="+pid);
},
height: 'auto',
width: 'auto',
resizable: true,
title: 'Tilesim'
});
jQuery("#opener").click(function () {
jQuery("#dialog").dialog("open");
return false;
})
})
.fail(function(msg) {
alert( "error msg="+msg );
})
.always(function() {
// alert( "finished" );
});
}