Home Web-development Instant E-commerce with OpenCart: Build a Shop

Instant E-commerce with OpenCart: Build a Shop

By Murat Yilmaz
books-svg-icon Book
Subscription
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
Subscription
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
About this book

For years, starting an e-commerce shop was considered a hard task with the need of a significant amount of money, time, and resources. OpenCart makes this process easier and enables anyone to create an attractive and profitable e-commerce solution. This concise guide will show you how to create a robust and striking online store with OpenCart.

"Instant E-Commerce with OpenCart: Build a Shop" teaches you how to build your own online shop with step-by-step, easy-to-follow instructions. You will learn how to install, configure, and customize your own shop in order to create an attractive and fully functional store in no time. If you have always wanted to create an online shop, but don’t know how, then this book is for you!

In "Instant E-Commerce with OpenCart: Build a Shop", you will be taken through the required steps to create an awesome e-commerce solution. This book starts by showing you how to correctly set up and install OpenCart, before moving on to creating products and their attributes.

If the world of payment gateways and shipping options sounds complicated, don’t worry. This guide will take you through the essentials required to set up and manage how your customers are going to pay for and receive their orders! Finishing with vouchers, templates, and SEO, this book will ensure you end up with a powerful, attractive, and profitable online store.

Publication date:
April 2013
Publisher
Packt
Pages
70
ISBN
9781782169680

 

Chapter 1. Instant E-commerce with OpenCart: Build a Shop

Welcome to Instant E-commerce with OpenCart: Build a Shop! OpenCart is currently one of the most flexible and user-friendly, open source shopping carts and store management systems. Today, many professionals run their shops using OpenCart because it provides a wide range of features that are easily customizable, even for non-techies. Also, there is a very active and ever-increasing community of users for OpenCart.

In this guide, we will learn how to implement a fully-featured store in the shortest time using structured, step-by-step recipes.

 

Installation (Simple)


We will learn how to install a default OpenCart shop correctly.

Getting ready

First of all, we will need a domain to run our online shop. GoDaddy.com is the most popular registrar to buy a domain name if you don't have one. To be able to install OpenCart, we will also need to find a web hosting service that needs to be fully supported by all of the components on the following technical checklist: Apache Server, PHP 5.2 (minimum), MySQL, cURL, Fsock, and the cPanel administration tool.

How to do it...

  1. Let's download the latest OpenCart version on our computer using the following link (at the time of writing this book, the latest OpenCart version was v1.5.4.1):

    http://www.opencart.com/index.php?route=download/download

  2. Let's log in to the cPanel administration tool. It is usually located at http://yourwebsite.com/cpanel.

  3. Let's open File manager under the File section and click on the Web Root option. We will click on the Upload button situated at the top and choose our installation ZIP file.

  4. After the uploading process is completed, we will extract the contents to the folder shown in the following screenshot:

  5. We will navigate to the upload folder. The next step is to select all the files and move them to the root folder. Here is how this is done:

  6. We will configure the database settings by creating a database and a user, and we will then connect the user to the database.

  7. In cPanel, click on MySQL Database Wizard. It will ask you to provide a database name.

  8. Now, we need to provide a database username with the password. Let's make sure we generate a strong password with the help of the password generator. Take note of the password. We will need it later. The final step is to provide all the privileges to our user for the database. For this, select the ALL PRIVILEGES checkbox and then click on the Make Changes button to complete the process.

  9. Now let's browse to http://yourwebsite.com/install.

  10. We will accept the public license agreement and click on Continue. The next page deals with essential system checks. If there are no errors, we will go on to the database settings page. We will fill in the information that we had already provided during database creation:

  11. The installation ends here. But now we will delete the install folder using cPanel, for security reasons.

 

Adding categories and subcategories (Simple)


We will look at the different ways to categorize a sample musical instruments shop and enter a sample category and subcategory under it.

Getting ready

OpenCart creates sample categories and products upon completion of the installation process. We will first need to delete them to start with a clean store structure. Let's browse to http://yourwebsite.com/admin, log in to the system, and click on the Catalog/Categories menu. Let's select all the categories and click on the Delete button.

How to do it...

  1. Let's add our first category to our web store. Open the Catalog menu, click on Categories, and then click on the Insert button.

  2. There are several tabs on this page. We will provide data for the General tab first.

  3. For the Data tab, let's fill the textboxes, select the options according to the following screenshot, and click on the Save button:

  4. In a similar manner, let's add a subcategory under the category that we have just added. Here is the sample screenshot to achieve this:

  5. Here is how the user interface will look when a visitor browses to the subcategory:

