2

Probably simple but I have a custom field that I would like to add to the Orders channel and then use that value in the customer notification email.

This field will not be populated by the customer, it's a custom date field that the admin has set for a course.

In the add to cart form I have:

<input type="hidden" name="date_booked_for" value="{course_date}" /> 

where the date_booked_for is the new field in the Orders Channel and course_date is the custom field that needs to be passed to checkout and then the email.

Stuck on the hidden field part in the checkout form and email notification.

Any ideas please?

TIA

0

let's try storing the date_booked_for as custom item_options data

in your add to cart form replace this line...

<input type="hidden" name="date_booked_for" value="{course_date}" /> 

with this

<input type="hidden" name="item_options[date_booked_for]" value="{course_date}" />

and in your email notification template you can output the custom item option within the order_items tag pair as shown below

{exp:cartthrob:submitted_order_info}
    {order_items}
        {item:date_booked_for}
    {/order_items}
{/exp:cartthrob:submitted_order_info}
1
  • That is perfect - thank you so much for taking the time to help this EE newbie ;)
    – moondawg
    Feb 16 '13 at 12:06
0

In your form use:

<input type="hidden" name="date_booked_for" value="custom_data[course_date]" /> 

In your email use:

{custom_data:course_date}
0
0

Thank you Anna but it's not working, I tried that myself before I posted. It just renders in the outputted HTML:

<input type="hidden" name="date_booked_for" value="custom_data[course_date]" /> 

I can see in the source for the page where the add to form is that the date is placed in the hidden field value. The flow is to then visit the cart and then checkout.

But: <input type="hidden" name="date_booked_for" value="custom_data[course_date]" />

is not populating that hidden fields value in the checkout form?

