X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Disable the order submit button (https://forum.x-cart.com/showthread.php?t=6318)

dsparks 02-19-2004 02:14 PM

Disable the order submit button
 
There was a piece of code on the forum before the site went down that explained how to code the "submit order" button so that it becomes disabled after the customer presses it once. This will stop them from pressing it multiple times and causing duplicate orders.

Can this be posted again?

Thanks...

B00MER 02-20-2004 07:05 AM

Code:

{***

Disable Submit order button once pressed

by:                          www.cart-lab.com
for:                        X-Cart Version 3.5.x
template: customer/main/checkout.tpl

***}

{*** Copy to skin1/customer/main/checkout.tpl ***}
{literal}
<SCRIPT language=JavaScript1.2>
<!--
function classChange(element,newclass) {
        element.className = newclass;
}

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.desc{display: none;}\n')
document.write('</style>\n')
}

function switchcontent(obj){
        if(document.getElementById){
        var el = document.getElementById(obj);
        var ar = document.getElementById("meat").getElementsByTagName("span"); //DynamicDrive.com change
                if(el.style.display != "block"){ //DynamicDrive.com change
                        for (var i=0; i<ar.length; i++){
                                if (ar[i].className=="sub") //DynamicDrive.com change
                                ar[i].style.display = "none";
                        }
                        el.style.display = "block";
                }else{
                        el.style.display = "none";
                }
        }
}

function submit_checkout() {
        //alert("'Submit' order button will be removed while we process your order, Press 'Ok' to continue processing your order.");
        document.checkout_form.submit();
        switchcontent('submit');
}

//-->
</SCRIPT>
{/literal}
{*** End of disable submit order scripts ***}

{*** Disable submit order button upon process of order ***}
{if $js_enabled}
<div id="meat">
<p align=center>
<span id="submit" class="sub" style="display:block;">
{include file="buttons/submit_order.tpl"}
</span>
</div>
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_submit_order}
{/if}
{*** END OF Disable submit order button upon process of order ***}


gman 06-18-2005 06:44 PM

Is this code just placed anywhere in the template? I am confused.

balinor 06-18-2005 07:44 PM

Take a look at the code closely, the comments at the top explain it.

gman 06-19-2005 08:21 AM

Ryan,
What I am seeing is:
Code:

{***

Disable Submit order button once pressed

by:          www.cart-lab.com
for:          X-Cart Version 3.5.x
template: customer/main/checkout.tpl

***}

{*** Copy to skin1/customer/main/checkout.tpl ***}

The only instruction I see is too copy it to the template. Is does nto say where in the template or if code gets replaced, etc. Sorry for being blind or stupid on this.

gman 06-21-2005 07:33 AM

Anyone feel free to jump in on this please.

B00MER 06-21-2005 08:20 AM

All code under this can go anywhere in your checkout.tpl file.

Code:

{*** Copy to skin1/customer/main/checkout.tpl ***}

This part needs to replace the anchor code (<A HREF..> until the included buttons/submit.tpl file.)

Code:

{*** Disable submit order button upon process of order ***}

gman 06-21-2005 11:15 AM

Thanks all but the problem appears to be AFTER the checkout button is pushed and when they press the credit card button.

dsparks 06-21-2005 01:19 PM

I'm not sure what buttons you are talking about, I only see a checkout button, then a continue button on the payment selection type, then the submit order button.

Anyway, here is the code in case this helps. This disables the submit order button after it is pressed.

>>>>>>>>>>>>>

You said you are using version 3.5.12. I could only find a release with the version of 3.5.1.

I never installed the 3.5.1 version but I did install the patch on the 3.5.4 version.

I compared the checkout.tpl files for both versions (3.5.4 and 3.5.1) and they are exactly the same.

I have included a version of the checkout.tpl file with the patch already applied. You can either replace your checkout.tpl file or do a file comparison and make your own changes.

Hope this helps...





Code:

{* $Id: checkout.tpl,v 1.37 2003/11/17 12:10:16 mclap Exp $ *}
{include file="location.tpl" last_location=$lng.lbl_payment_details}
{capture name=checkout_dialog}
<form action="cart.php" method=post name=cartform>
{if $config.Appearance.show_cart_details eq "Y" or ($config.Appearance.show_cart_details eq "L" and $smarty.get.paymentid ne "" and $smarty.get.mode eq "checkout")}
{include file="customer/main/cart_details.tpl"}
{else}
{include file="customer/main/cart_contents.tpl"}
{/if}
<HR noshade size=1>

{include file="customer/main/cart_totals.tpl"}