How it works...

Here's an explanation of the fields under the General tab:

  • Category Name: This is shown as a link to the visitor on the left sidebar by default, and it can optionally be displayed at the top of the page as well. The subcategories and the products listed under a category are shown to the visitor when a category name is clicked.

  • Meta Tag Description: This is used by search engines to describe a web page. So enter this information wisely to get a better rank with regard to relevancy and attract more visitors to your shop from the search engines.

  • Meta Tag Keywords: This is also for the search engines. It is useful to fill this textbox even though some search engines now ignore it. The search engines will relate our web page to the keywords we provide here.

  • Description: This is for our shop visitors. It describes what the category does and some of the items visitors can find under it.

Here's an explanation of the fields under the Data tab.

  • Parent Category: It is used when we open a subcategory under another category.

  • Image: The image we provide here is shown on the website. It is useful to provide such images whenever possible. It will attract more attention and provide more views for the product.

  • Top: If you have lots of main categories, you can use this option to show the most important ones at the top.

  • Status: If the Disabled option is selected, a category is not shown in the store.

    Note

    Be careful! Disabling a category will not disable the products in the category. The products will still be available by direct URL browsing if they are enabled.

 

Adding products (Intermediate)


In the following section, we will add a guitar as a sample product and show how different settings will result in different effects.

Getting ready

We will clean our store by removing preinstalled products, similar to how we did for categories in the previous section. Let's open the administration panel. We will open the Catalog menu, click on Products, choose all the listed products, and then click on the Delete button.

How to do it...

  1. Let's open the Catalog menu, go to Products, and click on the Insert button. We'll start with adding our first product by filling the General tab according to the following screenshot:

  2. Now let's click on the Data tab and provide data for the remaining fields according to the following screenshot:

  3. After filling the remaining fields on the Data tab, we will choose from the categories on the Links tab and jump to the Image tab directly to add more images for our product. We will be talking about the other tabs in the further sections, so we can just ignore them for now.

  4. After we click on the Save button, we can browse to the product's page and see how it looks:

How it works...

The following section explains what we have done for the creation of a basic product.

An explanation of the General tab is as follows:

  • Product Name: This name will constitute the heading text on the product information page. The name will be listed under its own category as well.

  • Meta Tag Description: This text will be displayed by the search engines to their visitors. So be descriptive and try to make it no lengthier than 125 words. Otherwise, it will be cut by the search engines.

  • Meta Tag Keywords: This is for the search engines. Here we can write related keywords for the product.

  • Description: This is the main description text that will appear on the product information page. The good thing is that we can even construct an advanced layout with the help of HTML.

  • Product Tags: Tags are the direct shortcuts for search phrases. They are shown under the product description. So, we can also group such searches and show different products under the same search tag.

In the Data tab, we provide the price of the product and its physical properties along with some stock-handling options.

  • Model: You need to provide the model number or code in this field.

  • Price: This is the price of the product, not inclusive of taxes.

  • Quantity: OpenCart supports stock tracking. We can take advantage of this feature by providing the current stock for the product. It will be deducted automatically after a sale if the Subtract Stock option is set to YES.

  • Subtract Stock: Set this to YES if you want to deduct from the stock whenever a new order has come in.

  • Out of stock status: If a product becomes out of stock (the Quantity becomes 0), the selected message is listed on the production information page.

  • Requires shipping: This option is only valid for physical products.

  • Location: Here we can enter information about the item's location.

  • Date Available: This can be used to show a product on the store on a future date.

 

Adding product attributes (Simple)


Product attributes generally define the categorized specifications or technical features of a product. If you provide the attributes, shop visitors can compare them side by side.

Getting ready

There are attributes and attribute groups that are created upon installation by default. We will need to delete them before entering our attribute information.

Let's open the list of attributes by clicking on the Catalog menu and then clicking on Attributes. After this, we will delete all the installed attributes.

Let's do the delete operation for the Attribute Groups list, which is located under Catalog | Attributes | Attribute Groups.

How to do it...

  1. We will start by adding an attribute group. For our example, we have chosen Physical attributes as the name for our attribute group.

  2. Guitar Body Material and Number of strings are two sample attributes. We will assign them to a certain attribute group while creating them.

  3. We will now edit our product using the Attribute tab under Catalog | Products. The available attributes are listed as soon as we begin filling in an attribute name. The following screenshot shows the two attribute values that are assigned for the product. This is a six string guitar with a basswood guitar body.

  4. If a visitor browses the product and opens the Specification tab, all the information we have provided will be seen.

How it works...

We should be providing this information where visitors are likely to compare and classify the attributes of more than one product. It's better usage of information. Here is the comparison screen for a user:

 

Adding product options (Simple)


Options contains the purchase options for a product. For example, color is a common option for mobile phones. Customers can choose either a black phone or white phone. Sometimes, an option can increase or decrease the final price of a product as well. For example, you can either buy a tablet with a protective case or buy one without it.

Getting ready

Let's delete the preinstalled options by browsing to Catalog | Options, selecting all the options, and deleting them.

How to do it...

  1. We will now enter a few purchase options for our products. Let's click on the Catalog menu, click on Options, and then click on the Insert button. According to the following screenshot, we offer Protective case, Guitar amp, and Guitar strap as Extra accessories.

  2. Now let's edit our product information through the Products page under the Catalog menu by browsing to the Option tab. The available list of options will be seen as soon as we begin typing.

  3. The following screenshot shows that we have provided optional Extra accessories for our guitar. For example, if the customer chooses to purchase the guitar, which costs $150 by itself, the final price will be $200 with the addition of $50 for the guitar amp.

  4. The following screenshot shows another set of options that is the required set of options. According to this, a customer must choose either the right- or left-handed guitar model. Choosing the left-handed guitar model will increase the price by 25 units. Choosing the right-handed guitar doesn't change the price.

  5. Here is what a customer will see on the product page. Note that we must choose an option for Hand orientation, while choosing any for Extra accessories is not obligatory:

  6. This is the shopping cart after these options are added to the final price:

 

Adding tax data (Simple)


Generally, the tax rate for a product is calculated according to the geographical shipping location of a customer. We will now see how we can enable taxes for a product, and how we can enter the tax class, rates, and grouping information for it.

How to do it...

  1. Let's apply the default tax class to the product under the Data tab. It is called Taxable Goods by default. The right-hand side of the page shows the result when the edited product is added to the shopping cart.

  2. Assume that our store also ships to Germany. Now let's add the tax rate for customers who will order from Germany. We will need to define the tax zone. Let's go to System | Localisation | Geo Zones and then click on the Insert button. We have added all the geo zones of Germany. Let's go to System | Localisation | Taxes | Tax Rates and insert the following tax rate and connect it with the geo zone.

  3. Go to System | Localisation | Taxes | Tax Classes, edit Taxable Goods, and insert Sales tax 19% in the Tax Name field for the newly added tax rate.

  4. Now if we open a test customer account with a shipping address from Germany, log in to the system, and add a product to the shopping cart, we will see that the correct tax value is applied.

  5. By default, the prices are shown inclusive of tax. It is possible to change this setting. Here is how to do it. Click on the System menu, click on Settings, and edit the Option tab. Now the front page shows the price without the tax included, as shown on the right-hand side of the following screenshot:

How it works...

The default tax class is applied to a product after it is added to the shopping cart. OpenCart shows UK tax zones on installation by default if a tax class is enabled for a product.

 

Configuring general shop settings (Simple)


We will learn how to configure the look of our shop as well as its stock handling, local language, currency, checkout, and tax options.

How to do it...

  1. Let's open the Settings menu from the System menu and then click on Edit to open the main settings screen for our store. Let's fill in the General tab according to our store information. Then, let's click on the Save button on the same page. After that, let's browse to the URL http://yourwebsite.com/index.php?route=information/contact to see how this information will be shown on the Contact us page. The link to this page is also located at the bottom of every page of our website.

  2. Let's continue with the Store and Local tabs and provide more information for our store.

    Tip

    Let's not forget to click on Save at regular intervals while entering information on the tabs. By doing this, we will not lose the changes if the website session expires.

  3. Now let's fill the Option and Image fields as well.

How it works...

Let's learn the details of the options we have just set.

The Store tab

Following is an explanation of some of the options under the Store tab:

  • Title: This is shown as the title of the store in the search engines as well as on a visitor's browser tab

  • Meta Description: This is for the search engines; it is shown as a description under the title

The Local tab

Following is an explanation of some of the options under the Local tab.

  • The Country and Region/State tabs: These are used to enter information for the "shipping from" address.

  • Auto Update Currency: We can automatically update the currency rates using this option. The rates will be updated using the Yahoo! Finance service working in the background.

  • The Length and Weight Class tabs: Measurement types are selected here. Typically, a store in the US will use inches and pounds instead of meters and kilograms that are used in the EU.

The Option tab

The following is an explanation of the options under the Option tab:

  • Default Items per page (part of the the Admin and Catalog tabs): This is for paging purposes and generally set to a high value for admin panels, for easier administration. A very large value for the customer catalog can make the site slower if it is getting a lot of page views.

  • Category Product Count: If set to Yes, all the subcategories will show the number of products under them. It can have a negative impact on the performance of large stores.

  • Allow Downloads: We set this to No for a store that sells physical products.

  • Taxes: We use this section to show prices either with or without the tax included, and define the address source for which the taxes need to be calculated. Typically, you will not need to change the settings here.

  • Customers Online: If set to Yes, online guests and customers are tracked in a special report, along with detailed information, such as their last visited page, IP address, and so on. The report is available under the Customers Online menu under Reports | Customers.

  • Login Display Prices: It is possible to show prices only when a customer logs in to the store. When it is set to Yes, guest users will not be able to see the sale prices of the items.

  • Account Terms: It is wise to force users to accept a privacy policy when they create an account. In this way, you can be on the safer side legally.

    Note

    The Account and Checkout Terms sections can be edited on the Information page under the Catalog menu.

  • Guest Checkout: This is the fastest way to order from a store, without the customer having to sign up for the store at first. But, they will not be able to track the status of their orders online.

  • Checkout Terms: Again, it is safer to force users to accept the terms and conditions of use.

 

Configuring payment models (Intermediate)


OpenCart supports a wide range of payment methods and services. We will learn how to integrate one of the most popular online payment services, that is, PayPal into our store. PayPal offers several solutions. Two popular ones are PayPal Website Payments Standard and PayPal Website Payments Pro.

How to do it...

Let's learn how to integrate PayPal Website Payments Standard into our store in test mode.

Integrating PayPal Website Payments Standard into our store (test mode)

  1. We will start by activating PayPal Payments Standard using the Payments section under the Extensions menu, and then we will edit the settings for it.

  2. The next step is to fill in the needed information for testing the PayPal system. For test purposes, we will choose the option for Sandbox Mode as Yes.

  3. We will now open a developer account to create test accounts on PayPal. Let's browse to http://developer.paypal.com and sign up for a developer account. Following is a screenshot of the screen that is displayed after we sign up and log in to the account. Click on the Create a preconfigured account link.

  4. The next screen will propose an account name with which your account will be created. Now we only need to add funds to the Account Balance field to create the account. Remember that it is a test account, so we can give any virtual amount of funds we want.

  5. Now we have a test PayPal account that can be used for our test purchases:

  6. Let's go to our shop's user interface, add a product to the shopping cart, and proceed to the Checkout page:

  7. Let's log in with the test account we have just created:

  8. The following screenshot shows a successful test order:

Integrating PayPal Website Payments Pro into our store (live mode)

  1. We need to get the API information first. Let's log in to our PayPal account. Click on the User Profile link, and then click on the Update link next to API access in the My selling tools section. The next step is to click on the Request API Credentials link. Choose the option that says Request API signature. This will help us get the API information.

  2. The next step is to activate Payment Pro on the OpenCart administration interface using the Payments section under the Extensions menu. We need to edit the details and enter the API information. Let's not forget to select No for Test Mode, which means that this will be a live system. Choose Enabled for the Status field.

How it works...

Now let's learn how the PayPal Standard and Pro models work and how they differ from each other.

PayPal Website Payments Standard

PayPal Standard is the easiest payment model to integrate into our store. All we need is a PayPal account, and a bank account to withdraw the money from. PayPal Standard has no monthly costs or setup fee. However, the company charges a small percentage from each transaction.

Note

Please go to https://www.paypal.com/webapps/mpp/merchant for merchant service details.

The activation of the Standard method is very straightforward. We only need to provide our e-mail address and then set Transaction Method to Sale, Sandbox Mode to No, and Status to Enabled on the administration panel.

There is a difference in the test payments that we have made. Customers can also pay with their credit cards instantly, even without a PayPal account. This makes PayPal a very powerful and popular solution.

Tip

If you are afraid of charging your real PayPal account, there is a good way to test your real payment environment. Create a dummy product with the price of $0.01 and complete the purchase with this tiny amount.

PayPal Website Payments Pro

This service can be used to charge credit cards using PayPal services in the background. The customers will not need to leave the store at all; the transaction will be completed at the shop itself. Many big e-commerce websites operate this way.

Note

Currently, Pro service is only available for merchant accounts located in the US, UK, and Canada.

 

Configuring shipping methods (Intermediate)


There are many shipping methods that OpenCart supports. In the following pages, we will learn how to implement the most popular ones.

How to do it...

Let's learn how to limit the purchases from our shop to specific countries.

