Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Checkout_Confirmation OnClick


astehli

Recommended Posts

Greetings. After 3 months of programming I have eventually found something I cannot solve. I have added the Contribs (thanks to the authors :thumbsup: ) of "SaferPay" and "Must agree to terms".

 

However, the SaferPay contrib spawns a new window even if I have not checked the "I Agree to Terms" checkbox. Details as follows (in Checkout_Confirmation.php):

 

_____________________

 

In the <head>, these scripts (amongst others):

 

<script LANGUAGE="JavaScript" SRC="https://www.saferpay.com/OpenSaferpayScript.js"></SCRIPT>

 

<script LANGUAGE="JavaScript">

function check_agree(TheForm) {

if (TheForm.agree.checked) {

return true;

} else {

alert(unescape('<?php echo CONDITION_AGREEMENT_ERROR; ?>'));

return false;

}

}

</SCRIPT>

_____________________

 

In the <body>, this form, checkbox and submit button:

 

echo tep_draw_form('checkout_confirmation', $form_action_url, 'post', 'onsubmit="return check_agree(this);"');

 

echo tep_draw_checkbox_field('agree','true', false, 'onclick="window.document.checkout_confirmation.agree.checked = !window.document.checkout_confirmation.agree.checked;"');

 

echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER, 'onClick="OpenSaferpayTerminal(\'' . $payinit_url . '\', this, \'BUTTON\')"');

 

_____________________

 

Scenario:

If the checkbox is CHECKED, the function check_agree(TheForm) returns TRUE, the SaferPay window spawns and everything is OK.

 

Problem Scenario:

If the checkbox is unchecked, the function check_agree(TheForm) returns FALSE, displays the ALERT, but the SaferPay Window ALSO SPAWNS :'( , when in fact it shouldnt, or I would rather it wouldnt :( .

 

I have tried a million combinations (nearly) of ways to stop this from happening, except the right combination which I cant figure out. I would be happy :D for some advice here. Thanks in advance :thumbsup:

Link to comment
Share on other sites

I've managed to resolve this without the help of the forum B) . For any persons with same or similar problems the solution is as follows:

 

Remove the validation from the form:

BEFORE:

echo tep_draw_form('checkout_confirmation', $form_action_url, 'post', 'onsubmit="return check_agree(this);"');

 

AFTER:

echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');

 

 

Add the validation to the Button and change the form reference, then concatenate the second function:

BEFORE:

echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER, 'onClick="OpenSaferpayTerminal(\'' . $payinit_url . '\', this, \'BUTTON\')"');

 

AFTER:

echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER, 'onClick="return check_agree(this.form) && OpenSaferpayTerminal(\'' . $payinit_url . '\', this, \'BUTTON\')"');

 

This works great! :thumbsup:

Link to comment
Share on other sites

  • 11 months later...

hello, my name is greg,

 

when i use your code, i have this problem:

 

'ERROR: Missing CURRENCY attribute' and the page is not redirected to checkout process,

 

can you help me?

 

thank you

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...