OpenCart Theme and Module Development
By Rupak Nepali
()
About this ebook
- Explore the new features in OpenCart by using them in your custom theme
- Get hands-on with the Global Library Methods used in OpenCart to make themes and extensions
- Packed with hands-on examples, step-by-step explanations, and illustrations to guide you through coding modules and themes
This book is aimed at developers and designers who want to start developing their own themes and extensions and for those who want to know about the code workflow of the OpenCart theme and modules.
Related to OpenCart Theme and Module Development
Related ebooks
Jasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsPractical Django 2 and Channels 2: Building Projects and Applications with Real-Time Capabilities Rating: 0 out of 5 stars0 ratingsMastering PhoneGap Mobile Application Development Rating: 0 out of 5 stars0 ratingsLearning Bootstrap Rating: 1 out of 5 stars1/5Instant Play Framework Starter Rating: 0 out of 5 stars0 ratingsInstant Hands-on Testing with PHPUnit How-to Rating: 0 out of 5 stars0 ratingsBackbone.js Patterns and Best Practices Rating: 0 out of 5 stars0 ratingsBuilding a Web Application with PHP and MariaDB: A Reference Guide Rating: 0 out of 5 stars0 ratingsPython for Google App Engine Rating: 0 out of 5 stars0 ratingsMeteor Design Patterns Rating: 0 out of 5 stars0 ratingsPHP 7 Programming Blueprints Rating: 0 out of 5 stars0 ratingsLearning Firefox OS Application Development Rating: 0 out of 5 stars0 ratingsjQuery Design Patterns Rating: 0 out of 5 stars0 ratingsHTML5 for Flash Developers Rating: 5 out of 5 stars5/5HTML5 Data and Services Cookbook Rating: 5 out of 5 stars5/5Node Web Development, Second Edition Rating: 0 out of 5 stars0 ratingsAndroid Application Development with Maven Rating: 0 out of 5 stars0 ratingsOuya Unity Game Development Rating: 0 out of 5 stars0 ratingsResponsive Design High Performance Rating: 0 out of 5 stars0 ratingsjQuery 2.0 Development Cookbook Rating: 0 out of 5 stars0 ratingsGetting Started with OpenCart Module Development Rating: 0 out of 5 stars0 ratingsNW.js Essentials Rating: 0 out of 5 stars0 ratingsD Web Development Rating: 0 out of 5 stars0 ratingsMastering jQuery UI Rating: 0 out of 5 stars0 ratingsEmber.js in Action Rating: 0 out of 5 stars0 ratingsFlex 3 with Java Rating: 0 out of 5 stars0 ratingsBeginning DotNetNuke Skinning and Design Rating: 0 out of 5 stars0 ratingsPHP Programming Solutions Rating: 0 out of 5 stars0 ratingsXamarin Mobile Application Development for Android - Second Edition Rating: 0 out of 5 stars0 ratingsTune into the Cloud: The story so far Rating: 0 out of 5 stars0 ratings
Internet & Web For You
The Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5Remote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5No Place to Hide: Edward Snowden, the NSA, and the U.S. Surveillance State Rating: 4 out of 5 stars4/5Coding For Dummies Rating: 5 out of 5 stars5/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Tor and the Dark Art of Anonymity Rating: 5 out of 5 stars5/5How to Be Invisible: Protect Your Home, Your Children, Your Assets, and Your Life Rating: 4 out of 5 stars4/5Social Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5How to Disappear and Live Off the Grid: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsThe Gothic Novel Collection Rating: 5 out of 5 stars5/5The Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5Podcasting For Dummies Rating: 4 out of 5 stars4/5How To Start A Profitable Authority Blog In Under One Hour Rating: 5 out of 5 stars5/5HTML in 30 Pages Rating: 5 out of 5 stars5/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5Mike Meyers' CompTIA Security+ Certification Guide, Third Edition (Exam SY0-601) Rating: 5 out of 5 stars5/5An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5How To Make Money Blogging: How I Replaced My Day-Job With My Blog and How You Can Start A Blog Today Rating: 4 out of 5 stars4/5Six Figure Blogging Blueprint Rating: 5 out of 5 stars5/5Wordpress for Beginners: The Easy Step-by-Step Guide to Creating a Website with WordPress Rating: 5 out of 5 stars5/5The $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 5 out of 5 stars5/5Beginner's Guide To Starting An Etsy Print-On-Demand Shop Rating: 0 out of 5 stars0 ratingsContent Chemistry: The Illustrated Handbook for Content Marketing Rating: 5 out of 5 stars5/5The Internet Is Not What You Think It Is: A History, a Philosophy, a Warning Rating: 3 out of 5 stars3/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratings
Reviews for OpenCart Theme and Module Development
0 ratings0 reviews
Book preview
OpenCart Theme and Module Development - Rupak Nepali
Table of Contents
OpenCart Theme and Module Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with OpenCart 2.0
The features of OpenCart
Changing the OpenCart shop's general settings
Setting image height and width
Managing the modules in the theme
Managing the image dimensions of modules in the default theme
Creating and setting a promotional banner
Installing and uninstalling a module
Setting the Banner, Carousel, and Slideshow modules
Managing the layout and position of a module in a theme
Describing the files and folders of the default theme
Summary
2. Bootstrap, Font Awesome, and FlexSlider in OpenCart 2 Themes
Bootstrap
Advantages of using Bootstrap in OpenCart themes
The basic template structure with Bootstrap in OpenCart 2
A basic static Bootstrap template
Font Awesome, an iconic font
Setting up Font Awesome
Using BootstrapCDN by MaxCDN
Using default CSS
The icons of Font Awesome
Rotated and flipped icons
FlexSlider
Summary
3. Creating Custom Themes
Preparing the files
Integrating HTML and CSS into the OpenCart theme
Creating a new theme based on the default theme
Understanding the code in header.tpl
Checklist for the header section
Changing the style of currency
Describing the code of the top menu categories
Changing the style of the menu
Understanding the code in footer.tpl
Changing the style of the footer div in the footer
Removing the copyright information in the footer
The home page
The category page
The product page
The information pages
The contact us page
Changing the CSS for the checkout steps
Summary
4. Getting Started with OpenCart 2 Modules
Creating a Hello World module
The admin folder
The catalog folder
Installing, configuring, and uninstalling a module
Installing a module
Configuring the module
Configuring layouts for the module
Uninstalling the module
Positions for the module
The status of the module
Sort order of modules
Different layouts for the same module
The file structure – admin and frontend
Creating a language file for the admin section in OpenCart
Creating a controller for the admin section in OpenCart
Creating a template file for the admin section in OpenCart
The breadcrumbs section of the module
Creating a language file for the Catalog (frontend) module in OpenCart
Creating a controller file for the Catalog (frontend) module in OpenCart
Creating a template file for the Catalog (frontend) module in OpenCart
Summary
5. Extensions Code
Global library methods
Affiliate (affiliate.php)
Cache (cache.php)
Cart (cart.php)
Config (config.php)
Currency (currency.php)
Customer (customer.php)
Database (db.php)
Document (document.php)
Encryption (encryption.php)
Language (language.php)
Length (length.php)
Log (log.php)
Mail (mail.php)
Pagination (pagination.php)
Request (request.php)
Response (response.php)
Session (session.php)
Tax (tax.php)
URL (url.php)
User (user.php)
Weight (weight.php)
The Featured module
Configuring the Featured module in OpenCart 2.0.1.1
Exploring code used in Featured module
Exploring the code of admin/controller/module/featured.php
Exploring the code of admin/view/template/module/featured.tpl
Exploring the code of catalog/controller/module/featured.php
The Shipping module
Changes required at the admin folder to create total cost based Shipping module
Changes made in the catalog folder
The Payment module
Off-site payment
On-site payment
Order Total
Summary
6. Create OpenCart Custom Pages
Getting started with feedback management
Database tables for feedback
Creating files in the admin section for feedback
Creating the language file in the admin section
Creating the model file in the admin section
Creating the controller file in the admin section
Creating the template files for form and list pages in the admin section
Creating the model file for the catalog folder frontend
Creating the language file for the frontend
Creating the controller file for the frontend
Creating the template file for the frontend
Summary
Index
OpenCart Theme and Module Development
OpenCart Theme and Module Development
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2015
Production reference: 1240615
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-768-9
www.packtpub.com
Credits
Author
Rupak Nepali
Reviewers
James Allsup
Dario Fumagalli
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Meeta Rajani
Content Development Editor
Susmita Sabat
Technical Editors
Rohith Rajan
Anushree Arun Tendulkar
Copy Editor
Vikrant Phadke
Project Coordinator
Izzat Contractor
Proofreader
Safis Editing
Indexer
Rekha Nair
Graphics
Abhinash Sahu
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Rupak Nepali is from Nepal. He has been working as a PHP programmer and on the OpenCart framework since 2010. He has also completed many projects and built many modules on OpenCart to meet his clients' requirements. He is currently working as a web developer at Corner Edge Interactive, Arizona, and as a freelancer on Elance, oDesk, and other freelancer sites. Rupak holds a bachelor's degree in computer information systems from Nobel College, Kathmandu, Nepal. He is currently studying for his MS degree in computer science from the Maharishi University of Management, Iowa, USA.
I have already written Getting Started with OpenCart Module Development. With lots of love from readers, I have been inspired to write this book. Thanks for loving my previous book, and I am sure you will love this book as well, since it covers extensions and themes.
I wish to thank my parents, especially my mother, Subdthara Nepali, and my father, Bhairab Nepali, who emphasized the importance of literacy. I also wish to thank my brothers, who helped at every step, as well as all my friends and seniors who provided me with the support and courage to write this book.
Thanks to Packt Publishing for providing me with such a great opportunity and everyone who assisted in the publishing of this book, including the reviewers.
About the Reviewers
James Allsup started developing an interest in selling online and creating websites with PHP at the age of 16. After he joined Welford Media in 2009, OpenCart became his platform of choice for e-commerce projects, shortly after his company became closely involved with its development and support. In 2012, he released OpenBay Pro, a multiple-marketplace solution that allows merchants to manage their eBay, Amazon, and Etsy stores directly from OpenCart.
Thanks to my late father. Without him, I wouldn't have been the person I am today.
Dario Fumagalli has been passionately building software since the dawn of microcomputers in 1980 and has never stopped adopting emerging technologies to increase his customers' satisfaction. From assembly code to C++, Delphi to C#, and PHP and its many frameworks to compound technologies (such as AJAX via jQuery), he has enjoyed learning every constantly changing technology and implementing it in a practical way for a result-driven business world.
In an era where the Web, mobile phones, and social networks dominate, Dario is currently implementing responsive, or adaptive, e-commerce and social media solutions. Another branch of his activities is related to securities analysis and price action trading, where he is able put into practice his software programming background to back-test strategies, implement the Monte Carlo simulation, and store financial data.
These days, he lives in Tenerife, one of the beautiful islands of the Canary Islands. He provides professional partnerships for interested companies, both where he lives and worldwide via the Internet.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Preface
If you can build OpenCart themes, then you can also customize the presentation layer of OpenCart. Likewise, if you can code OpenCart's extensions or modules, then you can also customize the functionality of the OpenCart e-commerce framework and make an e-commerce site easier to administer and look better. You can also change the way the default OpenCart system works. In this book, you will learn about the third-party frameworks used in the OpenCart framework, such as Bootstrap, Font Awesome, and FlexSlider. Similarly, you will learn about the global methods used in OpenCart. We will create a custom theme and describe most of the code of the presentation layer. Then you will be able to get a description of the modules' code and create a custom module.
In OpenCart, modules are a way of customizing and extending the functionality of OpenCart. This book shows you how to create a customized theme and make all sorts of extensions: OpenCart modules, an Order Total module, the idea of creating payment and shipping modules, and ways of creating custom pages and forms on an OpenCart module to carry out insert, edit, delete, and list operations (the CRUD functionality).
This book focuses on teaching you all aspects of OpenCart's modules and themes by showing and defining code examples. We describe how to build a new theme and module from the default OpenCart theme and module. This book describes every line of code so that you will know what the code does. You will be cloning the default theme to make a new customized theme.
Each chapter teaches you how to create a new customized OpenCart theme. You will be able to create a customized theme and a Hello World module by cloning HTML. Likewise, you will get a description of every line of code of the default Featured module of OpenCart. Then we will create feedback pages used to manage feedback, and you will be able to create an Order Total module called Tips Order Total module.
Each chapter builds a practical theme and a module from the ground up using step-by-step instructions and examples.
What this book covers
Chapter 1, Getting Started with OpenCart 2.0, describes the structure of the files and folders of the default theme. This chapter shows you how to manage the layout and position of the module in a theme. You also learn the following: how to change the general settings of the images; module images; how to create and manage banners, carousels, and slideshows; and managing the layout.
Chapter 2, Bootstrap, Font Awesome, and FlexSlider in OpenCart 2 Themes, teaches you how OpenCart uses third-party frameworks, and how we can use them to design themes and modules easily, effectively, and efficiently. You get to learn these topics: why Bootstrap is used in OpenCart themes, basic templating with the use of the Bootstrap, and how to use Font Awesome and FlexSlider.
Chapter 3, Creating Custom Themes, gives a checklist to be taken into consideration for the header, footer, and other sections when creating a new custom theme. In this chapter, we change the style of the currency module, show it in a row, describe the code of the top category menu, and then style the top menu with different CSS. We describe most content area codes, such as the home, category, information, and contact us pages. We also edit CSS in a style sheet to change the background and get the knowledge to customize the theme and make a new design for the theme.
Chapter 4, Getting Started with OpenCart 2 Modules, starts off with modules in OpenCart. Here, you learn to clone the HTML content module into the Hello World module, and you are shown the way to install, configure, and uninstall an OpenCart module, and show the structures of admin and frontend files.
Chapter 5, Extensions Code, describes the code of extensions, lists all the global methods of OpenCart, shows you how to configure the feature product module, describes the code of the Featured module, shows you how to start coding for the shipping module, and describes the payment module.
Chapter 6, Create OpenCart Custom Pages, is where we create a listing page and a form page; perform actions such as data retrieval, insertion, and deletion; and show them in the frontend. You get to learn the ways to manage data and create a page to list it, insert data into the database, retrieve it (either to display or to edit), and finally delete the data. Likewise, we show you how to list the data at the frontend by creating the required page. In this way, you will be able to create modules and pages to manage data across OpenCart.
What you need for this book
You should have OpenCart installed and should