Customise the Terms and Conditions Checkbox and Link in WP e-Commerce

Tuesday, 9th February 2010

By default the terms and conditions link on the checkout page in WP e-Commerce activates an overlay popup containing the terms and conditions text you have specified in the admin.

But what if you want the link to redirect to a page instead of triggering this popup? You just need to make a small change to your checkout template. Here’s what you need to do…

In The Admin

In the admin, instead of specifying terms and conditions text we are going to enter a URL. Make sure your URL is a full path including ‘http://’ as this will make it easier to detect wether the content is a URL or plain text.

Changes in your WP e-Commerce Theme

Your WP e-Commerce theme files usually reside in the ‘wp-content/uploads/wpsc/themes/your-theme’ directory. To change the terms and conditions link to link to another page rather that popup you will need to edit the ‘shopping_cart_page.php’ file.

In this file look for the terms and condition code. It will be near the bottom and should look a bit like this:

297
298
299
300
301
302
303
<?php if(get_option('terms_and_conditions') != '') : ?>
<tr>
   <td colspan='2'>
      <input type='checkbox' value='yes' name='agree' /> <?php echo TXT_WPSC_TERMS1;?><a class='thickbox' target='_blank' href='<?php echo get_option('siteurl')."?termsandconds=true&amp;width=360&amp;height=400'"; ?>' class='termsandconds'><?php echo TXT_WPSC_TERMS2;?></a>
   </td>
</tr>
<?php endif; ?>

What we will do is change this code so if the contents of your terms and condition is a link (beginning http://) it will write a link to that page rather than a popup. The new code with the if statement should look like this:

297
298
299
300
301
302
303
304
305
306
307
308
<?php if ( get_option('terms_and_conditions') != '' ) : ?>
<tr class="terms">
   <td colspan='2'>
      <input type='checkbox' value='yes' name='agree' /> <?php echo TXT_WPSC_TERMS1;?>
      <?php if ( substr(get_option('terms_and_conditions' ), 0, 7) == 'http://' ) { ?>
         <a target='_blank' href='<?php echo get_option('terms_and_conditions'); ?>' class='termsandconds'><?php echo TXT_WPSC_TERMS2;?></a>
      <?php } else { ?>
         <a class='thickbox' target='_blank' href='<?php echo get_option('siteurl')."?termsandconds=true&amp;width=360&amp;height=400'"; ?>' class='termsandconds'><?php echo TXT_WPSC_TERMS2;?></a>
      <?php } ?>
   </td>
</tr>
<?php endif; ?>

And that’s all there is to it.

3 Responses to “Customise the Terms and Conditions Checkbox and Link in WP e-Commerce”

  1. i-cute Says:

    thanks ben.. u are my savior.. i just wondering why wp e-commerce never open a tutorial thread in the support forum so that people who already have their own way of customization or tweak the code can share there..

  2. Ben Says:

    I know they are planning to overhaul their whole way they deliver support. Somewhere in the support forum to post code would be a good idea. I might suggest that to them.

  3. Max Says:

    Thanks for the tip since I’ve been searching for it since a while and have been trying many stuff which didn’t work by the way.
    Nevertheless, the new code you’re supplying seems to overwrite any translation.

Leave a Reply