Skip to content

Instantly share code, notes, and snippets.

@robwilliams
Created February 15, 2010 09:07
Show Gist options
  • Save robwilliams/304501 to your computer and use it in GitHub Desktop.
Save robwilliams/304501 to your computer and use it in GitHub Desktop.
// DO NOT use this code if you are using more than one psp !!
$(function() {
$checkout_sequence = $('input[@name="SEQUENCE"]');
// only execute the following code if we are on a checkout page
if($checkout_sequence.length > 0){
/*
autoforward to psp bounce stage unless user has chosen a
seperate delivery address
*/
// if you have renamed your checkout next button change it here!
var next_button_name = 'Next>';
// make sure we are on checkout page 2
if ($checkout_sequence.val() == '2') {
// make sure the delivery address fields are not on the page
if($('input[@name="DELIVERCOUNTRY"]').length != 1) {
// hide all of the page content so it looks like a quick redirect (not foolproof)
$('div').hide();
// find the input tags parent form
$form = $checkout_sequence.parent();
// append the "next>" action to the form so the perl scripts handle it correctly
$form.append('<input type="hidden" value="' + next_button_name + '" name="ACTION" />');
// i think it's quite obvious what this does :)
$form.submit();
}
}
/*
when 'enter' is pressed, submit form to the correct location
instead of the usual action of going to the first stage of the checkout
*/
// select all input fields except submit buttons
$checkout_sequence
.parent()
.find("input")
.not('input[@type="submit"]')
.keydown(function(event){
// 13 = enter
if(event.keyCode == 13) {
$form = $checkout_sequence.parent();
// append the "next>" action to the form so the perl scripts handle it correctly
$form.append('<input type="hidden" value="' + next_button_name + '" name="ACTION" />');
// and submit
$form.submit();
event.preventDefault();
}
});
};
/*
Autoforward to payment provider
*/
// make sure we are on the psp bounce page
if(document.formOCC) {
// hide all of the page content so it looks like a quick redirect (not foolproof)
$('div').hide();
// uncomment the next line if you are using google analytics e-commerce tracking
//__utmLinkPost(document.formOCC);
// and submit the page
document.formOCC.submit();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment