ModularMerchant
Knowledge Base
Shopping Cart Software Online Manual
Setup a redirect in a store template using PHP
Search Email Series Troubleshooting stuck outgoing emails
Location Home > Shopping Cart Software Components

Setup a redirect in a store template using PHP

quote
How can I force my store's home page to redirect straight to the checkout page instead? I use the store's "Add to Cart" links on my other website, and only need the customer to get to the checkout page in my store. Please advise.

This is a fairly easy task to accomplish, and will only require a little bit of PHP code in the template that controls the home page.

please note:
Troubleshooting custom code in templates does fall outside of Modular Merchant's range of free technical support. (Modular Merchant's Spheres of Support is available at: http://www.modularmerchant.com/sos/)

We're always happy to help when we can, but fixing larger template issues may require paid development time. We evaluate each request on a case-by-case basis. If a request is so large that it requires a custom web design project to resolve, we will always provide a proposal for the client's approval prior to performing any billable work.

To do this, take the following steps:

1. Navigate to [Design > Template Package Sandbox] in your store's Administration Area.

2. Select a Template Package to Edit.

3. If it isn't already, populate the "index.tpl" template into your package. This is done from the Template Package Options row, by clicking Populate Templates. In the popup, select the checkbox for index.tpl, and click Populate Selected Templates.

4. Under Template Package Files, select index.tpl.

5. At the top right of the Template Editor, click Switch to Plain Text Editor. This will switch the editor to show the source code of the template.

6. At the very beginning of the template's source code, paste the following code snippet; replacing the URL with the one you wish to direct visitors to:


code example
<?php  

header( 'Location: http://www.example.com/page.html' ) ;

?>

 

In order to have visitors of index page redirected to checkout, you will want to enter the checkout page of your store as the URL. (Such as http://www.example.com/checkout.php.)

warning
Make sure this code is at the absolute beginning of the template, before any other page content; even before <html> and other such tags. If it is not, the page will not function properly.
 

7. Under File Options, be sure that "Save" is selected.

8. Click Save Changes.
 
With this change to the template, customers who visit the index page of the store will now be directed to the checkout page instead.

You're done!

tip
You can do this to any template or webpage on servers running PHP.

however:
Be very careful what templates or pages you decide to setup redirects in, especially the store's universal template: universal.tpl

As an example, if you setup a redirect in universal.tpl, this will result in any templates that aren't populated into your template package redirecting to the specified URL.


— Last Edited - 01/6/2015 2:43pm PST
Rank and add a comment to this article
Only logged in users may leave comments and rank articles. Log in to have your say!
  Knowledge Base Home

  QuickCode™ Tag Glossary

  Modular Merchant.com Homepage

Not Logged in.
Either Log in or create a User Account.

Other articles in this category...

Adding a product quantity field to the store's home page

Adding additional pages to the checkout process

Apple Mail - Suggested Mail Account Settings

Can I put my store in an iframe on another website?

Changing a Modular Merchant account name

Checks & Money Orders

Create a CNAME record for your subdomain

Demo Mode

eCheck (Authorize.net)

Gift Wrap

Grace Period

How to download your SSL Certificate from Plesk

How to Report Server Slowness or Connectivity Problems

How vendor royalties are calculated

How zero dollar transactions are handled

Manage Modular Merchant Account

Microsoft Outlook - Suggested Mail Account Settings

Missing countries & states/provinces at checkout

Mozilla Thunderbird

Password-protect directories using Plesk

Prevent Specific Customers from Editing Their Subscriptions

Prorating subscription products

QR Codes

Search Email Series

Setup a redirect in a store template using PHP

Troubleshooting stuck outgoing emails

Upgrading your Modular Merchant Account Plan

Upload a company logo

What server am I on?