Accepting orders only from certain countries

We will now learn how to disable orders for the countries to which we don't want to ship items.

  1. Go to System | Localisation | Countries. You will see a list of all the countries of the world on the Countries page. Choose any one of them, set the Country Status to Disabled, and click on the Save button.

  2. We need to repeat this process for each country we don't want to ship to.

Shipping methods

The methods we will cover in this recipe are free, per item, weight-based, UPS, and USPS shipping.

Free shipping
  1. Let's go to the Extensions menu and click on Shipping. Then, click on the Install link next to the Free Shipping option. The following screen shows up after we enable it; here we will define that every UK Shipping geo zone order that exceeds 200 in total (that is, every order for which the total price exceeds 200 in the default currency) will have no shipping costs. The other customers will not even be able to see the free shipping offer.

Weight-based shipping
  1. Let's go to the Extensions menu and click on Shipping. We need to install and edit the weight-based shipping method. Open the General tab. The Status field has to be set to Enabled here for the Tax Class we use for the definition of our items in the store. Then, we will need to define the shipping rates for the geo zone we want, for example, UK Shipping.

  2. Let's fill in the Rates textbox with 1:10.00 , 2:17.00 , 5:35.00 , 10:60.00.

  3. Now change Status to Enabled.

  4. Now let's edit the weight of a product on the store. It is on the Data tab under Catalog | Products. The example shows a value of 1 kilogram:

  5. Let's log in to the system with a test user account that has an address from the UK. Let's add this product with quantities of one and two units separately and check the shipping options for each. The following screenshot shows the different weight-based shipping rates according to the total weight proposed to the customer:

UPS
  1. Let's visit the website https://www.ups.com/upsdeveloperkit.

  2. We need to register on this page. Upon successful completion of the registration, we will log in to the system and request an access key.

  3. The request would require a real UPS account. You can open a new account or connect an existing account now. After all these steps, we will get an access key that we can use in OpenCart.

  4. After this, we can go to Extensions | Shipping and activate the UPS method, and provide the access key along with our username and password on the developer system. Let's not forget to change the Status to Enabled and choose the mode correctly (test or live).

USPS
  1. Before starting, we need to open an account on the WebTools service web page. It is located at https://secure.shippingapis.com/registration.

  2. The account is opened on the test server by default. On completion of the tests, we will need to send an e-mail to USPS to activate production mode. After the change, we can offer this shipping method to the customers. Again, we provide the information for USPS using the Shipping section under the Extensions menu.

How it works...

By default, an OpenCart shop allows ordering for all the countries of the world upon installation. Generally, online stores accept orders only from a certain set of countries or regions. We have learned how to limit the purchases to specific countries.

Free shipping

It is possible to give customers the advantage of free shipping if their shopping cart value exceeds some predefined value.

Note

It is not possible to set different free shipping minimum totals for different geo zones for this OpenCart version at the same time. So we cannot offer, say, 200 for the UK, and 300 for Germany.

Weight-based shipping

This is one of the most popular shipping methods for online stores. The final shipping cost is calculated according to the weight of the products in the cart.

UPS

UPS (United Parcel Service) is the world's largest package-delivery company. OpenCart has a built-in shipping module for when shipping with UPS. Before we integrate UPS into OpenCart, we need to get a username, password, and a special XML key from the UPS Developer website.

USPS

USPS (United States Postal Service) is the official post office of the US government, so it is available only in the US.

 

Offering coupons and discounts (Intermediate)


We can offer coupon codes to our customers so that they will be motivated to shop more.

How to do it...

There are two types of coupons in OpenCart: fixed amount and percentage based.

Defining percentage-based coupons

  1. Let's open the Sales menu and click on Coupons, and then we will delete all the sample coupons that were set (by default) upon installation. We will insert a new coupon with the following values:

  2. Let's add a product to the shopping cart using a test customer account and apply the just-added coupon code. The following screenshot shows that the coupon code has been successfully applied:

Defining fixed amount coupons

  1. We will insert a new coupon with the following values:

  2. If we add a $699 product to the shopping cart using a test user account and try to apply the coupon code, we see that it fails.

  3. If we update the shopping cart with two items that together cost $1,398 and reapply the coupon code, it will be applied successfully.

Adding special discounts for products

  1. Let's edit a product, click on the Special tab, and add a new special discount as shown in the following screenshot. After that when we browse to this product, we see that the special discount has been applied:

  2. Customers can still apply a coupon code to the already-discounted special item:

Applying discounts for bulk purchases