{if $js_enabled}
{include file="buttons/update.tpl"}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_update}
{/if}
</form>
{/capture}
{include file="dialog.tpl" title="`$lng.lbl_checkout`: `$lng.lbl_step` `$checkout_step` `$lng.lbl_of` `$total_checkout_steps`" content=$smarty.capture.checkout_dialog extra="width=100%"}



{if $smarty.get.mode eq "auth"}
{include file="main/error_login_incorrect.tpl"}
{/if}
{if $payment_data.payment_method ne ""}
<h5>{$lng.lbl_payment_method}: {$payment_data.payment_method}</h5>
{capture name=dialog}
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<form action="{$payment_data.payment_script_url}" method=post name=checkout_form>
<input type=hidden name=action value="place_order">
<tr><td>
<pre>
<font>
{include file="customer/main/customer_details.tpl"}
</font>
</pre>
{include file="buttons/modify.tpl"}


{if $ignore_payment_method_selection eq ""}
<div align=right>
{include file="buttons/change_payment_method.tpl"}
</div>
{/if}
<input type=hidden name={$XCARTSESSNAME} value={$XCARTSESSID}>
{if $payment_data.payment_template ne ""}
{include file=$payment_data.payment_template}
{/if}
{include file="customer/main/checkout_notes.tpl"}


<input type=hidden name=payment_method value="{$payment_data.payment_method}">
{$lng.txt_you_are_agree} "{$lng.lbl_terms_n_conditions}" {$lng.lbl_and} "{$lng.lbl_privacy_statement}".
<p align=center>

{* =+=+=+=+=+=+=+=+=+= 20 Feb 2004 Change: DCS00080 *}

{* {if $js_enabled} *}
{* {include file="buttons/submit_order.tpl" style="button"} *}
{* {else} *}
{* {include file="submit_wo_js.tpl" value=$lng.lbl_submit_order} *}
{* {/if} *}

{literal}
<SCRIPT language=JavaScript1.2>
<!--
function classChange(element,newclass) {
  element.className = newclass;
}

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.desc{display: none;}\n')
document.write('</style>\n')
}

function switchcontent(obj){
  if(document.getElementById){
  var el = document.getElementById(obj);
  var ar = document.getElementById("meat").getElementsByTagName("span"); //DynamicDrive.com change
      if(el.style.display != "block"){ //DynamicDrive.com change
        for (var i=0; i<ar.length; i++){
            if (ar[i].className=="sub") //DynamicDrive.com change
            ar[i].style.display = "none";
        }
        el.style.display = "block";
      }else{
        el.style.display = "none";
      }
  }
}

function submit_checkout() {
  //alert("'Submit' order button will be removed while we process your order, Press 'Ok' to continue processing your order.");
  document.checkout_form.submit();
  switchcontent('submit');
}

//-->
</SCRIPT>
{/literal}
{*** End of disable submit order scripts ***}

{*** Disable submit order button upon process of order ***}
{if $js_enabled}
<div id="meat">
<p align=center>
<span id="submit" class="sub" style="display:block;">
{include file="buttons/submit_order.tpl"}
</span>
</div>
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_submit_order}
{/if}
{* =+=+=+=+=+=+=+=+=+= 20 Feb 2004 Change: DCS00080 *}

</td></tr>
</form>
</table>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_payment_details content=$smarty.capture.dialog extra="width=100%"}

{elseif $payment_methods ne ""}

{capture name=dialog}
<form method=get action="cart.php" name=checkout_form>
<table border=0 align=center>
{section name=payment loop=$payment_methods}
<tr>
<td width=1><input type=radio name=paymentid value={$payment_methods[payment].paymentid}{if $payment_methods[payment].is_default eq "1"} checked{/if}></td>
<td nowrap>{$payment_methods[payment].payment_method}</td>
<td>{$payment_methods[payment].payment_details}</td>
</tr>
{/section}
<input type=hidden name=mode value=checkout>
</table>


<div align=center>
{if $js_enabled}
{include file="buttons/continue.tpl" style="button"}
{else}
{include file="submit_wo_js.tpl" value=$lng.lbl_continue}
{/if}
</div>
</form>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_payment_method content=$smarty.capture.dialog extra="width=100%"}
{/if}


gman 06-21-2005 02:44 PM

dsparks,
I to see a continue button where you choose payment then continue to the next page. The first code above seems to replace that button, but I do not believe that is the button having the problem. I think it is the one on the credit card info page the one marked "Submit order" which is really the order button that is getting wacked twice.


All times are GMT -8. The time now is 07:22 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.