Difference between revisions of "Order Form Templates"

From WHMCS Documentation

m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
 
+
Order Form Templates define the look and feel of the shopping cart process.
+
Order Form templates define the look and feel of the shopping cart process.
 
+
 
==Built-in Order Form Templates==
 
==Built-in Order Form Templates==
 
+
 
WHMCS ships with several order form templates.
 
WHMCS ships with several order form templates.
 
+
<div class="docs-related-pages">See [[Standard Order Form Templates]] for information on Order Form templates and functionality.</div>
+
* For information on Order Form templates and functionality, see [[Standard Order Form Templates]].
 
+
* For details of deprecated and discontinued order form templates, see [[Discontinued Order Form Templates]].
For details of deprecated and discontinued order form templates, see [[Discontinued Order Form Templates]].
+
 
 
 
==Configuring the Order Form Template==
 
==Configuring the Order Form Template==
 
+
Definition of Order Form templates can occur in two locations.
+
You can set Order Form templates in two locations.
 
+
The first is in '''Setup > General Settings > Ordering'''. This defines the system default order form template directory. By default, this is ''Standard Cart''.
+
* The '''[[Ordering Tab|Ordering]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''. This defines the system default order form template. By default, this is ''Standard Cart''.
 
+
* The product group at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Products and Services|Products/Services]]''' or, prior to WHMCS 8.0, '''Setup > Products/Services'''. To set this, create or edit a product group. Selecting an Order Form template here will override the system default when viewing that product group in the client area. It will also define the styling for the product configuration part of the order process for products and bundles within that group.
There is also an option to configure an Order Form template on a per-product group basis. To do this, navigate to '''Setup > Products/Services > Create/Edit Product Group'''. Selecting an Order Form template here will override the system default when viewing that product group in the client area. It will also define the styling for the product configuration part of the order process for products and bundles within that group.
+
 
+
<div class="docs-alert-warning">
<div class="docs-alert-warning">Note: The view cart and checkout steps will always use the default order form template. This is because the cart can contain products from many different product groups at the same time.</div>
+
The view cart and checkout steps will always use the default order form template. This is because the cart can contain products from many different product groups at the same time.
 
+
</div>
 +
 
===Dynamic Order Form Switching===
 
===Dynamic Order Form Switching===
 
+
You can also specify an order form using a crafted URL. An order form template that you create using this method takes precedence over the system or product group order form template. This will last for the duration of the users visit.
+
You can also specify an order form using a crafted URL. An order form template that you create using this method takes precedence over the system order form template or product group order form template. This will last for the duration of the user's visit.
 
+
To do this, use an URL like <nowiki>http://www.yourdomain.com/whmcs/?carttpl=xxxxx</nowiki>. In this URL, <tt>xxxxx</tt> is the name of the template directory.  
+
To do this, use a URL that resembles <tt>http://www.example.com/whmcs/?carttpl=xxxxx</tt>. In this URL, <tt>xxxxx</tt> is the name of the order form template directory.
 
+
<div class="docs-related-pages">For more information, see [[Linking to WHMCS]].</div>
+
For more information, see [[Linking to WHMCS]].
 
+
 
==Template Files==
 
==Template Files==
 
+
Order Form templates exist in the '''/templates/orderforms/''' directory. Each subdirectory is a different order form template. Within those directories, you will find the following files:
+
Order Form templates exist in the <tt>/templates/orderforms/</tt> directory. Each subdirectory is a different order form template. Within those directories, you will find the following files:
 
+
* <tt>products.tpl</tt> — Lists product categories and products.
+
* <tt>adddomain.tpl</tt> — Begins the process for domain registration-only orders (WHMCS 8.0 and earlier).
* <tt>adddomain.tpl</tt> — Begins the process for domain registration-only orders.
 
 
* <tt>addons.tpl</tt> — Lists the addons a user can order for their existing packages when they log in.
 
* <tt>addons.tpl</tt> — Lists the addons a user can order for their existing packages when they log in.
* <tt>domainrenewals.tpl</tt> — Lists domains in the client's account. This can also allow for domain renewals to in advance.
+
* <tt>domain-renewals.tpl</tt> — Lists domains in the client's account. This can also allow for domain renewals to in advance.
 