We can apply special discounts on bulk purchases. Here is how this is done.

  1. We edit a product and click on the Discount tab. Let's add the discount as shown in the following screenshot:

  2. The following image shows how the unit price changes when the item is added in bulk and exceeds the Quantity value, which is what we have just defined on the Discount tab.

How it works...

Defining coupons

In the first example, we defined a coupon code that offers 20 percent discount on the price if the shopping cart value exceeds $250; we limited the total usage of this coupon to 10 times.

In the second example, we defined a coupon that gives a $100 discount on a purchase if the shopping cart value exceeds $1,000. We limited the usage of the coupon to include only selected products.

As a special promotion offer, we decreased the price of a product for a limited time in the next example.

Finally, we decreased the price of an item for bulk purchases.

 

Managing orders (Intermediate)


Order management is very straightforward and easy in OpenCart.

How to do it...

  1. Orders are tracked as a list using the Orders section under the Sales menu.

  2. Let's click on the Order Details tab to see who made an order, along with the total amount and date. The order status is shown as Pending at first:

  3. The Payment Details and Shipping Details tabs are the next ones we need to check. Although they are usually the same, they can also be different. In such a case, we send the invoice to the payment address and we ship the items to the shipping address.

  4. The next tab is Products, where we get to see all the ordered items along with their shipping information, coupons, and tax rates (if they exist).

  5. The last tab is the one we will always use. The Order History tab lists all the steps; this is where we start processing the orders and notify the customer.

  6. Here is a sample of an informative e-mail that the customer will get:

  7. Suppose that we are ready to ship the order. We will generate an invoice now using the Generate link on the Order Details tab:

  8. Now a new invoice number is generated in the Invoice No. field. Let's click on the Print Invoice button:

  9. This is what a typical invoice looks like:

  10. Let's ship the order and set the status as Shipped:

  11. Finally, we can set the Status to Complete after the shipment is made. This time, we will not send a notification.

How it works...

Although we can edit the details of an order, we typically view the details and then set the status of an order to inform the customer accordingly. The details of all the orders are listed in a table for easy administration.

Here is a screenshot showing all the changes to an order on the Order History tab:

 

Managing customers and users (Simple)


We will be able to track customers better if we group them into segments.

How to do it...

Let's learn how to create new groups and assign customers to a group.

Classifying customers in groups

  1. Customer groups are listed under Sales | Customers | Customer Groups. We will insert a new group and name it VIP.

Assigning a customer to a group

  1. Let's open the details for a customer by going to Sales | Customers | Customer Groups and editing the General tab. We will now set Customer Group to VIP.

  2. Now we can offer a special price for a product to the VIP group of customers using the Special tab under Catalog | Products.

  3. A visitor to the store who is part of the Default group will see the original price. On the other hand, a logged-in VIP user will see the special price.

Managing users and user groups

  1. Let's go to System | Users | User Groups and click on the insert button. Now let's add a group with the name Product Entry that will have only product administration rights. After this, let's go to System | Users, add a new user, and assign this user to the newly created group.

  2. Let's log in with the username operator1 and try to browse through the orders page listed on the page under Sales | Orders. We will not be able to see the list because of insufficient permissions:

How it works...

We could assign the VIP group to the most active customers with the biggest orders. The group Default is automatically created during installation, and all new customer registrations are assigned to this group.

OpenCart allows defining different roles for administrative users. It is especially useful for large stores where some users are only allowed to add/edit products while some others are allowed to process the orders.

 

Localization (Simple)


OpenCart is a very flexible system and allows running online stores in multiple languages and currencies.

How to do it...

In this recipe, we will learn how to install new languages and currencies for our store.

Installing a new language pack

We will download and install the French language pack as an example:

  1. Let's browse to http://www.opencart.com and click on the Extensions tab from the menu at the top, and search for french in the languages category:

  2. We have found a free language pack. Let's download it to our computer and extract the contents.

  3. There are two folders named admin and catalog. The admin folder holds the translations of the administration screens while the catalog folder provides them for the shop interface.

  4. Let's browse to the language folder under the catalog folder and find the compressed french folder (french.zip). We will upload it to /catalog/language on the server and extract the contents.

  5. Finally, we will open System | Localization | Languages and add a new language with settings as shown in the following screenshot:

  6. We can see that the French flag is displayed at the top of the store along with the English flag so that it is easy to change between the languages.

Adding a new currency option

  1. In this example, we will add Canadian Dollars (CAD) as additional currency for our store.

  2. Let's open System | Localization | Currencies and insert a new currency. The following screenshot shows that it has been activated on the shop interface after the addition.

  3. We have provided an initial value for the CAD, but it is also possible to update the currency automatically using the information from the Yahoo! Finance website. This setting is located on the Local tab under System | Settings.

 

