Hide Shipping Address with JQueryTools

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
kendo451

Hide Shipping Address with JQueryTools

Post by kendo451 »

For the orders module Billing template, it's handy to hide the Shipping Address form unless the User wants to change it.  I use JQueryTools to achieve this:

1. In the Orders Billing template, wrap a div around the Shipping Address section and give it an id, like so:

Code: Select all

<div id="shippingaddress">
  <!-- shipping address section goes here /-->
</div>
Then I call JQueryTools with the following content block:

Code: Select all

{JQueryTools action='incjs' include=''}
{literal}
<__script__ type="text/javascript">
//on page load
$(document).ready(function() {
	// Hide Shipping Address by Default then inject checkbox
	$("#shippingaddress").hide().before('<p><strong>Shipping Address is same as Billing:</strong><input id="copyaddress" type="checkbox" name="same_as_billing" checked=checked /></p>');
	// toggle #shippingaddress form when the checkbox is checked or unchecked
    $("#copyaddress").click(function () {
		$("#shippingaddress").toggle();
	});
});
</__script>  
{/literal}
harmh
Forum Members
Forum Members
Posts: 84
Joined: Tue Aug 24, 2010 7:37 am

Re: Hide Shipping Address with JQueryTools

Post by harmh »

Hi kendo451!

How do you place de JQueryTools content block? Do I have to place in in te content field or de billing template?

I hope you kan explane...
kendo451

Re: Hide Shipping Address with JQueryTools

Post by kendo451 »

In my templates I put this at the bottom of each page just above

{JQueryTools action='incjs'  [include='whatever plugins you want'}
{content block='page_scripts'}

On a page showing fancybox or whatever, I put the fancybox initialization code in the  page_scripts field for the page that hosts the module.
Post Reply

Return to “Tips and Tricks”