* <tt>configureproductdomain.tpl</tt> — Allows domain selection for domains for a specific product.
 
* <tt>configureproductdomain.tpl</tt> — Allows domain selection for domains for a specific product.
 
* <tt>domainoptions.tpl</tt> — For some templates, displays domain availability check results.
 
* <tt>domainoptions.tpl</tt> — For some templates, displays domain availability check results.
* <tt>configureproduct.tpl</tt> — Configures the product before adding it to the cart (for example, thebilling cycle, configurable options, or custom fields).
+
* <tt>checkout.tpl</tt> — Displays checkout page where visitors enter their contact and payment details.
 +
* <tt>common.tpl</tt> — Includes CSS elements specific to the order pages.
 +
* <tt>complete.tpl</tt> — Displays at the end of the checkout process.
 +
* <tt>configureproduct.tpl</tt> — Configures the product before adding it to the cart (for example, the billing cycle, configurable options, or custom fields).
 
* <tt>configuredomains.tpl</tt> — Chooses domain addons, complete custom field requirements, and custom nameservers.
 
* <tt>configuredomains.tpl</tt> — Chooses domain addons, complete custom field requirements, and custom nameservers.
 +
* <tt>domainregister.tpl</tt> — Domain searching and suggestions.
 +
* <tt>domaintransfer.tpl</tt> — Domain transfers eligibility check and EPP code provision.
 +
* <tt>error.tpl</tt> — An error page that's specific to the cart process.
 +
* <tt>fraudcheck.tpl</tt> — Displayed if the client fails a fraud check.
 +
* <tt>linkedaccounts.tpl</tt> — Includes any activated Social [[Sign-In Integrations]].
 +
* <tt>login.tpl</tt> — Displays the login page for existing users (WHMCS 8.0 and earlier).
 +
* <tt>marketconnect-promo.tpl</tt> — Promotes [[MarketConnect]] products when the client views the cart (WHMCS 7.6 and later).
 
* <tt>ordersummary.tpl</tt> — Displays cart contents and product total summaries during the order process.
 
* <tt>ordersummary.tpl</tt> — Displays cart contents and product total summaries during the order process.
* <tt>viewcart.tpl</tt> — Displays cart contents and the checkout process.
+
* <tt>products.tpl</tt> — Lists product categories and products.
* <tt>login.tpl</tt> — Displays the login page for existing users.
+
* <tt>sidebar-categories.tpl</tt> — A sidebar that lists group or contextual product information.
* <tt>complete.tpl</tt> — Displays at the end of the checkout process.
+
* <tt>sidebar-categories-collapsed.tpl</tt> — The <tt>sidebar-categories.tpl</tt> sidebar, collapsed for a smaller viewport.
 
+
* <tt>viewcart.tpl</tt> — Displays cart contents, tax estimators, and promotion code applicators.
 +
 
==Creating a Custom Order Form Template==
 
==Creating a Custom Order Form Template==
 
+
'''Step 1:''' Choose a name. The first step is to create a custom folder to store the custom templates files. This so that they are not overwritten or lost when upgrading. Names must be alphanumeric, all lowercase, and may use underscores.
+
To create a custom order form template:
 
+
'''Step 2:''' Decide how to create your template. If you are running 6.1 and later, we recommend using the parent relationships method (see below). For earlier versions of WHMCS (or if you prefer), copy all the template files from an existing order form template folder. You can then use these as a starting point for the custom order form.
+
# Choose a name. The first step is to create a custom folder to store the custom order form template files. This ensures they are not overwritten or lost when upgrading. Names must be alphanumeric, all lowercase, and may use underscores.
 
+
# Decide how to create your order form template. If you are running WHMCS 6.1 and later, we recommend using the parent relationships method (see below). For earlier versions of WHMCS, copy all the order form template files from an existing order form template folder. You can then use these as a starting point for the custom order form.
 +
 
===Parent Relationships===
 
===Parent Relationships===
 
