Home Blog Page 19

Undefined property: Proxy::method in storage/modification/system/engine/action.php on line

Opencart error: Notice: Undefined property: Proxy::getLabels in /htdocs/storage/modification/system/engine/action.php on line 79

If you get an error like above then find the “getLabels” in your opencart directory and you can find two places like:

public function getLabels()
{

Or something like below of model reference or controller reference

$this->model_extension_module_outofstock->getLabels();

If it is model then check the class name of the model, for our example it should be like below:

class ModelExtensionModuleOutOfStock extends Model
{

Once you correct the class name then the proxy issue will be removed.

The main method is at system/engine/proxy.php

public function __call($key, $args) {
	$arg_data = array();
	
	$args = func_get_args();
	
	foreach ($args as $arg) {
		if ($arg instanceof Ref) {
			$arg_data[] =& $arg->getRef();
		} else {
			$arg_data[] =& $arg;
		}
	}
	
	if (isset($this->{$key})) {		
		return call_user_func_array($this->{$key}, $arg_data);	
	} else {
		$trace = debug_backtrace();
		
		exit('<b>Notice</b>:  Undefined property: Proxy::' . $key . ' in <b>' . $trace[1]['file'] . '</b> on line <b>' . $trace[1]['line'] . '</b>');
	}
}

Hope this helps someone, let us know if you have any questions or issues so that we try to solve it. We have listed out errors that you may get in Opencart and their solutions at:

How to make the custom language pack in OpenCart 4?

In this Opencart tutorial, we will show you easy localization, and how to make the language pack in OpenCart 4. We will use “Nepalese” or “Nepali” as a new language as there is no language pack for Nepali. Once we created the language pack then we will add and activate in the OpenCart.

Time needed: 1 hour

Localization or globalization is done by making the Opencart language pack. Here are the steps to make the language pack:

  1. Create a language folder in admin/ folder

    Go to admin/language then copy en-gb/ folder and paste it and change the folder name to your language name.
    In our example, we name it “ne”.

  2. Change the flag and main language name file

    Find the flag for your language, preferable transparent png with 16*16 size. Go to admin/language/ne and then place there with the same name as code. In Nepali, it is “ne” so we make it ne.png
    Change the filename admin/language/ne/en-gb.php to admin/language/ne/ne.php

  3. Change code name to your language

    Find your language code, for Nepali, it is “ne”, now open admin/language/ne/ne.php, and change Locale code. Like:

    $_[‘code’] = ‘ne’;

    You can find the lists of ISO 639-1 Language Codes at W3Schools.

    Change others as per your language like direction, date format short, date format long, time format, decimal point, thousand points.

  4. Now start adding your language text

    Open each and every ***.php and change English text to your language text except the variable in $_[‘DONTCHANGE’]. For example, if you open admin/language/ne/ne.php then you need to change the

    $_[‘text_yes’] = ‘Yes’;
    to
    $_[‘text_yes’] = ‘हुन्छ’;

    Just change values after the equal sign. Do the same for all of the others then your admin language is ready to install.

    Opencart language pack

  5. Similarly, we need to do the same thing in the catalog/ folder, so the first step, create a language folder in the catalog/language folder

    Go to catalog/language then copy the en-gb and paste it and change the name to your language.
    In our example, we name it “ne”.

  6. Change the filename to language name and flag name to language name in catalog/ folder

    Go to catalog/language/ne and add the flag related to the country and name it as per the language code. In our example, we named it ne.png. Previously in Opencart 2.0, they had collections of flags, but now they removed in 3.0, if you still need lists of small flags collection then you can download from download small flags.
    Then, rename the en-gb.php to ne.php

  7. Replace code name to your language in catalog/ folder also

    Open catalog/language/ne/ne.php and change $_[‘code’]= ‘en’; to

    $_[‘code’] = ‘ne‘;

    Similarly if needed change other Locale as per language needs.

  8. Start changing English text to your language text in catalog/language/ne folder

    Open each and every ***.php and change English text to your language text except the variable in $_[‘DONTCHANGE’]. For example, if you open catalog/language/ne/ne.php then you need to change the

    $_[‘text_yes’] = ‘Yes’;
    to
    $_[‘text_yes’] = ‘हुन्छ’;

    Create Opencart language pack

  9. Now make a ***.ocmod.zip

    Create upload/ folder and add the admin/ and catalog/ folder and inside the admin/ folder create language/ folder and then copy the translated folder. Here we copy the ne/ folder. Then, make zip and name ****.ocmod.zip. Your extension is ready to add.
    Language pack folder structure

How to add the language in Opencart?

  • Go to Extensions >> Installer and upload the ***.ocmod.zip
  • Go to Extensions >> Modifications and Refresh it
  • Go to System >> Localisation >> Languages
  • Then add the language, in our Nepali case it is something like below:
    How to add language in Opencart
  • Select the folder of your language at Code select box.
  • If you see “Warning: You added before the language!” then ignore for the first time and save again.
  • Your language is active.

Please don’t forget to post your questions or comments so that we can add extra topics, free modules, or Opencart tutorials that we need to develop which helps to develop quality. You can follow our Twitter account @rupaknpl and subscribe to the YouTube user Opencart tutorial. Thanks a lot.

OCMOD free module to show product availability on categories pages and modules

This Opencart free Ocmod module will show product availability on categories pages and in the featured module, bestseller module, lastest module and in special module. By default when the product quantity is greater than zero, it will show Availability: In Stock, if the product quantity is zero then it will show the product status assigned while entering the products.

Status is shown when a product is out of stock the one selected below. The default options are: In Stock, Pre-Order, Out Of Stock, and 2-3 Days:

Out of Stock Opencart

Download the module by clicking the below button and go to admin >> Extensions >> Installer >> then upload the downloaded product-availability.ocmod.zip. If you are having an installation problem then watch this video

After that go to admin >> Extensions >> Modifications and clear the cache and you will see the changes in a featured module like the one below:

Featured module Product Availability

Read more: Opencart 4 OCMoD Tutorial

Likewise, you can see the availability in categories pages like below:

Show availability in category page

Please don’t forget to post your questions or comments so that we can add extra topics, free modules, or opencart tutorials that we need to develop which helps to develop quality. You can follow at the Twitter account @rupaknpl and subscribe to the YouTube user opencart tutorial. Thanks a lot.

How to see all variables available in twig template in Opencart?

In Opencart, we can see all the variables that are available in the twig template by just adding the following code in twig page.

<ol>
    {% for key, value in _context  %}
      <li>{{ key }}</li>
    {% endfor %}
</ol>

For e.g., if we want to see all the variables that are on the account login page, then open to catalog/view/theme/default/template/account.twig and paste above code now it will be like below:

Opencart Twig Variables

Now the output will be like below:

Opencart variables twig

Here are the variables available in the account login page.

breadcrumbs
error_warning
action
register
forgotten
redirect
success
email
password
column_left
content_full
content_full_bottom
column_right
content_top
content_bottom
footer
header
code
direction
date_format_short
date_format_long
time_format
datetime_format
decimal_point
thousand_point
text_home
text_yes
text_no
text_none
text_select
text_all_zones
text_pagination
text_loading
text_no_results
button_address_add
button_back
button_continue
button_cart
button_cancel
button_compare
button_wishlist
button_checkout
button_confirm
button_coupon
button_delete
button_download
button_edit
button_filter
button_new_address
button_change_address
button_reviews
button_write
button_login
button_update
button_remove
button_reorder
button_return
button_shopping
button_search
button_shipping
button_submit
button_guest
button_view
button_voucher
button_upload
button_reward
button_quote
button_list
button_grid
button_map
error_exception
error_upload_1
error_upload_2
error_upload_3
error_upload_4
error_upload_6
error_upload_7
error_upload_8
error_upload_999
error_curl
datepicker
backup
heading_title
text_account
text_login
text_new_customer
text_register
text_register_account
text_returning_customer
text_i_am_returning_customer
text_forgotten
entry_email
entry_password
error_login
error_attempts
error_approved
text_logout
text_edit
text_password
text_address
text_wishlist
text_order
text_download
text_reward
text_return
text_transaction
text_newsletter
text_recurring
text_information
text_service
text_extra
text_contact
text_sitemap
text_manufacturer
text_voucher
text_affiliate
text_special
text_powered
text_shopping_cart
text_category
text_checkout
text_search
text_all
text_language
text_currency
text_items
text_empty
text_cart
text_sub_total
text_credit
text_order_id
text_total
_parent

Let us know if you have any questions or suggestions.

Opencart 3 free module to list or display all Reviews of products on one page

This Opencart 3 free module or extension is to list out or display all reviews of products on a page. This is one instance module. It lists out the product name, small description of the product, star rating given to the product and the details of the review and the reviewer name and date with the totals reviews for that product and link to it and products add to cart button, wishlist button, and compare button.

First, download the module by clicking the button below

Go to Admin >> Extensions >> Installer and upload the opencart-reviews-listing.ocmod.zip

Then, go to Admin >> Extensions >> Extensions >> Choose Modules >> Install the All reviews module then edit it. If you need more details on how to install extensions then watch it.

Admin section setting

You will see the admin setting for All reviews module like below:

All reviews show Opencart module

Enter the details.

  • Heading Title at Listing Page
  • Meta Description and Short description
  • Number of Reviews to show in a page
  • Product Image Width
  • Product Image Height
  • Show link in the main menu
  • Status

Frontend

Then in the browser go to https://YOURURL/index.php?route=extension/product/allreviews,

All reviews listing opencart free module

See the demo here: https://webocreation.com/nepalbuddha/index.php?route=extension/product/allreviews

Please don’t forget to post your questions or comments so that we can add extra topics, free module or opencart tutorial that we need to develop which helps to develop ourselves and quality. You can follow at twitter account @rupaknpl and subscribe to YouTube user opencart tutorial. Thanks a lot. Enjoy!

Opencart theme development environment setting up automation: Gulp, package.json, Yarn NPM setup

In this Opencart tutorial, we are setting up the OpenCart theme development environment with a gulp, package.json, yarn or NPM, create files and folder structure for development with the use of SCSS and custom JS and with gulp watch we output them in normal OpenCart theme.

We are already known about AMP(Apache, MySQL, PHP) stack with MAMP, install Opencart 3.0.3.2 and get used to the admin interface and files and folder structure of OpenCart. We are using Microsoft Visual Studio code as an Integrated development environment. Before you start this please have a look at this post where we show you how to make the custom theme in OpenCart with the base theme.

Opencart 3 Theme Gulp, SCSS, ES6 set up

We set up the automation tools for custom themes development, it may not be required for simple development but better to have them for continuous development. Steps for setting up the Opencart theme development environment and its automation can be below:

  1. Download https://github.com/rupaknepali/opencart-theme-developement-gulp-setup/archive/master.zip or clone this repo https://github.com/rupaknepali/opencart-theme-developement-gulp-setup
  2. Go to catalog/view/theme, paste this folder, unzip and rename the folder opencart-theme-development-gulp-setup to your theme name.
  3. Then in terminal go to catalog/view/theme/YOURTHEME/dev and run ‘npm install
  4. After all npm packages installed, open dev/gulpfile.js and change the proxy URL “opencart.loc” to your localhost URL
  5. Then in terminal go to catalog/view/theme/YOURTHEME/dev and run “gulp” and then “gulp watch”
  6. Now make changes in the YOURTHEME/dev/scss files or YOURTHEME/dev/js files or YOURTHEME/dev/image or YOURTHEME/dev/fonts, now you will see the changes.
  7. Now you can start the customization
  8. The following are the files and folders structure.
File and folder structure for theme development

If someone needs more details about the setup then the following steps can help you to set up from the beginning of the Opencart theme development, here we will install node, npm, gulp packages, npm packages as needed and run the gulp to minify CSS and JS and convert the ES6 JS with babel

  1. Download and Install the Node.js

    Go to https://nodejs.org and download the latest version and install it

  2. Install Gulp with npm

    npm install gulp-cli -g

  3. Set up gulpfile.js

    Navigate to your custom theme directory and create dev/ folder then inside it create a JavaScript file named gulpfile.js and paste the following code in it

    https://raw.githubusercontent.com/rupaknepali/opencart-theme-developement-gulp-setup/master/dev/gulpfile.js

  4. Create folders SCSS, Image, JS, Fonts

    These folders hold files where we make changes the changes and the gulp will compile and create files and folders outside of dev/ folder

  5. Set up the package manager

    Type ‘npm init‘ in your terminal from the dev folder as created in step 3. Enter the details that init asked.

  6. Install Dependencies that are needed for gulp.js

    Type ‘npm install –save-dev <packagename> in your terminal, which will download gulp files and its associated dependencies and will create a folder ‘node_modules’. For ours we need:

    npm -i babel/core babel/preset-env babelify browser-sync browserify browserify-shim gulp gulp-autoprefixer gulp-concat gulp-if gulp-notify gulp-options gulp-plumber gulp-rename gulp-sass gulp-sourcemaps gulp-strip-debug gulp-uglify gulp-uglifycss vinyl-buffer vinyl-source-stream

    You can see in package.json following are the dev dependencies:

    “devDependencies”: {
            “@babel/core”: “^7.5.5”,
            “@babel/preset-env”: “^7.5.5”,
            “babelify”: “^10.0.0”,
            “browser-sync”: “^2.26.7”,
            “browserify”: “^16.3.0”,
            “browserify-shim”: “^3.8.14”,
            “gulp”: “^4.0.2”,
            “gulp-autoprefixer”: “^6.1.0”,
            “gulp-concat”: “^2.5.2”,
            “gulp-if”: “^3.0.0”,
            “gulp-notify”: “^3.0.0”,
            “gulp-options”: “^1.1.1”,
            “gulp-plumber”: “^1.2.1”,
            “gulp-rename”: “^1.2.0”,
            “gulp-sass”: “^4.0.2”,
            “gulp-sourcemaps”: “^2.6.5”,
            “gulp-strip-debug”: “^3.0.0”,
            “gulp-uglify”: “^3.0.2”,
            “gulp-uglifycss”: “^1.0.9”,
            “vinyl-buffer”: “^1.0.0”,
            “vinyl-source-stream”: “^2.0.0”
        }

  7. Add some other setting in package.json

    “babel”: {
    “presets”: [
    “@babel/preset-env”
    ]
    },
    “browserify”: {
    “transform”: [
    “browserify-shim”
    ]
    },
    “browser”: {
    “jquery”: “./node_modules/jquery/dist/jquery.js”
    },
    “browserify-shim”: {
    “jquery”: “$”
    },
    “browserslist”: [
    “last 2 version”,
    “> 2%”
    ],

  8. Our full package.json looks like:

    {
        “name”: “opencart-gulp-4-es6”,
        “version”: “1.1.0”,
        “description”: “Opencart theme development with Gulp 4 file setup for Javascript ES6 compiling, plus SCSS, images, and fonts”,
        “author”: “Rupak Nepali <webocreation.com@gmail.com> (https://webocreation.com)”,
        “repository”: {
            “type”: “git”,
            “url”: “https://github.com/rupaknepali/opencart-theme-developement-gulp-setup”
        },
        “keywords”: [
            “opencart”,
            “gulp”,
            “es6”,
            “scss”
        ],
        “devDependencies”: {
            “@babel/core”: “^7.5.5”,
            “@babel/preset-env”: “^7.5.5”,
            “babelify”: “^10.0.0”,
            “browser-sync”: “^2.26.7”,
            “browserify”: “^16.3.0”,
            “browserify-shim”: “^3.8.14”,
            “gulp”: “^4.0.2”,
            “gulp-autoprefixer”: “^6.1.0”,
            “gulp-concat”: “^2.5.2”,
            “gulp-if”: “^3.0.0”,
            “gulp-notify”: “^3.0.0”,
            “gulp-options”: “^1.1.1”,
            “gulp-plumber”: “^1.2.1”,
            “gulp-rename”: “^1.2.0”,
            “gulp-sass”: “^4.0.2”,
            “gulp-sourcemaps”: “^2.6.5”,
            “gulp-strip-debug”: “^3.0.0”,
            “gulp-uglify”: “^3.0.2”,
            “gulp-uglifycss”: “^1.0.9”,
            “vinyl-buffer”: “^1.0.0”,
            “vinyl-source-stream”: “^2.0.0”
        },
        “babel”: {
            “presets”: [
                “@babel/preset-env”
            ]
        },
        “browserify”: {
            “transform”: [
                “browserify-shim”
            ]
        },
        “browser”: {
            “jquery”: “./node_modules/jquery/dist/jquery.js”
        },
        “browserify-shim”: {
            “jquery”: “$”
        },
        “browserslist”: [
            “last 2 version”,
            “> 2%”
        ],
        “license”: “GPL-3.0”,
        “dependencies”: {
            “gulp-clean-css”: “^4.2.0”,
            “gulp-concat-css”: “^3.1.0”
        }
    }

  9. Running automation tool from cmd/terminal.

    Now type ‘gulp ‘ and then ‘gulp watch’

    Opencart Gulp

  10. You will see the browser opened at localhost:3000

    Make the changes in SCSS files, JS files, twig files, add images and fonts and the browser reload will happen and you will see the changes.

How to clone the default theme of Opencart 3 to custom theme?

In this Opencart tutorial, we will show how to create a custom Opencart 3 theme. We will go through the default theme files and folders and then clone default theme to custom theme, install the custom theme, activate it and change the CSS of the custom theme.

First, let’s go through the default core theme files and folders of OpenCart:

In the admin section following are the theme files:

  • admin/controller/extension/theme/default.php
  • admin/language/en-gb/extension/theme/default.php
  • admin/view/template/theme/default.twig

In the catalog section, all the files and folders inside the catalog/view/theme/default are of the default theme.

Now, let’s clone the default theme to a custom theme, for that let’s do the following:

Opencart custom theme files and folders

We are going to create a “webocreation” theme, you can name is anything. Let’s start cloning the files:

  • Go to admin/controller/extension/theme/ and copy default.php and paste it and rename it to webocreation.php, then open it in your editor.
  • Now find the default word and replace it with webocreation.
  • Next, go to admin/language/en-gb/extension/theme/ and copy default.php and paste it and rename it to webocreation.php, then open it in your editor.
  • Do the same, find the default word, and replace it with webocreation.
  • Next, go to admin/view/template/extension/theme/ and copy default.twig and paste it and rename it to webocreation.php, then open it in your editor.
  • Do the same, find the default word, and replace it with webocreation.
  • Now go to catalog/view/theme and copy the whole default folder and paste it and rename the folder to webocreation.
  • Go to catalog/view/theme/webocreation/image and copy default.png and paste it and rename it to webocreation.png
  • Finally go to catalog/view/theme/webocreation/template/common/ and open header.twig and then find default and replace it with webocreation.
  • With this, our webocreation opencart theme is created.

Now let’s activate the webocreation Opencart theme.

  • Log in to the Admin section and in the left menu, navigate to Extensions >> Extensions >> Then choose the Themes in extension type.
  • You will see the themes list, where we will see our Webocreation Store Theme also
  • Click the Install button
  • Then edit it
  • In the Theme Directory choose the “webocreation”
  • Choose Status to Enabled
  • Then enter the details as per your requirement, enter the width and height of images, then click save.
  • Now navigate to System >> Settings >> Edit your store >> and in General tab >> Theme >> select the “Webocreation Store Theme”
  • Your webocreation theme is activated.
Opencart theme settings

Let’s see a demo if really webocreation theme is active

  • Go to catalog/view/theme/webocreation/stylesheet/ and open stylesheet.css and change the color of heading, find the following code:
h1, h2, h3, h4, h5, h6 {
	color: #444;
}

Replace the above code with the following:

h1, h2, h3, h4, h5, h6 {
	color: #64ccc9;
}

If everything is ok then you will see changes in the heading titles, now you can perform any changes you like in the CSS and make it different than the default OpenCart theme.

Let us know if you have any questions or suggestions. In the next post, we will set up a local development environment and setup gulp, package.json, yarn, or NPM and be ready to use the SCSS, minification, and optimization for rapid theme development.

How to install OpenCart on a CentOS VPS

This Opencart tutorial is to show you how to install OpenCart on a CentOS-7 64bit which is an Enterprise-class Linux Distribution VPS (Virtual Private Servers), we install Apache, PHP, MySQL, other PHP packages as needed by Opencart and setup virtual host

Login to your VPS

ssh root@IPPROVIDED

Then enter the password.

Now update your system before installing the applications, by updating your server using the command below

sudo yum update

Now install the apache web server by running the command, if it is already installed then you can skip this step as mostly there are installed

sudo yum install httpd

Now start the apache service, which you can do it by the following command as per your system

sudo service httpd start

Till now you can check by typing the IP address provided, you will see the Apache page, mine IP http://178.33.153.139/ and it shows like below:

Better to activate Apache to start after system boot which we can do by the following command:

chkconfig httpd on

Next, install the MySQL server using the following command:

sudo yum install mysql-server

Tell it which run levels to start on:

sudo /sbin/chkconfig --levels 235 mysqld on

Then start the MYSQL server

sudo service mysqld start

To improve the security of your MySQL server, it is recommended to run the interactive security script. You can do that by using the following command:

sudo mysql_secure_installation

Then it asks multiple questions to set the username and password for the database. Once you remove the anonymous users, then disallowing root login remotely, removing test database and reloading privileges on test database then your MySQL installation should be secure.

Like we did for Apache let’s run the MySQL on reboot by the following command:

chkconfig mysqld on

Now let’s install PHP and the other requirements that are needed for the OpenCart, you need to run the command:

sudo yum install php libapache2-mod-php php-mcrypt php-mysql curl php-curl php-gd php-zip

Once all those PHP packages are installed, our server is almost ready. Next, let’s download and configure OpenCart on your VPS by using the commands below:

sudo mkdir /var/www/html/opencart
cd /var/www/html/opencart
sudo wget https://github.com/opencart/opencart/archive/master.zip
sudo unzip master.zip
sudo mv opencart-master/upload/* .
sudo mv opencart-master/upload/.htaccess.txt .htaccess
sudo rm -f master.zip
sudo cp config-dist.php config.php
sudo cp admin/config-dist.php admin/config.php
sudo chown -R www-data: /var/www/html/opencart
sudo chmod 0755 system/storage/cache/
sudo chmod 0755 system/storage/logs/
sudo chmod 0755 system/storage/download/
sudo chmod 0755 system/storage/upload/
sudo chmod 0755 system/storage/modification/
sudo chmod 0755 image/
sudo chmod 0755 image/cache/
sudo chmod 0755 image/catalog/
sudo chmod 0755 config.php
sudo chmod 0755 admin/config.php

Let’s add Nano Text Editor

yum install nano

Next, create an Apache virtual host for OpenCart

sudo nano /etc/httpd/conf/httpd.conf

Add the following VirtualHost content:

<VirtualHost *:80>
    ServerAdmin admin@domain.com
    DocumentRoot /var/www/html/opencart
    ServerName domain.com
    ServerAlias www.domain.com 
    <Directory /var/www/html/opencart/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory> 
    ErrorLog /var/log/httpd/domain.com-error_log
    CustomLog /var/log/httpd/domain.com-access_log common
</VirtualHost>

Replace domain.com with your actual domain name.

Enable the OpenCart virtual host and restart the Apache webserver using the following commands:

sudo a2ensite opencart
sudo service httpd restart

Login to the MySQL database

mysql -u root -p

Create a MySQL database, user and set up a password for OpenCart:

CREATE DATABASE webocreation;
GRANT ALL PRIVILEGES ON webocreation.* TO 'webocreationuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Replace webocreation with your database name, webocreationuser with your username and password with your password.

Open a web browser and enter your domain name and start the installation.

Let us know any questions about the VPS Virtual Private Servers and any questions about OpenCart in the comment below.

Opencart 3 custom module development tutorial – Hello World module

In this Opencart 3 tutorial we are showing how to create Opencart 3 custom modules or extensions, this tutorial is for the developer and to add the custom functionalities in the Opencart. Check our hello world workflow.

Modules listing in Opencart admin
  • Before you start, watch the following videos tutorial
  • Then start to work in the admin folder for module management
    For Opencart 2 follow this post: How to create the controller for the Opencart custom module?
    For Opencart 3, it is similar to Opencart 2 with some changes in the view section, which we are showing below.
    • To create the Controller in OpenCart 3, we need to understand at least four methods (index, install, validate and uninstall)
    • To create the language file in OpenCart 3, we need to understand how to create variable and how we can load it in the controller and how it automatically get variable access to view.
    • To create the view in Opencart 3, we need to know twig templating.
  • Then start to work in the catalog for module show in front or presentation
    • It also needed three files language, controller and view
  • Before starting, things to consider while creating the modules are as per Daniel are:
    • You are not allowed to modify any core DB tables. If you need to store any data for your extension you need to create a new table and use joins. But you can insert it into the setting table as the configuration are added to it
    • You are not allowed to overwrite any files.
    • All files are only allowed to be written in extension folders, except templates which of course go under the template folder.
    • All extension should have an admin page that allows configuration
    • Extensions are now prefixed by their category. so paypal_status would become payment_paypal_status
  • Here is the files and folders structure of Hello World module
Hello world opencart

OpenCart identifies existing modules automatically, simply by reading the admin/controller/extension/module folder. Any modules existing in this folder will automatically be shown on the Modules listing page, and on the User Permissions page.

More detail for Opencart 2 are at https://webocreation.com/admin-controller-file-make-hello-world-module-opencart-module-development/

Let’s start with Admin Controller

The file to create is helloworld.php and it should be inside admin/controller/extensions/module/ and start with the following boilerplate code:

<?php
class ControllerExtensionModuleHelloworld extends Controller
{
	private $error = array();
	public function index()
	{ }
	protected function validate()
	{ }
	public function install()
	{ }
	public function uninstall()
	{ }
}

In OpenCart, Every class name of the module should start with ControllerExtensionModule, here in the hello world module, our folder structure is controller >> extension >> module >> helloworld.php so the class name is ControllerExtensionModuleHelloworld then extends the class with the base class controller. Better to have all the four methods index() will run when the controller is loaded or someone clicks the edit button, validate() checks for the admin access and other data validation, install() method runs when we click the install button on the module list page, and uninstall() method runs when we click the uninstall button.

private $error = array();
$error is just a private array which will hold the values if some error occurs, we assign error if users don’t have access, or submitted data are not valid.

Installation method:

This method is called when someone clicks the install + button

public function install()
{
	$this->load->model('setting/setting');
	$this->model_setting_setting->editSetting('module_helloworld', ['module_helloworld_status' => 1]);
}

Here we load the setting model, you can see the editSetting() method at controller >> model >> setting >> setting.php. When the install button is clicked then it deletes all the settings it had with the same code and installs the all values again. While passing the values don’t forget to include the extension in front of the name. Like here our extension is module and name is HelloWorld so it becomes module_helloworld and the same for the variables you are going to save, we are saving the status so module_helloworld_status which need to pass as an array. Let see the setting database table, and you will see how values are stored.

Opencart setting database table

The convention is to add module_ or payment_ or shipping_ or report_ or dashboard_ etc as per your extensions type so it is supported in the cloud base as well.

After installation, we click the edit blue button, which calls the index method whose full code is below which we will describe afterward:

public function index()
{
	$this->load->language('extension/module/helloworld');
	$this->document->setTitle($this->language->get('heading_title'));
	$this->load->model('setting/module');
	if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
		if (!isset($this->request->get['module_id'])) {
			$this->model_setting_module->addModule('helloworld', $this->request->post);
		} else {
			$this->model_setting_module->editModule($this->request->get['module_id'], $this->request->post);
		}
		$this->session->data['success'] = $this->language->get('text_success');
		$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true));
	}
	if (isset($this->error['warning'])) {
		$data['error_warning'] = $this->error['warning'];
	} else {
		$data['error_warning'] = '';
	}
	if (isset($this->error['name'])) {
		$data['error_name'] = $this->error['name'];
	} else {
		$data['error_name'] = '';
	}
	$data['breadcrumbs'] = array();
	$data['breadcrumbs'][] = array(
		'text' => $this->language->get('text_home'),
		'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
	);
	$data['breadcrumbs'][] = array(
		'text' => $this->language->get('text_extension'),
		'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)
	);
	if (!isset($this->request->get['module_id'])) {
		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'], true)
		);
	} else {
		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true)
		);
	}
	if (!isset($this->request->get['module_id'])) {
		$data['action'] = $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'], true);
	} else {
		$data['action'] = $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true);
	}
	$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true);
	if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
		$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
	}
	if (isset($this->request->post['name'])) {
		$data['name'] = $this->request->post['name'];
	} elseif (!empty($module_info)) {
		$data['name'] = $module_info['name'];
	} else {
		$data['name'] = '';
	}
	$this->load->model('localisation/language');
	$data['languages'] = $this->model_localisation_language->getLanguages();
	if (isset($this->request->post['status'])) {
		$data['status'] = $this->request->post['status'];
	} elseif (!empty($module_info)) {
		$data['status'] = $module_info['status'];
	} else {
		$data['status'] = '';
	}
	$data['header'] = $this->load->controller('common/header');
	$data['column_left'] = $this->load->controller('common/column_left');
	$data['footer'] = $this->load->controller('common/footer');
	$this->response->setOutput($this->load->view('extension/module/helloworld', $data));
}

Let start understand in detail:

$this->load->language('extension/module/helloworld');

This is to load the language file admin >> language >> en-gb (or active language) >> extension >> module >> helloworld.php. Let’s create the language file and add some variables needed:

<?php
// Heading
$_['heading_title']     = 'Hello World Content';
// Text
$_['text_extension']    = 'Extensions';
$_['text_success']      = 'Success: You have modified Hello World Content module!';
$_['text_edit']         = 'Edit Hello World Content Module';
// Entry
$_['entry_name']        = 'Module Name';
$_['entry_title']       = 'Heading Title';
$_['entry_status']      = 'Status';
// Error
$_['error_permission']  = 'Warning: You do not have permission to modify Hello World Content module!';
$_['error_name']        = 'Module Name must be between 3 and 64 characters!';

Now to get access to heading_title in the controller we do like below:

$this->language->get('heading_title')

To assign that heading_title as Title of the page we pass the $this->document->setTitle, click to know all of the objects’ methods of opencart

$this->document->setTitle($this->language->get('heading_title'));

Below is the code of how we define the breadcrumbs array and assign in the data variable and pass it to view.

$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
	'text' => $this->language->get('text_home'),
	'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
);
$data['breadcrumbs'][] = array(
	'text' => $this->language->get('text_extension'),
	'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)
);
if (!isset($this->request->get['module_id'])) {
	$data['breadcrumbs'][] = array(
		'text' => $this->language->get('heading_title'),
		'href' => $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'], true)
	);
} else {
	$data['breadcrumbs'][] = array(
		'text' => $this->language->get('heading_title'),
		'href' => $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true)
	);
}

In the code above we use $this->language->get(‘text_home’) so you may got confused how we got text_home variable although we don’t define in admin >> language >> en-gb >> extension >> module >> helloworld.php, so the trick is we can get access to all variables of admin >> language >> en-gb >> en-gb.php we don’t need to load like other language file. So the breadcrumb here is to create the breadcrumbs array then assign the Home and dashboard URL, then added another link Extension and URL to module page. Then we check if the module is an edited or a new module and show the title and link of respective modules.

Now let’s move to another part of the code, the below part of the code is to create the action URL when someone submits or save the form. Here it checks if it is an active module or not and if it is an active module then it passes module_id in the URL

if (!isset($this->request->get['module_id'])) {
	$data['action'] = $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'], true);
} else {
	$data['action'] = $this->url->link('extension/module/helloworld', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true);
}

In OpenCart module setting mostly, they have to save button and cancel button so below is the link when someone is redirected when they click the cancel button.

$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true);

The below code is to check if the module exists and if then get the available module information of that module.

if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
	$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
}

The below code is to set the data of the fields to pass to the view. Here we check if the module name is set or module description and the status like below if nothing is set then we assign the empty.

if (isset($this->request->post['name'])) {
	$data['name'] = $this->request->post['name'];
} elseif (!empty($module_info)) {
	$data['name'] = $module_info['name'];
} else {
	$data['name'] = '';
}

if (isset($this->request->post['module_description'])) {
	$data['module_description'] = $this->request->post['module_description'];
} elseif (!empty($module_info)) {
	$data['module_description'] = $module_info['module_description'];
} else {
	$data['module_description'] = array();
}

if (isset($this->request->post['status'])) {
	$data['status'] = $this->request->post['status'];
} elseif (!empty($module_info)) {
	$data['status'] = $module_info['status'];
} else {
	$data['status'] = '';
}

This below code is to pass the languages to the view, as OpenCart supports multi-language so we are showing you how module_description and status can be set as per the language.

$this->load->model('localisation/language');
$data['languages'] = $this->model_localisation_language->getLanguages();

The below are the data to pass the header, column left and the footer to the view.

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

The below code is to set the response output to view.

$this->response->setOutput($this->load->view('extension/module/helloworld', $data));

When someone saves the module then following code run and save the module data in an oc_module table in the JSON format.

$this->load->model('setting/module');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
	if (!isset($this->request->get['module_id'])) {
		$this->model_setting_module->addModule('helloworld', $this->request->post);
	} else {
		$this->model_setting_module->editModule($this->request->get['module_id'], $this->request->post);
	}
	$this->session->data['success'] = $this->language->get('text_success');
	$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true));
}
module database defined of Opencart

When someone submits the form it validates the data with the validate() method as we call it in index() method like $this->validate(), in validate method we mostly check for the permission and define any other validation needed.

protected function validate()
{
	if (!$this->user->hasPermission('modify', 'extension/module/helloworld')) {
		$this->error['warning'] = $this->language->get('error_permission');
	}

	if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 64)) {
		$this->error['name'] = $this->language->get('error_name');
	}

	return !$this->error;
}

Now the last part of the controller is the uninstall method, it uninstalls and removes all the data when someone clicks the uninstall red button.

public function uninstall()
{
	$this->load->model('setting/setting');
	$this->model_setting_setting->deleteSetting('module_helloworld');
}

Now our last part of admin View or presentation part, as opencart started to use the twig templating so here is the full code of the view part:

{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-module" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
      <button type="button" class="close" data-dismiss="alert">×</button>
    </div>
    {% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_edit }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-module" class="form-horizontal">
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-name">{{ entry_name }}</label>
            <div class="col-sm-10">
              <input type="text" name="name" value="{{ name }}" placeholder="{{ entry_name }}" id="input-name" class="form-control" />
              {% if error_name %}
              <div class="text-danger">{{ error_name }}</div>
              {% endif %}
            </div>
          </div>
          <div class="tab-pane">
            <ul class="nav nav-tabs" id="language">
              {% for language in languages %}
              <li><a href="#language{{ language.language_id }}" data-toggle="tab"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</a></li>
              {% endfor %}
            </ul>
            <div class="tab-content">
              {% for language in languages %}
              <div class="tab-pane" id="language{{ language.language_id }}">
                <div class="form-group">
                  <label class="col-sm-2 control-label" for="input-title{{ language.language_id }}">{{ entry_title }}</label>
                  <div class="col-sm-10">
                    <input type="text" name="module_description[{{ language.language_id }}][title]" placeholder="{{ entry_title }}" id="input-heading{{ language.language_id }}" value="{{ module_description[language.language_id] ? module_description[language.language_id].title }}" class="form-control" />
                  </div>
                </div>
              </div>
              {% endfor %}
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
            <div class="col-sm-10">
              <select name="status" id="input-status" class="form-control">
                {% if status %}
                <option value="1" selected="selected">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
                {% else %}
                <option value="1">{{ text_enabled }}</option>
                <option value="0" selected="selected">{{ text_disabled }}</option>
                {% endif %}
              </select>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
  
  <script type="text/javascript"><!--
$('#language a:first').tab('show');
//--></script></div>
{{ footer }}

Here is the output of the view:

Hello world content settings of Opencart

The variable we passed from the controller can be accessible in template file which we can show easily with {{variable_name}}, so we can show header, column left and footer like below:

{{ header }}{{ column_left }}{{ footer }}

All other codes are simple in the view part only thing little complicate is the language for loop section and how we add form field name which will be saved in the database. Here heading title and status are language-specific.

Now the front end part so let’s start to create a file in catalog/ folder, go to catalog >> controller >> extension >> module and create helloworld.php and paste the following code:

<?php
class ControllerExtensionModuleHelloworld extends Controller
{
	public function index($setting)
	{
		if (isset($setting['name'][$this->config->get('config_language_id')])) {
			$data['html'] = html_entity_decode($setting['module_description'][$this->config->get('config_language_id')]['title'], ENT_QUOTES, 'UTF-8');
			return $this->load->view('extension/module/helloworld', $data);
		}
	}
}

Mostly same conventions to follow as for the admin controller as we define above, here we need to pass the $setting in the index method and all values and data of module is available for your in $setting, if you are confused just do the print_r($setting) and you will get all the details data of the module. Here we check if the module is active and just show the title that we entered in the backend.

View section is also pretty simple in the frontend. Go to catalog >> view >> theme >> default >> template >> extension >> module >> helloworld.twig and enter the code below:

<div>
  {% if html %}
      <h2>{{ html }}</h2>
  {% endif %}
</div>

It check if the html is not empty and if not empty then show the html content.

Now all of our code is ready, now you can show it in your desired layout as per requirement. If you are confused about how to install the module and set the configuration then this video helps.

Comment below or let us know if you have any questions or suggestions.

Workflow or markup to make hello world module – OpenCart Module Development

When we created the hello world module then it will be like as shown below:

Hello World Module in Extension’s Module

hello world module opencart extension listing

Installing Hello World Module

Click on the green (install) button, then click edit blue button. You will see a form to insert the hello world text.

Hello World Module form

helloworld form opencart module development

Enter the hello world text and select the status to enabled and click the save button. As Opencart can have unlimited module instance, so we can have multiple instances of the hello world

Set up layout and position for Hello World Module

To setup layout and position, go to Design >> Layout, edit Information layout then add the hello world module to the column left.

hello world module layout and position

Show up in Front/Presentation side

As we added to the column left of the information page, let’s go to the front page about us page URL.
/index.php?route=information/information&information_id=4

hello world front presentaion opencart

Files and folder creation

  • Making language file in admin/ for Hello World Module
  • Making the controller file in admin/ for Hello World Module
  • Making view file in admin/ for Hello World Module
  • Making language file in catalog/ for Hello World Module
  • Making the controller file in catalog/ for Hello World Module
  • Making view file in catalog/ for Hello World Module
Hello world opencart files and folders structure

Now go to full details to create a hello world module in OpenCart

Thanking you
webocreation.com@gmail.com
twitter
:@rupaknpl

youtube

 : onlinegyannepal

https://webocreation.com

Opencart 3 OCMOD coding tutorial

In this tutorial, we are showing you how to write code in OCMOD and modify the core files of OpenCart. Here we will show the flows that happened when someone uploads the ***.ocmod.zip file, then create an install.xml file to show the module link in the left column and give you details of Ocmod documentation in Opencart 3. For Opencart 4 OCMOD tutorial click here

As per the core code when you upload the ***.ocmod.zip folder from Extensions >> Installer, the following things will happen:

  1. Check if the user has permission. You will get an error like:
    “Warning: You do not have permission to modify modifications!”
  2. Check if there is an install temporary folder zip already there.
  3. If it found the file and the file created time is less than 5 seconds then it tries to unlink or remove the file, if it cannot remove the file then it throws an error saying:
    “Extension installation taking place please wait a few seconds before trying to install!”
  4. It checks whether the uploaded zip file ends with .ocmod.zip
  5. It checks if there are any other file uploading errors, UPLOAD_ERR_OK: Value: 0; There is no error, and the file uploaded with success. If there is any error it will show errors like:
    “File could not be uploaded!”
  6. If everything is good then it creates a .tmp file and performs function move_uploaded_file.
  7. Then it adds the logs in the database table oc_extension_install with the name ***.ocmod.zip and the extension download id. “oc_” is the database prefix.
  8. Then it starts the installation, from the controller “ControllerMarketplaceInstall”, it makes sure the file name is stored in the session. If the file is not in that session then it shows an error like this:
    “File could not be found!”
  9. Then it starts unzipping the ***.ocmod.zip and if it cannot unzip the ocmod.zip file then it shows an error like:
    “Zip file could not be opened!”
  10. After unzipping it checks whether the unzip folder contains “upload/” or not, likewise, it checks for the allowed directories to be written or not. Opencart allows the following directories only:
    • ‘admin/controller/extension/’,
      ‘admin/language/’,
      ‘admin/model/extension/’,
      ‘admin/view/image/’,
      ‘admin/view/javascript/’,
      ‘admin/view/stylesheet/’,
      ‘admin/view/template/extension/’,
      ‘catalog/controller/extension/’,
      ‘catalog/language/’,
      ‘catalog/model/extension/’,
      ‘catalog/view/javascript/’,
      ‘catalog/view/theme/’,
      ‘system/config/’,
      ‘system/library/’,
      ‘image/catalog/’
  11. So while creating a custom opencart module better to work on these folders only. If you put it in another folder then it may give you the following error:
    “The directory %s is not allowed to be written to!”
  12. It checks for the directory structure of the zip and whether it matches with the Opencart directory structure.
  13. Then it will insert in the database table oc_extension_path with extension install id.
  14. Then it will start installing the /install.xml, if an XML file exists then it is put into the database. It checks for the “code” name in the XML and checks if the values already exist in the database. If everything is good then it inserts into the database table oc_modification with extension_install_id, name, code, author, version, link, XML, status, and date_added.
  15. Then it unlinks or removes the temporary folder.
  16. Finally, it gives the success message.

With the flow steps above the folder structure for the ocmod.zip is install.xml and upload. Inside the upload/ folder put the OpenCart folder and files.

In the install.xml it should be something like where the ******* is your custom thing.

ocmod code starter
<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>*******</name>
    <version>*******</version>
    <author>*******</author>
    <link>*******</link>
    <code>*******</code>
    <description>*******</description>
    <file path="*******">
        <operation>
            <search><![CDATA[ ******* ]]></search>
            <add position="*******"><![CDATA[*******]]></add>
        </operation>
    </file>
</modification>

Don’t forget <code>, although it is not mentioned in the Modification system documentation https://github.com/opencart/opencart/wiki/Modification-System

You can use multiple file operations. There are two operations search and add. With the Add operation, you can replace, add before, or add after.

<file path="">
    <operation>
        <search><![CDATA[]]></search>
        <add position=""><![CDATA[]]></add>
    </operation>
</file>

Now check out the previous blog posts where we have listed all the documentation of OCMOD.

While zipping the folder zip the install.xml and upload/ folder, not the main folder. install.xml is not mandatory.

If you are trying to create a table or insert data in the table then you need to create the install method in your controller. Like:

module install database

In the install method, you can implement logic as needed for your module when it is installed.

//Check it in admin/controller/extension/extension/module.php install method.
// Call install method if it exists
$this->load->controller('extension/module/' . $this->request->get['extension'] . '/install');

Similarly, you can implement the logic for the uninstalling method when it is uninstalled.

We created a free module with OCMOD to show the Module link in the left menu with the following XML:

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Show Module Link At Left Menu</name>
    <version>3.0</version>
    <author>Rupak Nepali</author>
    <link>https://webocreation.com</link>
    <code>webocreation_show_module_link_at_left_menu</code>
    <description>Show module link at left menu</description>
    <file path="admin/controller/common/column_left.php">
        <operation>
            <search><![CDATA[ if ($this->user->hasPermission('access', 'marketplace/extension')) { ]]></search>
            <add position="after"><![CDATA[
                $marketplace[] = array(
                    'name'     => "Modules",
                    'href'     => $this->url->link('marketplace/extension&type=module', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
            ]]></add>
        </operation>
    </file>
</modification>

Steps for making changes to the core files of OpenCart

  1. In your local make the changes in the core of the files and keep track of the files
  2. Then create the install.xml and add those changes in install.xml
  3. Then remove the changes of the core files that you make the changes.
  4. Then zip it with ***.ocmod.zip and upload in Extensions >> Installer
  5. Then clear the cache in Extensions >> Modifications
  6. You are set.

Testing Tips for the Developer

Testing is hard for OCMOD changes if you have to change in XML, zip, upload from the installer, and clear in modifications. So the tip for developers is they can place the install.xml in the system/ folder (not sure if it is supported in Opencart version 3.0.3.2), then make changes in the install.xml and you don’t need to zip and upload, you can clear in modifications and you can check the changes. If you don’t want to clear the cache in modifications then you can go through this blog Opencart cache clear.

If their search code is not found then it shows an error like the below in the Ocmod log:

MOD: 
FILE: admin/controller/common/column_left.php
CODE: if ($this->user('access', 'marketplace/modification')) {
NOT FOUND - OPERATIONS ABORTED!

The Search Code provides the following attributes:

  • trim=”(true|false)”
  • regex=”(true|false)”
  • index=”(number)”

The add code provides the following attributes:

  • trim=”(true|false)”
  • position=”(replace|before|after)”
  • offset=”(number)”

Other you can read at https://webocreation.com/ocmod-documentation/

Let us know if you have any suggestions or questions.

Sidebar Search Opencart module for free version 2

We are publishing another free Opencart module “Sidebar Search module” and we made this for OpenCart version 2.0.3.1. No files are overridden, you can enable it and disable it whenever you like from the admin section.

Output after installing the module in the home page’s right column is shown as in the image below:

sidebar search opencart module free
sidebar search opencart module free

Although the search is available at the header section so it is useless to use at default theme but you can use it for the customized theme and I will make another search module soon which will include all search functionality as the main search page. For now, enjoy this normal search opencart free module. You can see how I copied the header search section and show it as a module in the side search box. You can show anywhere you like as this is a module so you can show in the left column, right column or top content or bottom content.

Download Sidebar shopping cart free module from the link below:

Download Sidebar search OpenCart free module

Installation:

  1. Unzip the downloaded folder.
  2. Upload the files in the root folder to your server, no file is overwritten.
  3. Then activate the Search module.

Activating the Sidebar Search module:

  1. After uploading files to servers, it’s time to install Sidebar search module
  2. We are showing the sidebar search at the right column but you can show it wherever you like as this acts as the normal module.
  3. Go to Admin section
  4. Then click on Extensions on the left menu
  5. After that Click Modules and go to “Search” in the modules list
  6. Then click the green button to install the module (see the image below)
installation_of_module
installation_of_module

Then click the blue edit button After that, you will see the form which has the status field, select “Enabled” and then click the Save button. Your module is active and is ready to use in the layout.

Setup layout for the sidebar search module at home page:

  1. From the admin section go to System >> Design >> Layouts.
  2. You will see a list of layouts, from which edit the “Home” layout.
  3. Then click Blue add the button to add rows at module section which is shown in the image below:
siderbar shopping cart installation
siderbar_shopping_cart_installation

Second, you choose the Search in module column and Column right in the Position column and insert the sort order as required. Then click save button

Your custom sidebar search module is showing in the right column of the homepage. Likewise, you can show in many other layouts and pages.

Codes in search modules controller:

<?php
class ControllerModuleSearch extends Controller {
    public function index() {
        $this->load->language('module/search');
        $data['heading_title'] = $this->language->get('heading_title');
        
        $data['search'] = $this->load->controller('common/search');

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/search.tpl')) {
            return $this->load->view($this->config->get('config_template') . '/template/module/search.tpl', $data);
        } else {
            return $this->load->view('default/template/module/search.tpl', $data);
        }
    }
}

The main role player code here is

$data['search'] = $this->load->controller('common/search');

Code of search modules in language section:

<?php
// Heading
$_['heading_title'] = 'Search';

Code of search modules in theme (presentation layer):

<h3><?php echo $heading_title; ?></h3>
<hr>
<div class="row">
    <div class="product-layout col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <header><?php echo $search; ?></header>
    </div>
</div>
<hr>

Let me know if you get any problem with performing tasks in the comment so that I can help if you have any.

Thanks
Rupak Nepali

OpenCart 3 error Warning: You do not have permission to modify the default store theme!

While playing around with OpenCart 3.0.0.0 we were trying to create a new OpenCart 3.0 theme and for that, we copy the default theme and named “Webocreation” and was doing the following setting but got an error: “Warning: You do not have permission to modify the default store theme!”

So make the following changes to solve the problem:

The above error says we don’t have permission to modify so we tried to give permission as follows:

  • Admin >> System >> Users >> User Groups >> Edit the Administrator >> clicked “Select All” for both access permission and modify permission, then clicked save.

With the above permission, we should be able to get access but still got the same errors so we checked the code and found some glitch.

We checked admin\controller\extension\theme\default.php in OpenCart 3.0 and found following permission check at validate() method.

if (!$this->user->hasPermission('modify', 'extension/theme/theme_default')) {
    $this->error['warning'] = $this->language->get('error_permission');
}

But when we check at the User group permission it is extension/theme/default

extension theme default

So above code need to change to the following:

if (!$this->user->hasPermission('modify', 'extension/theme/default')) {
    $this->error['warning'] = $this->language->get('error_permission');
}

With this change, we are able to save, but still, we are not able to retrieve the save theme setting so we checked the code again and found the following:

if (isset($this->request->get['store_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
    $setting_info = $this->model_setting_setting->getSetting('default', $this->request->get['store_id']);
}

So we changed it to following

if (isset($this->request->get['store_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
    $setting_info = $this->model_setting_setting->getSetting('theme_default', $this->request->get['store_id']);
}

Then, it all starts to work. If you are also getting such an error, we hope it will help you to solve the problem. Enjoy and let us know if you are getting any kind of errors.

Opencart 3 – display images of the sub-categories in the category page

In this Opencart tutorial, we show you how to display sub-categories image on the category page in Opencart 3 by making code changes, click for Opencart 2 show images for sub-categories.

Open catalog/controller/product/category.php and find the following code:

$data['categories'][] = array(
    'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this- 
     >model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
    'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . 
     $result['category_id'] . $url)
);

Then replace with the following code:

$image = "";
if ($result['image']) {
    $image = $this->model_tool_image->resize($result['image'], 100, 100);
}
$data['categories'][] = array(
    'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this- 
     >model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
    'image' => $image,
    'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . 
    $result['category_id'] . $url)
);

Open catalog/view/theme/default/template/product/category.twig and find the following code:

{% if categories|length <= 5 %}
    <div class="row">
        <div class="col-sm-3">
            <ul>
                {% for category in categories %}
                    <li>
                        <a href="{{ category.href }}">
                            {{ category.name }}
                        </a>
                    </li>
                {% endfor %}
            </ul>
        </div>
    </div>
{% else %}
    <div class="row">
        {% for category in categories|batch((categories|length / 4)|round(1, 'ceil')) %}
            <div class="col-sm-3">
                <ul>
                    {% for child in category %}
                        <li>
                            <a href="{{ child.href }}">
                                {{ child.name }}
                            </a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        {% endfor %}
    </div>
    <br/>
{% endif %}

Replace with the following code:

 {% if categories|length <= 5 %}
    <div class="row">
        <div class="col-sm-3">
            <ul>
                {% for category in categories %}
                    <li>
                        {% if category.image  %}
                            <div>
                                <img src="{{ category.image }}" alt="{{ category.name }}" title="{{ category.name }}" class="img-thumbnail"/>
                            </div>
                        {% endif %}

                        <a href="{{ category.href }}">
                            {{ category.name }}
                        </a>
                    </li>
                {% endfor %}
            </ul>
        </div>
    </div>
{% else %}
    <div class="row">
        {% for category in categories|batch((categories|length / 4)|round(1, 'ceil')) %}
            <div class="col-sm-3">
                <ul>
                    {% for child in category %}
                        <li>
                            <div>
                                {% if child.image  %}
                                    <img src="{{ child.image }}" alt="{{ child.name }}" title="{{ child.name }}" class="img-thumbnail"/>
                                {% endif %}
                            </div>

                            <a href="{{ child.href }}">
                                {{ child.name }}
                            </a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        {% endfor %}
    </div>
    <br/>
{% endif %}

In catalog/view/theme/default/template/product/category.twig there are two places where we added the following code:

 {% if category.image  %}
    <div>
        <img src="{{ category.image }}" alt="{{ category.name }}" title="{{ category.name }}" class="img- 
        thumbnail"/>
    </div>
{% endif %} 
{% if child.image  %}
    <div>
        <img src="{{ child.image }}" alt="{{ child.name }}" title="{{ child.name }}" class="img-thumbnail"/>
    </div>
{% endif %}

Once we added the above code then we can see the images of the sub-categories.

Sub-categories Images in category page

This way we can show the sub-categories image on the category page. Let us know if need any support. Hope you liked this post, please subscribe to our YouTube Channel for Opencart video tutorials. You can also find us on Twitter and Facebook.

Easy steps to setup local environment of Pantheon with Lando

This is an introduction of Lando and how to set up locally and set up the Pantheon environment in the local environment so that we can have the same environment as Pantheon and development, testing and deployment are so easy. Pantheon supports both WordPress and Drupal.

Install Lando

Mac

  • Ensure homebrew is installed and up-to-date.
  • Add the Lando cask: brew cask install lando

Windows:

  • Download the .exe file and install it from
    https://github.com/lando/lando/release

Now create a folder let’s say “pantheonlando” then go inside that folder and run lando init

lando init

After that it will ask the following questions:

  • What recipe do you want to use? pantheon
    Choose pantheon.
  • Choose a Pantheon account: add a different token
    Choose: add a different token
  • Enter a Pantheon machine token [hidden]
    Enter the token, if you don’t have one, create at Pantheon and enter that token here.
  • Which site? webocreation-12
    It will list out all the sites in your pantheon account, choose one
lando init

With this, Lando is initialized.

Import Pantheon Database, code, and files

lando pull
lando pull
lando pull

It drops all the database and pulls the recent one and all the files uploaded.

Start your site:

In the terminal run:

lando start

BOOMSHAKALAKA!!! Your site is ready.

lando start

Now go to NGINX URLs, here as in the example it is http://localhost:32778 but yours can be different.

With these steps, developers can quickly specify and painlessly spin up the services and tools needed to develop their projects of the pantheon and test it locally.

If you got 500 Internal Server Error, you may have forgotten to run composer install or perform lando pull or check the files and folder permission.

lando 500 internal server error

Let us know if you find any issues so that we can try to find the solution for you.

Enjoy Lando, for more details visit https://docs.devwithlando.io/tutorials/pantheon.html.

Pardot, Mailchimp, and website integrating Marketing system

With Digital Business Transformation approaches, business activities are more focused on automating Marketing system, as automation improves the lead nurturing process in a number of ways so being experienced in Pardot and Mailchimp, following can be one way to automate your subscription of the blog and pass data from Website to MailChimp to Pardot. With this you can use your website blog RSS feed and send daily, weekly or monthly email to your subscribers which will be handled by Mailchimp and data will be passed from Mailchimp activities to the website and then to Pardot where you can analyze your prospects more thoroughly and increase the reach.

Why this approach?

We did not find a way in Pardot to handle RSS feed and send published blogs to the subscribers on the predefined date so we have to use the MailChimp to automate it.

One of the workflows can be as below:

Mailchimp Pardot flow step

When visitors visit a website then they will see sign up form let’s say newsletter sign up form having two field email and first name. If they fill-up the form with the correct email format then they will get an email to confirm the email from the MailChimp and once they confirmed the subscription then they will be added to the subscriber’s list in the MailChimp.

Set Up WebHooks

  • Navigate to the Lists page.
  • Click the drop-down menu next to the list you want to work with, and choose Settings.
  • Select Settings
  • On the Settings page, click Webhooks.
  • Click Create New Webhook.
  • In the Callback URL field, type the URL from your integration or application where you want to send webhook requests. This URL will receive data about events going on in your MailChimp list.
  • If you don’t have a callback URL yet, contact your developer or hire an expert to set it up.
  • Check the boxes next to each update type to choose the events that will trigger your webhook.
    http://kb.mailchimp.com/integrations/api-integrations/how-to-set-up-webhooks
  • Click Save.
  • After the URL is saved, the webhook will notify your application of any events.

With webhook and callbacks of MailChimp, data are sent in POST to the website. For now, there is no connection between Mailchimp and Pardot. If anything is needed we need to handle from website and MailChimp webhooks and callbacks. When webhooks are called then this call URL will be called and code in that page runs.

Subscription mechanism with Pardot:

When someone subscribes from the website inserting name and email then these data also need to be passed to the Pardot.
As MailChimp does not transfer data directly to the Pardot so needs to create webhooks between website and MailChimp and transfer data from the website to Pardot. Similarly, we have to perform the same when someone unsubscribes in Mailchimp we have to trigger the webhook callback function and then use the form handler and submit for the prospects.

In this way, we can handle the data transfer from the website to MailChimp, MailChimp to the website and then website to Pardot.

Contact us if you want this to be implemented in your system.

Other posts about Pardot:

Show attributes of products in category page Opencart 2.0+ and 3.0+

This opencart tutorial shows how to show attributes of products in category page in Opencart 2.0 and Opencart 3.0.3.2 we will provide OCMOD and VqModafter some time:

Open catalog/controller/product/category.php and find following code:

$data['products'][] = array(
	'product_id'  => $result['product_id'],
	'thumb'       => $image,
	'name'        => $result['name'],
	'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
	'price'       => $price,
	'special'     => $special,
	'tax'         => $tax,
	'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
	'rating'      => $result['rating'],
	'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);

Now add one line in it ‘attribute_groups’ => $this->model_catalog_product->getProductAttributes($result[‘product_id’]), then the products array will be like below:

$data['products'][] = array(
	'product_id'  => $result['product_id'],
	'thumb'       => $image,
	'attribute_groups'       => $this->model_catalog_product->getProductAttributes($result['product_id']),
	'name'        => $result['name'],
	'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
	'price'       => $price,
	'special'     => $special,
	'tax'         => $tax,
	'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
	'rating'      => $result['rating'],
	'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);

For OpenCart 3.0+

Now open catalog/view/theme/YOUR_THEME_FOLDER/template/product/category.twig and add following codes just below <p>{{ product.description }}</p>

{% if product.attribute_groups %}
<div class="tab-pane" id="tab-specification">
  <table class="table table-bordered">
    {% for attribute_group in product.attribute_groups %}
    <thead>
      <tr>
        <td colspan="2"><strong>{{ attribute_group.name }}</strong></td>
      </tr>
    </thead>
    <tbody>
    {% for attribute in attribute_group.attribute %}
    <tr>
      <td>{{ attribute.name }}</td>
      <td>{{ attribute.text }}</td>
    </tr>
    {% endfor %}
      </tbody>
    {% endfor %}
  </table>
</div>
{% endif %}

For OpenCart 2.0+

Now open catalog/view/theme/YOUR_THEME_FOLDER/template/product/category.tpl and add following codes just below <p><?php echo $product[‘description’]; ?></p>

<p>
  <?php if ($product['attribute_groups']) { ?>
<div class="tab-pane" id="tab-specification">
  <table class="table table-bordered">
    <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
    <thead>
    <tr>
      <td colspan="2"><strong><?php echo $attribute_group['name']; ?></strong></td>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
    <tr>
      <td><?php echo $attribute['name']; ?></td>
      <td><?php echo $attribute['text']; ?></td>
    </tr>
    <?php } ?>
    </tbody>
    <?php } ?>
  </table>
</div>
<?php } ?>
</p>

Save and reload and it will show attributes in category’s products

attributes-at-category-page
attributes-at-category-page

If you need to do for the featured products, bestseller products then follow similar code changes in their controller and view files.

Comment below or let us know if you have any questions or requirements for OpenCart. You can subscribe to our youtube channel for OpenCart tutorials.

“What People are Buying right now?” Opencart Module for free

Another free Opencart module for my visitors and subscribers, this extension will show “What People are buying right now?”. It lists out the recently ordered products.

To download the module click below:

Installation

Upload the folders ‘admin’ and ‘catalog’ and their files from the extracted directory to your server OpenCart main directory. Check this installation video if have any issues

OpenCart core files are not changed.

After installation:

You can edit the module and setup following:

Then setup in your preferred layout and you will see like below:

Query implemented is below:

public function getLatestOrderedProducts($limit)
{
	$product_data = "";
	$product_data = $this->cache->get('product.latestordered.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);

	if (!$product_data) {
		$product_data = array();

		$query = $this->db->query("SELECT op.product_id FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY o.order_id DESC LIMIT " . (int)$limit);
		foreach ($query->rows as $result) {
			$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
		}
		$this->cache->set('product.latestordered.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
	}

	return $product_data;
}

Further help and customized versions:

This module has been successfully tested for a standard OpenCart 3.0.3.2.

If you need a customized version of this module and any other Opencart help and support then let me know and I can create one for a charge.

If you get any problem with the module then let me know by commenting.

Youtube video to show with autoplay, Free Opencart module or extensions

Another Opencart module for free by webocreation.com which shows youtube video and autoplay it, download this extension upload and take the youtube video id and show it in module placed and autoplay it.

Download, extract and Upload the files and folder inside the upload/ folder to your respective admin/ and catalog/ folder. If you have a problem then watch this video which will show how to upload, install and configure opencart module

After uploading, go to Extensions >> Choose the Modules >> Then go to the “Youtube AutoPlay youtube module” and click + Install green button and then click the + blue button. After that, you will see the following screenshot where you have to enter the Module Name, Youtube Id and change the status to Enabled.

Youtube Auto Play Opencart module

Click Save.

Then go to Design >> Layouts >> Edit where you want to show the youtube video. For us we are showing it on the home page at the bottom so our setting is like below:

Layout and Position to show for the Youtube Autoplay module

With the above settings we can see the youtube video at the bottom of the home page, like in this demo:

Let us know if you need to improve anything in the module and we will make the adjustments as per your request. Thanks for using these modules and let us know if you have any requirements.

How to upgrade Opencart from version 2.3 to 3.0.3.1 and Journal theme 2 to 3?

Our webocreation.com is still in opencart v2.3 and today we are upgrading to opencart version 3.0.3.1 live. So that it will be pressure for us to complete it. We are able to upgrade in 1hrs and fix problems to go through the normal ordering. Previously we were using Journal version 2 and now we are using journal version 3.

Be prepared with the following:

  • Make a backup of every file and folder and the database.
  • Download the latest version of OpenCart, right now it is 3.0.3.2
  • Download the Journal theme version 3
  • Download the demo data of the Journal theme
  • Login to admin and disable the custom theme and set up the default theme of OpenCart so there are no conflicts.
  • Upload all the latest version Opencart files and folders to your server and go to your store URL, it mostly gives errors unless it is a minor version update.
  • Rename the Vqmod folder to something else as it may contain .xml files which give errors in major version upgrades.
  • Rename the journal-cache folder also if you have.
  • Remove all .xml files except modification.xml inside system/ folder
  • Go to system/storage/cache folder and delete all files and folder except index.html, similarly go to system/storage/modification and delete all files and folder except index.html, likewise, go to system/storage/upload and delete all files and folder except index.html. It means the need to remove all the cache and file modifications that are in the system/storage of Opencart 2.
  • Then run YOURSTOREURL/install in your browser
  • You will see some notice, if you re-run then it will be resolved automatically.
  • Install the Opencart in the subfolder so that it will be easy to copy and paste in the config.php and get the files and folder as needed. This is extra steps but will be helpful to debug if something went wrong.
  • Update your config.php and admin/config.php as required as mostly, it missed the DIR_STORAGE constant.
  • Then go to the directory of DIR_STORAGE and upload files and folders to match the DIR_STORAGE folder of your demo sub-folder installation. Or you can download the following and extract and upload all files and folders to your store DIR_STORAGE path.
    • Download DIR_STORAGE files.
    • Some time upgrade code is not able to create the files and folders for the DIR_STORAGE so we have to upload it manually.
  • If you see errors then it is because of non-upgraded extensions, so find them out and disable them.
  • Then verify all of your extensions if they are enabled as mostly they got disabled when a major version upgrade is done.
  • Check for modules, shipping, payments, and Order totals likewise other Analytics, Captchas, etc
  • Don’t forget to delete Journal2 folders in admin and in catalog likewise in the system folder. Similarly, remove all .tpl files will be a good idea.
  • Happy Upgrading and hope it went smooth on your side.

Read: Learn Journal theme coding by example

Things to consider:

  • SEO URL alias is not transferred properly. So you have to transferred manually or write SQL code to transfer from the oc_url_alias to oc_seo_url, as now in OpenCart 3.0.3.1 the SEO URL is also stored specific and language-specific.
  • None of the Journal settings and configuration are transferred so if you have a unique design then you have entered them manually.
  • Most of the modules get disabled so need to enabled again.
  • Theme will show two default theme so need to disabled both and enable whichever works as this is because there are existing files of Opencart 2

Some of the error we fixed while we upgrade the OpenCart and Journal theme:

SyntaxError: Unexpected token < in JSON at position 0 parsererror Notice: Undefined variable: affiliatee in /public_html/install/model/upgrade/1009.php on line 23{“success”:”Patch 1009 has been applied (10 of 10)”,”next”:”index.php?route=upgrade\/upgrade\/next&step=11″}

-Re-run the install

Warning: fopen(DIR_STORAGElogs/openbay.log): failed to open stream: No such file or directory in /public_html/system/library/log.php on line 22Warning: fopen(DIR_STORAGElogs/error.txt): failed to open stream: No such file or directory in /public_html/system/library/log.php on line 22Warning: Use of undefined constant DIR_STORAGE – assumed ‘DIR_STORAGE’ (this will throw an Error in a future version of PHP) in /public_html/admin/controller/startup/sass.php on line 7Warning: include_once(DIR_STORAGEvendor/scss.inc.php): failed to open stream: No such file or directory in /public_html/admin/controller/startup/sass.phpon line 7Warning: include_once(): Failed opening ‘DIR_STORAGEvendor/scss.inc.php’ for inclusion (include_path=’.:/opt/alt/php72/usr/share/pear’) in /public_html/admin/controller/startup/sass.php on line 7

  • First, remove the cache which is in system/storage of OpenCart 2
  • Define the DIR_STORAGE constant at the config.php and provide the right path.
  • If you are confused which path to provide then install an Opencart in sub-folder and log in which will redirect you to define the storage folder. With this default setup, now you can see its config.php and admin/config.php and do the same for your store config.php and admin/config.php. This is one way.

Warning: fopen(/v3storage/cache/cache.catalog.language.1557105242): failed to open stream: No such file or directory in /public_html/system/library/cache/file.php on line 49Warning: flock() expects parameter 1 to be resource, boolean given in /public_html/system/library/cache/file.php on line 51Warning: fwrite() expects parameter 1 to be resource, boolean given in /public_html/system/library/cache/file.php on line 53Warning: fflush() expects parameter 1 to be resource, boolean given in /public_html/system/library/cache/file.php on line 55Warning: flock() expects parameter 1 to be resource, boolean given in /public_html/system/library/cache/file.php on line 57Warning: fclose() expects parameter 1 to be resource, boolean given in /public_html/system/library/cache/file.php on line 59Warning: fopen(/v3storage/cache/cache.currency.1557105242): failed to open stream

  • Upload the cache folder, download, logs, modification, session, upload, vendor files, and folder.
  • You can download here as well, which is the basic files and folder of the OpenCart installation

Error: A theme has not been assigned to this store!

You can fix the error by referring to this post as it contains some steps to solve it.

Notice: Undefined variable: _SESSION in /public_html/catalog/controller/extension/module/v2pagecache.php on line 13Error: A theme has not been assigned to this store!

In our case, most of the modules were disabled when we upgraded to OpenCart 3. Thus we re-installed modules, theme, Order Totals, payment and shipping also.

Journal Theme Installation Error
Make sure you have refreshed Opencart Modifications.

This is straight forward, go to admin>> Extensions >> Modifications and click the refresh button.

Let us know your upgrade process and issues if you got any.