【发布时间】:2019-05-29 14:24:02
【问题描述】:
我有一个从 Wordpress Woocommerce 商店中的 iFrame 调用的应用程序(WordPress 插件)。一切正常。 该应用程序生成产品并将它们添加到购物车,并允许访问者进入购物车并付款。使用 jQuery 模态。
目前我正在使用重定向来为访问者提供对购物车的访问权限。 但是,我希望访客在结帐后留下(回来)。 这个想法是所有访问者交互都由模态处理 这样访问者可以继续使用应用程序并生成更多产品。
这可能吗? 有更好的选择吗?
我目前的代码如下:
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" );
});
}
【问题讨论】:
标签: jquery wordpress iframe woocommerce