+
To make upgrading and maintaining order form customisations easier, Order Form templates support parent-child relationships. This allows an order form that inherits template files from another directory. It will end the need to create a custom copy of all twelve template files. Only create the pages that need customisation. The remaining templates will then load from the parent order form when you define them.
+
To make upgrading and maintaining order form template customisations easier, Order Form templates support parent-child relationships. This allows an order form that inherits template files from another directory. It will end the need to create a custom copy of all of the template files. Only create the pages that need customisation. The remaining order form templates will then load from the parent order form when you define them.
 
+
By leveraging this functionality, a developer can create templates that are simple and easy to maintain. The system updates any changes to template files that aren't customised when you upgrade.
+
By leveraging this functionality, a developer can create order form templates that are simple and easy to maintain. When you upgrade, the system updates any changes to order form template files that aren't customised.
 
+
For example:
+
For example, the '''Standard Cart''' order form template is the parent for the '''Premium Comparison''' order form template. '''Premium Comparison''' consists only of a <tt>products.tpl</tt> order form template file. So, all other steps of the order process use order form templates and design from '''Standard Cart'''.
 
+
The ''Standard Cart'' order form template is the parent for the ''Premium Comparison'' template. Premium Comparison consists only of a products.tpl template file. So, all other steps of the order process use templates and design from the Standard Cart.
 
 
 
 
<div class="docs-alert-info">
 
<div class="docs-alert-info">
<span class="title">TIP: </span><br />
+
<span class="title">Template Locations</span><br />
* The "Standard Cart" order form template is under '''Setup > General Settings > Ordering tab'''.
+
* '''Standard Cart''' is in the '''[[Ordering Tab|Ordering]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''.
* The "Premium Comparison" order form is for the product groups that will use its product selection page at '''Setup > Products/Services > Products/Services > Edit Group'''.
+
* '''Premium Comparison''' is for the product groups that will use its product selection page at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Products and Services|Products/Services]]''' or, prior to WHMCS 8.0, '''Setup > Products/Services > Products/Services'''.
 
</div>
 
</div>
 
+
 
===Creating a New Template based on a Parent===
 
===Creating a New Template based on a Parent===
 
+
<div class="docs-alert-info">We only support this in WHMCS 6.1.0 and later.</div>
+
<div class="docs-alert-info">
 
+
We only support this in WHMCS 6.1.0 and later.
After creation of a custom order form template, WHMCS needs to know the parent template. Create a YAML file within the new directory to do this. Name the YAML file ''theme.yaml'' and include the following:
+
</div>
 
+
<source lang="yaml">
+
After creation of a custom order form template, you must specify the parent order form template. To do this, create a YAML file within the new directory. Name the YAML file <tt>theme.yaml</tt> and include the following code:
config:
+
    parent: standard_cart
+
<div class="source-cli">
</source>
+
<br/>config:
 
+
<br/>    parent: standard_cart
In the above example, "standard_cart" is the name of the parent template we're using.
+
</div>
 
+
At this stage the new order form template is ready. Activation via the Ordering tab of General Settings is possible. Selection of the custom order form template name within the configuration area for a specific product group is also possible.
+
In the above example, <tt>standard_cart</tt> is the name of the parent template we're using.
Now let's look at how we would customise a step of the order process.
+
 