4
  • In the future, you can add your replies as a comment under the answer as opposed to posting a new answer.
    – mjr
    Feb 14 '13 at 21:50
  • But in Safari when I want a new paragraph, it posts the comment :(
    – moondawg
    Feb 14 '13 at 22:41
  • hmm guess paragraphs don't work so well in comments
    – mjr
    Feb 15 '13 at 4:23
  • can you post the template code for your add to cart form and your confirmation page?
    – mjr
    Feb 15 '13 at 4:25
0

Hi mjr and thank you for taking the time to answer.

That is correct, I have that custom field in my orders channel.

I have a Structure listings page with a a cartThrob add to form call with a hidden field:

Which works as I can see the rendered HTML as:

The user adds to cart and then if they wish, view the cart and checkout.

On the checkout template I have added your suggestion and no joy and nothing is rendered in the email confirmation OR entered in the Orders channel.

Just to repeat, this course_date is entered by the site admin, it is not at any time chosen as an item option by the user. I just want to take that entries custom date field and use it in the email confirmation.

TIA

0

Thanks - here is the code as requested for the add to cart section:

    {exp:channel:entries channel="domestic_courses" disable="categories|member_data|pagination" status="open|featured"}
<div class="row">
<!-- start 8 cols --> 
<div class="eight columns">
<section class="box">
<div class="frame">
<h1 class="intro">{title}<h1>
<div class="row padding-bottom-10">
<div class="five columns"><img src="{domestic_course_image}" class="intro-image" />
<ul class="course-list">
<li><strong>Cost (inc VAT):</strong> {course_price:plus_tax decimals="2"}</li>
<li><strong>Course Length:</strong> {course_length}</li>
{if {places} > 0}
<li>There are {places} place/s remaining.</li>
{if:else}
<li class="full">This course is fully booked.</li>
{/if}
</ul>
</div>
<div class="seven columns">
<p class="large-text">{domestic_course_summary}</p>
{full_domestic_course_details}
</div>
</div>

<div class="row">
<div class="twelve columns padding-bottom-10">
<h4 class="info-label">Enter amount of places required below:</h4>
</div>
{exp:cartthrob:add_to_cart_form entry_id="{entry_id}" return="" error_handling="inline" required="quantity"}
<input type="hidden" name="date_booked_for" value="{course_date}" /> 
<div class="one column">
<input type="text" name="quantity" value="">
</div>
<div class="eleven columns">
{if field_errors_exist}
<ul class="errors">
    {field_errors}
    <li>{error}</li>
    {/field_errors}
</ul>
{/if}
{if global_errors_exist}
<ul class="errors">
    {global_errors}
    <li>{error}</li>
    {/global_errors}
</ul>
{/if} 
<div class="message">Updating... </div>
<input type="submit" id="go" class="but yellow normal-but light-border" value="BOOK NOW"></div>
</div>
{/exp:cartthrob:add_to_cart_form}
{/exp:channel:entries}

And the checkout code:

{exp:cartthrob:checkout_form secure_action="yes" error_handling="inline" class="custom" create_user="no" group_id="5" return="store/order_info" required="first_name|last_name|address|city|address|state|zip|phone|email_address"}
<input type="hidden" name="custom_data[date_booked_for]" value="{course_date}" />
{exp:cartthrob:customer_info}
<fieldset class="billing" id="billing">
<legend>Billing Info</legend>
<div class="row">
    <div class="six columns">
     <label for="customer_first_name" >First Name</label><input type="text" name="first_name" value="{customer_first_name}" id="customer_first_name" {if error:first_name} class="required" {/if} />
    </div>
    <div class="six columns">
    <label for="customer_last_name" >Last Name</label><input type="text" name="last_name" value="{customer_last_name}" id="customer_last_name" {if error:last_name} class="required" {/if} />
    </div>
  </div>
<div class="row">
    <div class="six columns">
     <label for="customer_address" >Address</label><input type="text" name="address" value="{customer_address}" id="customer_address" {if error:address} class="required" {/if}  />
    </div>
    <div class="six columns">
    <label for="customer_address2">Address 2</label><input type="text" name="address2" value="{customer_address2}" id="customer_address2"  />
    </div>
  </div>
<div class="row">
    <div class="four columns">
     <label for="customer_city">City</label>
     <input type="text" name="city" value="{customer_city}" id="customer_city" {if error:city} class="required" {/if}   />
    </div>
    <div class="eight columns">
    <label for="customer_county">County</label>
    <input type="text" name="state" value="{state}" id="state" {if error:state} class="required"{/if} />


    </div>
  </div>
<div class="row">
<div class="four columns">
<label for="Postcode">Postcode</label><input type="text" name="zip" value="{customer_zip}" id="Postcode" {if error:zip} class="required" {/if}   />
</div>
<div class="eight columns">
<label for="customer_country_code" >Country</label>
<select name="customer_country_code"  id="customer_country_code" >
<option value="GBR" selected="selected">United Kingdom</option>
</select>
</div>
<div>
</fieldset>
<fieldset class="shipping" id="shipping">
<legend>Shipping</legend>
<div class="row small-info-area">
<div class="twelve columns">
<div class="six columns"><label for="use_billing_info"><strong>Use same billing details for shipping?</strong> <input type="radio" value="yes" name="use_billing_info" /></label></div>
</div>
</div>
<div class="row">
    <div class="six columns margin-top-10">
     <label for="shipping_first_name" >Shipping First Name</label><input type="text" name="shipping_first_name" value="{shipping_first_name}" id="shipping_first_name" />
    </div>
    <div class="six columns margin-top-10">
    <label for="shipping_last_name" >Shipping Last Name</label><input type="text" name="shipping_last_name" value="{shipping_last_name}" id="shipping_last_name"/>
    </div>
  </div>
<div class="row">
    <div class="six columns">
     <label for="shipping_address" >Shipping Address</label><input type="text" name="shipping_address" value="{shipping_address}" id="shipping_address" />
    </div>
    <div class="six columns">
    <label for="shipping_address2" class="">Shipping Address (line 2)</label><input type="text" name="shipping_address2" value="{shipping_address2}" id="shipping_address2"  />
    </div>
  </div>
<div class="row">
    <div class="four columns">
     <label for="shipping_city" >City</label><input type="text" name="shipping_city" value="{shipping_city}" id="shipping_city" />
    </div>
    <div class="eight columns">
    <label for="shipping_state">County</label>
    <input type="text" name="shipping_state" value="{shipping_state}" id="shipping_state" />

    </div>
  </div>
<div class="row">
<div class="four columns">
<label for="shipping_zip" class="">Shipping Postcode</label><input type="text" name="shipping_zip" value="{shipping_zip}" id="shipping_zip"/>
</div>
<div class="eight columns">
<label for="shipping_country_code" class="">Shipping Country</label><select name="shipping_country_code"  id="shipping_country_code">
<option value="GBR" selected="selected">United Kingdom</option>
</select>
</div>
</div>
</select>
</fieldset>
<fieldset class="additional_info" id="additional_info">
<legend>Additional Info</legend>
<div class="row">
<div class="six columns">
<label for="phone" class="">Phone</label><input type="text" name="phone" value="{phone}" id="phone" {if error:phone} class="required" {/if}  />
</div>
<div class="six columns">
<label for="email_address" class="">Email Address</label><input type="text" name="email_address" value="{email_address}" id="email_address" {if error:email_address} class="required" {/if} />
</div>
</div>
<div class="row">
<div class="twelve columns">
<label for="requirements" class="">Any dietary requirements or additional message?</label><textarea name="requirements" value="{requirements}" id="requirements"></textarea>
</div>
</div>
</fieldset>

<input type="submit" id="checkout_complete" class="but normal-but yellow" value="Confirm Booking" />
{custom_data:phone}

{/exp:cartthrob:customer_info}

{/exp:cartthrob:checkout_form}

For now, I would just like to concentrate getting this hidden field in the Orders Channel, if that works, I can get it in the email confirmation.

TIA again.

1
  • Thanks for the code, I updated my previous answer with a new code sample
    – mjr
    Feb 15 '13 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.