Page 1 of 1

Hide Shipping Address with JQueryTools

Posted: Fri Jul 23, 2010 7:15 pm
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}

Re: Hide Shipping Address with JQueryTools

Posted: Wed Sep 22, 2010 9:05 am
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...

Re: Hide Shipping Address with JQueryTools

Posted: Thu Oct 14, 2010 7:01 pm
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.