Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

What OpenCart is

OpenCart is a free open-source engine for an online shop, written in PHP. Out of the box it has a product catalog, a cart, a checkout, customer accounts and an admin panel. You install it, add products and the shop works — code is needed only when the shop must do something the engine cannot.

What is inside

PartWhat it does
StorefrontPages the customer sees: catalog, product, cart, checkout
Admin panelManaging products, orders, customers and settings
ExtensionsAdd-ons: modules, payment and shipping methods, themes

Everything you write yourself is packaged as an extension. Core files stay untouched, so the shop can be updated later.

Which version

The course covers OpenCart 4 — releases 4.0.2.x and 4.1.x. Version 4 is very different from versions 2 and 3: code uses namespaces, extensions live in their own folder, addresses are built differently.

Releases 4.0 and 4.1 also differ from each other in small details: method arguments, array keys, menu items. Where a detail depends on the release, the lesson says so. When in doubt, open the same file in the core of your copy and look how it is done there.

What it needs

WhatVersion
PHP8.0 or newer
DatabaseMySQL or MariaDB
Web serverApache or Nginx

OpenCart has no console tool like Artisan and does not require Composer for your own code. Files are created by hand in the right folder — the engine finds them by path.

What you will build

One example runs through the whole course — an extension called acme_hello:

extension/acme_hello/
├── install.json
├── admin/      settings page in the admin panel
└── catalog/    block and pages on the storefront

First you learn how a page works on a simple controller, then move the code into this extension, add settings, a table, events, and later a shipping and a payment method.

What to know beforehand

PHP at the level of classes and namespaces, basic SQL (SELECT, INSERT) and HTML. Templates are written in Twig — its syntax is explained in the templates lesson.

Common mistake

Most examples on the web are written for OpenCart 2 and 3 and do not work in version 4. Before copying code, check which version it targets. The sign of version 4 is a namespace Opencart\... line at the top of the file and paths starting with extension/.

Thanks for reading!

Donate to the site — we work hard for you.