Im trying to make a redirection plugin on jquery. It should redirect twice, first to a "thank you for purchase, you gonna be redirected now" and then to an external page where you made the actual purchase.
Everything works fine when I redirect but I can't get the item_id or amount of the product that im posting. Is a wordpress page and im posting a product to display in an external page where you made the actual purchase. This is my code which redirects you you to a "/success" page after clicking the button "continue", after the success page is displayed, it will show the message for 5 seconds and then it must redirect you to the actual purchase page:
function addToListAndRedirect(item_id){
var email = jQuery("[name='your-email']").val();
var amount = jQuery("[name='vinbrevet-contact-amount']").val();
var subscription = {
ListIds: [
"beeb2f48-5265-443e-960f-4f995d8c2942"
],
ConfirmationIssue: { IssueId: "cd081857-4f30-4da1-ab5c-a7883f62d99c" },
Contact: {
Email: email
}
}
window.location.href = "http://vinbrevet.se/success?items="+ item_id + ":" + amount; }
the code in /success page:
function redirectToExternal(item_id, amount) {
var item_id;
var amount = jQuery("[name='vinbrevet-contact-amount']").val();;
jQuery.post("http://ui.admlo.se/Api/Subscriptions/c03a4119-f6a8-4d86-b34f-f16177ec7912").always(function() {
window.location.replace("https://www.systembolaget.se/dryckeslista?items=" + item_id+":" + amount);
});
}
setTimeout("redirectToExternal()", 5000);
I understand that it should be a better way... but iis it possible to get the item_id and amount from the browser bar? or how should I get the item_id and amount after the first redirect? In the page /success i can display the item_id and amount but in the second redirect I get undefined:undefined.
URL example:
http://vinbrevet.se/success/?items=7487101:1 (the success page).
https://www.systembolaget.se/delat?items=undefined:undefined (the redirect after success page)