X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   How add required checkbox to checkout (https://forum.x-cart.com/showthread.php?t=69846)

Martin Bishop 08-19-2014 08:14 AM

How add required checkbox to checkout
 
Hi

I want to add more required checkboxes to the checkout (in addition to the 'Yes I've read Ts and Cs and privacy statement' one). Is there a simple way to do this?

I tried adding some using CSS3 required responses but discovered this doesn't work in safari etc. so not ideal for a checkout.

thanks
Martin

totaltec 08-19-2014 12:03 PM

Re: How add required checkbox to checkout
 
Not exactly simple depending on what you want to do with the validation and/or record the submission. I've done this before by expanding the built in JavaScript in the form to encompass my additional box. And I've also written custom JS of my own to create popups with multiple checkboxes, then recorded the responses with the order.

I'm not familiar with your version at the moment, it's a little bit old now and my memory of it is fading. Do you have One Page Checkout? Is it the stock one included with the cart?

Looks like I have a working example of something like you want up on my test site: http://trainingpen.com/ (this site gets blown away and rebuilt from time to time)

It's based on a particular product being added to cart http://trainingpen.com/product.php?productid=17611 If you add that to cart and proceed to checkout a special checkbox will appear and it will display the sku.

If you want me to, I can hunt the code down for you and pass it along, though I would need to bill for the time as it will take a bit of work to find as its been a year or more. The solution is probably posted by me right on this forum, but I looked and googled and couldn't find it...

totaltec 08-19-2014 12:11 PM

Re: How add required checkbox to checkout
 
Here is the basic idea that I could glean quickly, should put you on the right track:
Template: /ideal_responsive/modules/One_Page_Checkout/opc_summary.tpl
Code:

  <div class="terms_n_conditions">
    <label for="accept_terms">
      <input type="checkbox" name="accept_terms" id="accept_terms" value="Y" />
      {$lng.txt_terms_and_conditions_note|substitute:"terms_url":"`$xcart_web_dir`/pages.php?alias=conditions":"privacy_url":"`$xcart_web_dir`/pages.php?alias=business"}
    </label>
  </div>

Just duplicate that code and change the input name to "accept_two" or similar, update the label "for" too. Wipe out the language variable in the label and put your own text and links. Then search for the JavaScript and update the function to check for the second box, and that's the piece that would take me a bit to look up and work out for you.

Martin Bishop 08-20-2014 12:51 AM

Re: How add required checkbox to checkout
 
Hi Mike

thanks very much for taking the time to have a look, it's really helpful. I'll have a go myself with your suggested method above and maybe give you a shout if I run up against a code wall (i.e. javascript).

many thanks

cherie 08-28-2014 04:38 PM

Re: How add required checkbox to checkout
 
Also change the id as they must be unique.


All times are GMT -8. The time now is 03:47 AM.

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