+
At this stage, the new order form template is ready. You can activate it in the '''[[Ordering Tab|Ordering]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''. You can also now select the custom Order Form template name within the configuration area for a specific product group.
#Begin by identifying the name of the template file that controls the step a developer will customise. See the list above for help.
+
#Copy that template file from the defined parent template to the new template directory.
+
If you want to customize a step in the ordering process, follow these steps:
#Make the desired changes to the copy within the custom template directory.
+
#Enable the new order form to see it in action. The custom order form will load the step that has had customisation. Other steps will load from the parent order form template. Usually, the parent template would be the system default, in Setup > General Settings > Ordering tab.
+
# Identify the order form template file that controls the step you want to customize.
 
+
# Copy that order form template file from the defined parent order form template to the new directory.
Selection of the custom template would then occur in the necessary product groups in Setup > Products/Services > Products/Services > Edit Group.
+
# Make the desired changes to the copy within the custom order form template directory.
 
+
# Enable the new order form template. The custom order form template will load the step that has had customization. Other steps will load from the parent order form template. Usually, the parent order form template is the system default in the '''[[Ordering Tab|Ordering]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''.
 +
 +
Then, select the custom order form template in the necessary product groups in '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > [[Products and Services|Products/Services]]''' or, prior to WHMCS 8.0, '''Setup > Products/Services > Products/Services'''.
 +
 
==Third Party Order Conversion/Affiliate Tracking==
 
==Third Party Order Conversion/Affiliate Tracking==
 
+
On checkout completion, and after customer payment, a client will see the Order Completed Page. The complete.tpl file in the active order template folder controls this. For example, this could occur if a third party conversion tracking or affiliate system needs to execute JavaScript after checkout.
+
After checkout and payment, a client will see the '''Order Completed''' page. The <tt>complete.tpl</tt> file in the active order form template directory controls this. This file contains an <tt>{if $ispaid}{/if}</tt> section, as in the example below. Code inside those tags runs once a customer pays for an order. Code outside runs regardless of payment status.
 
+
This file contains an <tt>{if $ispaid}{/if}</tt> section, as in the example below. Code inside those tags runs once a customer pays for an order. Code outside runs regardless of payment status.
 
 
 
 
<source lang="php">
 
<source lang="php">
 
{if $ispaid}
 
{if $ispaid}
 
Enter any HTML code which needs to be displayed once a user has
 
Enter any HTML code which needs to be displayed once a user has
completed the checkout of their order here - for example
+
completed the checkout of their order here - for example
 
conversion tracking and affiliate tracking scripts
 
conversion tracking and affiliate tracking scripts
 
{/if}
 
{/if}
 
</source>
 
</source>
 
+
 
<div class="docs-alert-info">
 
<div class="docs-alert-info">
Many variables, including {$orderid}, {$ordernumber}, and {$amount}, are available. Use these where necessary to fill in order details.
+
Many variables, including <tt>{$orderid}</tt>, <tt>{$ordernumber}</tt>, and <tt>{$amount}</tt>, are available. Use these where necessary to fill in order details.
 
</div>
 
</div>

Latest revision as of 20:53, 26 April 2022

Introduction

Order Form templates define the look and feel of the shopping cart process.

Built-in Order Form Templates

WHMCS ships with several order form templates.

Configuring the Order Form Template

You can set Order Form templates in two locations.

  • The Ordering tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings. This defines the system default order form template. By default, this is Standard Cart.
  • The product group at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services. To set this, create or edit a product group. Selecting an Order Form template here will override the system default when viewing that product group in the client area. It will also define the styling for the product configuration part of the order process for products and bundles within that group.

The view cart and checkout steps will always use the default order form template. This is because the cart can contain products from many different product groups at the same time.

Dynamic Order Form Switching

You can also specify an order form using a crafted URL. An order form template that you create using this method takes precedence over the system order form template or product group order form template. This will last for the duration of the user's visit.

To do this, use a URL that resembles http://www.example.com/whmcs/?carttpl=xxxxx. In this URL, xxxxx is the name of the order form template directory.

For more information, see Linking to WHMCS.

Template Files

Order Form templates exist in the /templates/orderforms/ directory. Each subdirectory is a different order form template. Within those directories, you will find the following files:

  • adddomain.tpl — Begins the process for domain registration-only orders (WHMCS 8.0 and earlier).
  • addons.tpl — Lists the addons a user can order for their existing packages when they log in.
  • domain-renewals.tpl — Lists domains in the client's account. This can also allow for domain renewals to in advance.
  • configureproductdomain.tpl — Allows domain selection for domains for a specific product.
  • domainoptions.tpl — For some templates, displays domain availability check results.
  • checkout.tpl — Displays checkout page where visitors enter their contact and payment details.
  • common.tpl — Includes CSS elements specific to the order pages.
  • complete.tpl — Displays at the end of the checkout process.
  • configureproduct.tpl — Configures the product before adding it to the cart (for example, the billing cycle, configurable options, or custom fields).
  • configuredomains.tpl — Chooses domain addons, complete custom field requirements, and custom nameservers.
  • domainregister.tpl — Domain searching and suggestions.
  • domaintransfer.tpl — Domain transfers eligibility check and EPP code provision.
  • error.tpl — An error page that's specific to the cart process.
  • fraudcheck.tpl — Displayed if the client fails a fraud check.
  • linkedaccounts.tpl — Includes any activated Social Sign-In Integrations.
  • login.tpl — Displays the login page for existing users (WHMCS 8.0 and earlier).
  • marketconnect-promo.tpl — Promotes MarketConnect products when the client views the cart (WHMCS 7.6 and later).
  • ordersummary.tpl — Displays cart contents and product total summaries during the order process.
  • products.tpl — Lists product categories and products.
  • sidebar-categories.tpl — A sidebar that lists group or contextual product information.
  • sidebar-categories-collapsed.tpl — The sidebar-categories.tpl sidebar, collapsed for a smaller viewport.
  • viewcart.tpl — Displays cart contents, tax estimators, and promotion code applicators.

Creating a Custom Order Form Template

To create a custom order form template:

  1. Choose a name. The first step is to create a custom folder to store the custom order form template files. This ensures they are not overwritten or lost when upgrading. Names must be alphanumeric, all lowercase, and may use underscores.
  2. Decide how to create your order form template. If you are running WHMCS 6.1 and later, we recommend using the parent relationships method (see below). For earlier versions of WHMCS, copy all the order form template files from an existing order form template folder. You can then use these as a starting point for the custom order form.

Parent Relationships

To make upgrading and maintaining order form template customisations easier, Order Form templates support parent-child relationships. This allows an order form that inherits template files from another directory. It will end the need to create a custom copy of all of the template files. Only create the pages that need customisation. The remaining order form templates will then load from the parent order form when you define them.

By leveraging this functionality, a developer can create order form templates that are simple and easy to maintain. When you upgrade, the system updates any changes to order form template files that aren't customised.

For example, the Standard Cart order form template is the parent for the Premium Comparison order form template. Premium Comparison consists only of a products.tpl order form template file. So, all other steps of the order process use order form templates and design from Standard Cart.

Template Locations

  • Standard Cart is in the Ordering tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.
  • Premium Comparison is for the product groups that will use its product selection page at Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/Services.

Creating a New Template based on a Parent

We only support this in WHMCS 6.1.0 and later.

After creation of a custom order form template, you must specify the parent order form template. To do this, create a YAML file within the new directory. Name the YAML file theme.yaml and include the following code:


config:
parent: standard_cart

In the above example, standard_cart is the name of the parent template we're using.

At this stage, the new order form template is ready. You can activate it in the Ordering tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings. You can also now select the custom Order Form template name within the configuration area for a specific product group.

If you want to customize a step in the ordering process, follow these steps:

  1. Identify the order form template file that controls the step you want to customize.
  2. Copy that order form template file from the defined parent order form template to the new directory.
  3. Make the desired changes to the copy within the custom order form template directory.
  4. Enable the new order form template. The custom order form template will load the step that has had customization. Other steps will load from the parent order form template. Usually, the parent order form template is the system default in the Ordering tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.

Then, select the custom order form template in the necessary product groups in Configuration () > System Settings > Products/Services or, prior to WHMCS 8.0, Setup > Products/Services > Products/Services.

Third Party Order Conversion/Affiliate Tracking

After checkout and payment, a client will see the Order Completed page. The complete.tpl file in the active order form template directory controls this. This file contains an {if $ispaid}{/if} section, as in the example below. Code inside those tags runs once a customer pays for an order. Code outside runs regardless of payment status.

{if $ispaid}
Enter any HTML code which needs to be displayed once a user has
completed the checkout of their order here - for example
conversion tracking and affiliate tracking scripts
{/if}

Many variables, including {$orderid}, {$ordernumber}, and {$amount}, are available. Use these where necessary to fill in order details.