Passing Session Variables to Email

damienkeedamienkee Member
in Help edited March 2012
Hi, I'm setting up a ticketing page for our local theatre group and am having a few issues transferring session variables through to the email confirmation.

We're using session variables to indicate what date the performance is on, rather than having all 10 performance dates as properties for each ticket type.

I can successfully pass and display the session variable on the checkout page, but cannot seem to populate the fc_custom_fields inputs so that they go through to the email.

I am no expert in jQuery (but am quickly learning!) but this one has me a little stumped. In a nutshell, how do I replace the ??? (which do go through to the email) with the variables I pull out of the JSON object? Hove been trying variation sof the val() and html() but am sure I've got the syntax wrong.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">;

<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
	<title>^^store_name^^ Checkout</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="https://^^store_domain^^/themes/standard/styles.css"; type="text/css" media="screen" charset="utf-8" />

<!-- INSERT Custom fields into checkout -->
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function() {
     var performance = fc_json.custom_fields.performance;
     $('div.performance_holder').html(performance);
     var seating = fc_json.custom_fields.seating;
     $('div.seating').html(seating);
});
</script>

</head>

<body id="checkout">
	<div id="pageContainer" style="width:760px; margin:0px auto;">

<br><br><br>

		^^cart^^
		^^checkout^^
^^custom_begin^^
<h2>Additional Information</h2>
<p>Show Selected: <div class="performance_holder"></div>
<p>Preferred Seating : <div class="seating"></div>
<fieldset id="fc_custom_fields">
<div>
<input type="hidden" name="performance_email" value="??">
<input type="hidden" name="seating_email" value="???"

</div>
</div><!-- .fc_inner -->
</fieldset><!-- #fc_custom_fields -->
^^custom_end^^

	</div>
</body>
</html>

Full link here if it helps - www.savoyards.squarespace.com/tickets

Any help would be greatly appreciated!

Regards
Damien Kee

Comments
  • lukeluke FoxyCart Team
    Hey Damien. The easiest way is to give your inputs id's like so:
    <input type="hidden" id="performance_email" name="performance_email" value="???" />
    <input type="hidden" id="seating_email" name="seating_email" value="???" />
    

    And then update the jQuery:
    var performance = fc_json.custom_fields.performance;
    jQuery('div.performance_holder').html(performance);
    jQuery('#performance_email').val(performance);
    var seating = fc_json.custom_fields.seating;
    jQuery('div.seating').html(seating);
    jQuery('#seating_email').val(seating);
    

    Hope that helps.
  • Luke, you rock!!!! :)

    Next step, can I edit the ^^cart^^ placeholder? (I've looked but pretty sure I can't). I don't want to include the line items 'Category' and 'Group Total' as I think they're not relevant to us (and the word 'Group' has different meaning to us which will be very confusing.)

    The option I'm exploring now is doing a for loop to check through all the products, pick out the ones that have non-zero quantities and send them through to the email like I've done with the session variables.

    Let me know if you think there is a better way.

    Regards
    Damien Kee
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    If you want to do further customization of the email receipt I think you'll need to go this route: http://wiki.foxycart.com/integration/foxycart/custom_receipt
  • Thanks Sparkweb, I did look at that, but it doesn't handle custom fields :(
  • fc_adamfc_adam FoxyCart Team
    @damienkee,

    I believe that limitation is just because it was built for an old version of the XML datafeed. Newer versions of FoxyCart will include custom fields in the XML datafeed. The script would just need to be adapted to match the current XML datafeed as displayed here: http://wiki.foxycart.com/static/redirect/xml_datafeed
  • lukeluke FoxyCart Team
    @damienkee: you can also use the "language" section of the admin to customize that text however you like. Additionally, you can use jQuery to hide things you don't want, though that would obviously only work for the cart, checkout and receipt, not the actual email.

    Hope that helps.
Sign In or Register to comment.