Managing affiliates (Simple)


Affiliate marketing is a very effective online marketing strategy. Simply put, people who have blogs or e-mail lists will advertise our products with their special tracking IDs and earn commissions whenever a sale is made through their links. Let's learn how to manage affiliates, commission rates, and sales.

How to do it...

Let's learn how to manage the affiliate system for our shop and disable it when we don't need it.

Managing affiliates

  1. People who are interested in joining our affiliate program will use the special link http://yourwebsite.com/index.php?route=affiliate/login mentioned at the base of the page.

  2. After they register for our affiliate program, we will need to approve them. For this purpose, we will use the page under Sales | Affiliates.

  3. After approval, the affiliate will get a notification e-mail. The person can now log in to the system and generate the links for products using his/her account menu located at http://yourwebsite.com/index.php?route=affiliate/tracking.

  4. We need to be sure that the commission rate and payment type for each affiliate is accurate. We can edit the affiliates using the Payment Details tab under Sales | Affiliates:

Disabling affiliate system

It is quite possible that an online shop owner won't use the affiliate system. By default, the affiliate system is enabled on OpenCart. In the current version, there is no administrative setting to deactivate/activate it. Still, we can disable it by removing the affiliate link from the base of the page and redirecting the affiliate login page to the main page. Here is how it is done.

  1. Let's edit the footer.tpl file located at catalog/view/theme/default/template/common and remove the following line:

    <li><a href="<?php echo $affiliate; ?>"><?php echo $text_affiliate; ?></a></li>
  2. Let's open the login.tpl file located at catalog/view/theme/default/template/affiliate.

  3. Let's add the following code at the top of the page:

    <?php header( 'Location: index.php?route=common/home' ) ; ?>
  4. Now all requests to the affiliate login page will be redirected to the main page.

Note

The default commission rate can be set for a store using the Option tab under System | Settings.

 

Offering voucher codes (Simple)


Voucher codes are actually discount codes that can be purchased online and sent to someone as a gift, usually for special days, such as Christmas, Black Friday, birthdays, and others. The recipient can redeem the voucher during checkout.

How to do it...

  1. A customer clicks on the Gift Vouchers link in the Extras section at the bottom of the store's page.

  2. Then the voucher is purchased; the customer also needs to enter information about who will be using the voucher at the store.

  3. The purchase of the vouchers can be tracked by the administrator using the Gift Vouchers section under Sales | Gift Vouchers. The voucher code will not be e-mailed until we approve it by clicking on the Send button.

    Tip

    Make sure that the payment was received successfully before clicking on the Send button. Also, do not forget to edit the automatically generated code before sending it if it is very easy to guess.

  4. Now the recipient will get the code in his/her e-mail inbox and can redeem the coupon on the shopping cart at the store.

  5. If the total amount of the shopping cart exceeds the voucher amount, the voucher amount will be used as a discount.

  6. If the total amount of the shopping cart is less than the voucher amount, the remaining funds can be used for future purchases by the recipient.

    Note

    The Use Gift Voucher option is enabled on the store during checkout (by default), as shown in the previous screenshot. If we don't see this option for redeeming the voucher, we will need to enable it using the Order Totals section under the Extensions menu.

  7. The e-mails that will be sent are also customized. We can edit or create new templates using the Voucher Themes section under Sales | Gift Vouchers.

  8. By default, a voucher purchase can only be between $1 and $1,000. We can override this default setting using the site edit page in the Vouchers section, which is part of the Option tab under System | Settings.

 

Learning to use modules (Simple)


OpenCart provides a set of modules that help us further customize and enhance our shops. Some of these modules are enabled, by default, upon installation.

How to do it...

In this recipe, we will look at the most useful modules and learn how we can take advantage of them.

Working with banners

Banners, simply defined, are images with links to advertised products or websites. In OpenCart, we can manage and replace banners easily.

  1. Let's define a new banner by going to System | Design | Banners and inserting a new banner with multiple images.

  2. After this, let's go to Extensions | Modules and edit the Banner module. We choose Banner1 as the name for the newly added banner and also provide the dimensions and location of the banner.

  3. The following screenshot shows how it will appear on the store front's category page. Note that the images rotate automatically in a few seconds as we have provided two images for the banner.

