Thread: Regulations

Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    red flag Regulations

    Hi I'm trying to set up a new regulation in 'Configuration, Regulations'

    So far I've managed to set this up in the database by adding a new row. The row is called DISPLAY_DELIVERY_ON_CHECKOUT.

    This will then force the customer to tick a box once they've entered delivery instructions.

    I've edited tpl_checkout_payment_default so it displays an extra checkbox on the website to do this and the new regulation shows up in the admin however when you go through the payment process step 2 just shows up a blank page.

    This is what I've done with the code in tpl_checkout_payment_default

    <?php
    if (DISPLAY_CONDITIONS_ON_CHECKOUT == 'true') {
    ?>
    <fieldset>
    <legend><?php echo TABLE_HEADING_CONDITIONS; ?></legend>
    <div><?php echo TEXT_CONDITIONS_DESCRIPTION;?></div>
    <?php echo zen_draw_checkbox_field('conditions', '1', false, 'id="conditions"');?>
    <label class="checkboxLabel" for="conditions"><?php echo TEXT_CONDITIONS_CONFIRM; ?></label>
    </fieldset>


    <?php
    if (DISPLAY_DELIVERY_ON_CHECKOUT == 'true') {
    ?>

    <fieldset>
    <?php echo zen_draw_checkbox_field('delivery', '1', false, 'id="delivery"');?>
    <label class="checkboxLabel" for="delivery"><?php echo TEXT_DELIVERY_INSTRUCTIONS; ?></label>
    </fieldset>
    <?php
    }
    ?></fieldset>


    However if I take out this line

    <?php
    if (DISPLAY_DELIVERY_ON_CHECKOUT == 'true') {
    ?>

    The check box displays, although doesn't force the customer to tick it.

    So any ideas on how I might get this to function correctly?

    Please see the graphic attached for how step 2 of the payment process should display.

    Thanks

    Nick
    Attached Images Attached Images  

  2. #2

    Default Re: Regulations

    You are missing a } in your code.

    Try the code below:
    PHP Code:
    <?php
    if (DISPLAY_CONDITIONS_ON_CHECKOUT == 'true') {
    ?>
    <fieldset>
    <legend><?php echo TABLE_HEADING_CONDITIONS?></legend>
    <div><?php echo TEXT_CONDITIONS_DESCRIPTION;?></div>
    <?php echo zen_draw_checkbox_field('conditions''1'false'id="conditions"');?>
    <label class="checkboxLabel" for="conditions"><?php echo TEXT_CONDITIONS_CONFIRM?></label>
    </fieldset>


    <?php
    }

    if (
    DISPLAY_DELIVERY_ON_CHECKOUT == 'true') {
    ?>

    <fieldset>
    <?php echo zen_draw_checkbox_field('delivery''1'false'id="delivery"');?>
    <label class="checkboxLabel" for="delivery"><?php echo TEXT_DELIVERY_INSTRUCTIONS?></label>
    </fieldset>
    <?php
    }
    ?></fieldset>
    To force the user to check the box, you can maybe add a quick javascript function to show an alert with an error message if the box is not checked.

    it would be something like:

    Code:
    <script type="text/javascript">
    function validate()
    {
          if(document.forms[0].conditions.checked == false)
          {
                alert('Please accept the conditions!');
                return false;
          } else {
                return true;
          }
    
    }
    </script>

    and add the following to your form tag:

    Code:
    onSubmit="return validate();"
    http://www.customscripts.co.za - Custom development for open-source applications

    http://www.pcservice.co.za - Website Development, Domain Registration, Hosting

  3. #3
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    red flag Re: Regulations

    Hi Pierre, Thanks for that. It worked with your code adding in }

    However it doesn't fire up a red warning message such as the one that gets displayed when you don't check the terms and conditions checkbox.

    Like this one ' Please confirm the terms and conditions bound to this order by ticking the box below. '

    So how would I get it to do this? I assume its just a case of setting the checkbox to 'REQUIRED'.

    I've tried various Javascripts to do this but none seem to work correctly. And besides, having this controlled from the shop admin makes it easier if it needs to be turned off.

    Please can you let me know if you can shed any light on how I get this to fire up a warning message if the box hasn't been checked?

    Many Thanks

    Nick

  4. #4

    Default Re: Regulations

    edit the file includes/modules/pages/checkout_confirmation/header_php.php

    Find around line 51:

    PHP Code:
    if (DISPLAY_CONDITIONS_ON_CHECKOUT == 'true') {
      if (!isset(
    $_POST['conditions']) || ($_POST['conditions'] != '1')) {
        
    $messageStack->add_session('checkout_payment'ERROR_CONDITIONS_NOT_ACCEPTED'error');
      }


    add this just below that:
    PHP Code:
    if (DISPLAY_DELIVERY_ON_CHECKOUT == 'true') {
      if (!isset(
    $_POST['delivery']) || ($_POST['delivery'] != '1')) {
        
    $messageStack->add_session('checkout_payment'ERROR_DELIVERY_NOT_ACCEPTED'error');
      }

    of course you would need to define ERROR_DELIVERY_NOT_ACCEPTED for the text you want to be displayed
    http://www.customscripts.co.za - Custom development for open-source applications

    http://www.pcservice.co.za - Website Development, Domain Registration, Hosting

  5. #5
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    red flag Re: Regulations

    Hi Pierre, this works great thanks and does exactly what I was trying to achieve. So thanks for the pointers.

    Just one thing, where do I put this in the languages files?

    define('ERROR_DELIVERY_NOT_ACCEPTED', 'Please let us know your delivery instructions e.g. Leave nextdoor. If there are none please tick this box to proceed.');


    Many Thanks

    nick

  6. #6

    Default Re: Regulations

    You can put it anywhere in your includes/languages/english.php file
    http://www.customscripts.co.za - Custom development for open-source applications

    http://www.pcservice.co.za - Website Development, Domain Registration, Hosting

 

 

Similar Threads

  1. Help With Regulations
    By Globie in forum General Questions
    Replies: 9
    Last Post: 15 Sep 2010, 04:07 PM
  2. Adding New Regulations
    By SeaBriz in forum General Questions
    Replies: 2
    Last Post: 2 Dec 2008, 12:12 AM
  3. Add new regulations
    By ilove24 in forum General Questions
    Replies: 0
    Last Post: 28 Aug 2008, 07:39 AM
  4. Regulations Per Product?
    By gabstero in forum General Questions
    Replies: 0
    Last Post: 13 Aug 2008, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg