I want to collect a users postal code from the form input on the onepage checkout and show the result in a later checkout step before they submit the order.
<input type="text" class="input-text validate-zip-international required-entry validation-passed" value="" id="billing:postcode" name="billing[postcode]" title="Zip/Postal Code">
What is the best way of achieving this please?
Best Answer
You could use JavaScript/jQuery to fetch those values from the input fields and write them to your review area.
I did this in the past, for a custom one page checkout, so it may require some tweaking for your needs. You just need to make this an onClick event on the continue button, if I remember what I did correctly.
Update
If you just want the postal code, the code above stores it in the variable shippingPostalCode, if they opted to use a separate shipping address, and just plucks the value from the input field if they use the same billing/shipping info. You can send just the postal code to be written the same way, like so:
Just replace "shipping_post_code_html_element" with the id of the html element you're wanting to write it to.
Similarly, for the else statement (where I'm using the billing data in the case that shipping/billing are the same), I'd put the billing zip code in a variable, just to make the code look nicer, and change it to something like this:
I updated the code above, too, so you can just pick out the pieces you don't need.