Using the Specials module

  1. This is a very useful module for promoting the products for which there are special price discounts. After installing and enabling this module using the Modules section under the Extensions menu, we create a placeholder to show the special items.

  2. In the following example, a special box will be shown only at the bottom of all the content on the Product page (a maximum of three specials) and on the left-hand side of the Category page (a maximum of five products)

  3. Here are two screenshots that show how the module will appear on a product page:

  4. The same module is shown on a category page in the following screenshot:

Tip

Modules behave differently according to the selected layout structure and placement.

 

Implementing SEO for our shop (Intermediate)


Search Engine Optimization (SEO) is an essential part of a website, and it is required in order to appear in higher positions in search engine results. On default installation of OpenCart, even basic SEO is not applied. So we will now learn how to activate it at a basic level.

How to do it...

  1. Let's open one of the product pages to see how URLs are formed. A sample page is shown in the following screenshot:

  2. Let's click on the Server tab on the site edit page under System | Settings. Let's choose Yes for the Use SEO URL's option and save the page.

  3. Let's open File manager on cPanel and browse to the root folder.

  4. Rename the .htaccess.txt file to .htaccess by deleting the .txt part.

  5. Let's open the OpenCart administration screen and browse to Catalog | Products and edit the product. We will fill the Meta Tag Description and Meta Tag Keywords textboxes under the General tab and the SEO Keyword field under the Data tab.

  6. Now let's browse to the product page using a category. The URL was changed according to the SEO keyword we just entered.

How it works...

We have changed the parameterized URL to a friendlier one. We should also use SEO for the categories and their subcategories. As a best practice, this should be done for every category and product in our store.

As the best SEO practice, always use the "–" sign between words instead of spaces for the SEO keywords.

 

Changing layouts and templates (Intermediate)


Templates are used to provide different design styles for the store front. While most templates do not change the default functionality, some of them do. There are free and paid templates available for OpenCart, and you can download them using the following websites:

How to do it...

Now let's learn how to install a new template for our store.

Note

Let's remember that the recipe shows us how to install a simple template. Some other advanced templates usually require specific manual actions on database and file structure. These are explained in the readme files in the template packages.

  1. We will use a free template from the OpenCart.com extensions section of our example. After downloading the template from the website, we will upload the ZIP file to the theme folder under catalog/view and extract it to this location.

  2. After this, we will navigate to System | Settings, click on the Store tab, and change the template:

  3. Here is how the new template will look on the store:

  4. Now let's learn how layout determines the design of a page. For this example, we will edit the design of a selected product to have the Manufacturer layout instead of the default Product layout.

  5. The final result would be a screen without the left-hand side column because the Manufacturer layout has no left-hand side column.

  6. By editing or playing with the layouts, you can have any kind of advanced layout system. It is possible to upload and activate other paid and free layouts as well.

  7. The layouts can be added, deleted, and changed using the Layouts section under System | Design.

 

Managing shop backups and restores (Simple)


Taking backups of our store on a regular basis is essential to safeguard our store against the disasters that can occur on a hosting server.

How to do it...

In this recipe, we will learn how to back up our system regularly and restore it if needed.

Backing up OpenCart files and data

  1. Let's go to System | Backup | Restore in the administration panel. All the data items are automatically selected for us. We will just click on the Backup button.

  2. The system will generate a file with a .sql extension. We need to save it in a safe place on our computer.

  3. We will now open cPanel File Manager and compress all the stored files into a store.zip file. After that, we will download it and save it in the same safe place on our computer.

Restoring OpenCart files and data

  1. In the case of a disaster, we will need to restore our system using our backup files and data. But first we need to delete all the current files on the server. Let's open cPanel File Manager, choose all the files, and delete them.

  2. Then we will upload the store.zip file, which we have saved previously, and extract it to the same location.

  3. Now it is time to learn how to restore the data. Let's go to System | Backup | Restore, choose the backup file (next to Restore Backup), and click on the Restore button.

  4. That was the final step in the restoration of an OpenCart system.

About the Author
  • Murat Yilmaz

    Murat Yilmaz is a software developer and an online entrepreneur who lives in Antalya, Turkey. He has over 10 years of experience in different IT fields, including development of web-driven solutions, large databases, and OLAP systems. He has worked in several multinational companies in Istanbul and Moscow as a consultant. He currently runs his own blog and an e-commerce and online advertising network. He holds a bachelor's degree in Computer Science from Marmara University at Istanbul. He spends his free time playing progressive rock songs, online chess, and reading scientific books.

    He has also authored two other books, OpenCart 1.4: Beginner's Guide and OpenX Ad Server: Beginner's Guide.

    Browse publications by this author
Instant E-commerce with OpenCart: Build a Shop
Unlock this book and the full library FREE for 7 days
Start now