Documentation You are here: start » v » 0.7.0 » checkout

This is an old revision of the document!


The Most Efficient One-Page Checkout Available

What Is the Checkout?

When we refer to the “checkout” we refer to the page (or pages, in other systems) where the customer enters their billing and payment information, and where they submit their order for processing. In general, the cart comes before the checkout, and the receipt is displayed when a successful checkout is processed.

How and Why FoxyCart's Checkout Is Different

One of the major piece we wanted to simplify and improve upon when we started FoxyCart was the checkout page. In addition to making it a very dynamic one-page checkout, we also revolutionized (big hypey word, we know, but we feel it's true) the way customers choose between a guest checkout or creating an account.

No longer will your customers be presented with inputs for their email and password, only to submit the form and be told that they don't have a user, and that if they'd like to register they can click the teeny tiny link in the bottom right. Odds are they don't care about registering; they just want to buy your wares as quickly as possible. Our unique approach automatically determines whether the customer has an account, and also presents easy options to checkout as a guest user if desired (and configured for your store).

The checkout is also highly flexible, and can be modified in a variety of ways. HTML, CSS, and JavaScript are all available for you to perform advanced customizations both of the design and the functionality.

Checkout Template Customization

The checkout can be quickly, easily, and automatically styled to match your existing site's templates. This is care of “AutoMagiCache”. There are screencasts, examples, and lots of documentation about customizing your checkout template. And really, it's quite easy and automatic, so we strongly recommend reviewing the screencasts. A customized checkout can significantly boost conversion rates, so it's likely well worth your time to style your FoxyCart-powered checkout to match your site.

Errors On the Checkout

"Hard" Errors

Any “hard” errors will be displayed for your customers (and in your store's error log), and will generally be supplied by your payment gateway for things like a declined card, a mismatched billing address, or other issues that impact payment. See Errors and What To Do About Them for more info.

"Soft" Errors

FoxyCart's checkout also employs JavaScript validation to provide for quick feedback if a required field is left empty, if a shipping option is unselected, an email address malformed, or etc. These errors will not show up in your store's error log.

Other Errors and Unexpected Behavior

Because the checkout is complex, there are a variety of things that can go wrong if you're customizing things. If things aren't happening as expected…

  • Check for JavaScript errors using Firebug or the comparable debugging system in your browser of choice.
  • Check for required fields you may have hidden via CSS.
  • Make sure your checkout template has a doctype, and is free of major validation errors.
  • Post on our forum for additional help.

Adding Custom Checkout Fields

Overview

Sometimes it is necessary or desirable to include additional input fields on checkout, such as:

  • Checkbox to require Terms of Service agreement.
  • Checkbox to opt-in to a mailing list.
  • Input field for a referrer code.
  • Checkbox to “send as a gift”, with a text area for a gift card note.
  • Input field for date of birth.

It's (relatively) easy to add custom fields to your FoxyCart checkout page, providing you know some HTML. In a nutshell, any code you insert in between the tags ^^custom_begin^^ and ^^custom_end^^ will be inserted in your checkout page, in between a container div#fc_custom_fields_container.

An Example

Here's a basic example of the above functionality. It doesn't matter where you put this code. It will be moved into the checkout form when FoxyCart loads your checkout page, so it can be after the </body> or </html> tags if you want.

^^custom_begin^^
 
<h2>Additional Information</h2>
 
<fieldset id="fc_custom_fields">
	<legend>Additional Information</legend>
	<div class="fc_inner">
		<div>
			<h4>Updates</h4>
			<input type="checkbox" name="Update_List" value="yes" checked="checked" />
			<label for="Update_List">Leave this box checked to receive occasional updates about our products. We will not share your email address, and you can unsubscribe at any time.</label>
 
		</div>
		<div>
			<h4>Comments?</h4>
			<p>If you have any comments about your order, or about our checkout process, please let us know.</p>
			<textarea name="Comments" cols="35" rows="6"></textarea>
		</div>
	</div><!-- .fc_inner -->
</fieldset><!-- #fc_custom_fields -->
 
^^custom_end^^

This code will then be inserted in your checkout page, below the address fieldsets and above the shipping fieldset. It will be wrapped in a container div, like this:

<div id="fc_custom_fields_container" class="fc_fieldset_container">
 
<h2>Additional Information</h2>
 
<fieldset id="fc_custom_fields">
	<legend>Additional Information</legend>
	<div class="fc_inner">
		<div>
 
			<h4>Updates</h4>
			<input type="checkbox" name="Update_List" value="yes" checked="checked" />
			<label for="Update_List">Leave this box checked to receive occasional updates about our products. We will not share your email address, and you can unsubscribe at any time.</label>
 
		</div>
		<div>
			<h4>Comments?</h4>
			<p>If you have any comments about your order, or about our checkout process, please let us know.</p>
			<textarea name="Comments" cols="35" rows="6"></textarea>
 
		</div>
	</div><!-- .fc_inner -->
</fieldset><!-- #fc_custom_fields -->
 
</div><!-- #fc_custom_fields_container -->

What to name your fields

You can name your fields anything you want, but we recommend using the underscore (_) for spaces, and capitalizing your input names as you'd like them displayed. For all receipts, we will convert underscores to spaces for you.

For example, if you have <input name=“Update_List” />, it will be displayed in your receipt (and email receipts) as Update List.

What about Receipts and the Datafeeds?

The custom fields will be inserted at the bottom of your your receipt (after checkout), as well as in any emails that include the ^^receipt^^ placeholder.

Custom checkout fields are included in all XML datafeeds from version 0.3.

What if I'm using multiship and I need a custom field per shipto?

No problem! Just wrap your custom fields in ^^multiship_custom_begin^^ and ^^multiship_custom_end^^ and you're good to go.

A Note about Checkboxes

Checkboxes do not post if they are unchecked. This is standard HTML form behavior, but it's worth noting, especially if you're using checkboxes for your XML datafeeds.

Required Fields

You can required a custom field by adding fc_required to its class (of the input). You can add an error message (which will display if it's left blank) by adding a label.fc_error with for=“your_field_name”, like this:

<label class="fc_error" style="display: none;" for="terms_of_service">Please accept our Terms of Service.</label>

For example, if you wanted to force a Terms of Service acceptance, it'd look like this:

^^custom_begin^^
 
<h2>Additional Information</h2>
 
<fieldset id="fc_custom_fields">
	<legend>Additional Information</legend>
	<div class="fc_inner">
		<div>
			<h4>Terms of Service</h4>
			<input type="checkbox" name="terms_of_service" value="accept" checked="checked" class="fc_required" />
			<label for="terms_of_service">By checking this box you agree to our <a href="http://www.YOURDOMAIN.com/tos">Terms of Service</a>.</label>
			<label class="fc_error" style="display:none;" for="terms_of_service">You must accept our Terms of Service to complete this transaction.</label>
		</div>
		<div>
			<h4>Comments?</h4>
			<p>If you have any comments about your order, or about our checkout process, please let us know.</p>
			<textarea name="Comments" cols="35" rows="6"></textarea>
		</div>
	</div><!-- .fc_inner -->
</fieldset><!-- #fc_custom_fields -->
 
^^custom_end^^

"Sensitive" Custom Checkout Fields

By default, all custom checkout fields will be emailed as part of the email receipt sent to both the customer and the store's email address. Emailing sensitive information is a Bad, Bad Idea. If you aren't familiar with the reasons why, please read our Security Primer for more info. If you do need to collect information that you do not want to be emailed, such as Social Security Numbers or other sensitive data, you can prefix your field names with h:, like this:

Please enter your Social Security Number: <input type="text" name="h:social_security_number" />

“Sensitive” fields are displayed in the admin's transaction view, and are sent in the XML, but are not emailed.

You should not be collecting passwords using custom fields, as they will be stored in cleartext and not hashed in our system. Though we work hard to keep our systems secure, it's just not a good idea to store passwords without a strong hashing algorithm.

Other Checkout Actions

The checkout is primarily used to pay for new purchases, but there are certain other situations that arise that are still handled through the checkout. It's important to understand when your checkout can be used for other purposes so you can design and style accordingly.

Subscription Cancellation

An example of a subscription cancellation checkout page If you're doing recurring billing you may likely be using sub_cancel links in your email receipts, which will allow your customers to follow a sub_token link with sub_cancel=true. This will immediately redirect the customer to your checkout, but it is a highly streamlined checkout experience geared only towards allowing your customer to cancel their subscription. As you can see in the example to the right, the checkout includes just three main pieces:

  1. The normal email + password authentication section.
  2. The cart.
  3. The button that is normally labelled something like “checkout” or “confirm your order”, but is now labelled “Cancel My Subscription”. (This text can be modified in your store's language section.)

It is important to note that the password is still required in order to confirm the cancellation. This is to prevent an unauthorized user from modifying a subscription they aren't supposed to be modifying.

"Update Info" Requests

If the cart parameter is set to updateinfo, the cart will immediately redirect to the checkout in “updateinfo” mode. Simply put, this will process an empty transaction, thus allowing the customer to update their password, address(es), or payment info. This updated information will be sent in a transaction datafeed, but the payment gateway will not be contacted during this checkout.

The updateinfo process can be useful in certain situations, but especially if you're handling subscriptions you'll likely want to use the sub_token rather than the updateinfo approach.

Site Tools