PHP Programming

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Built Your First Application in OpenCart- Part 3

In our previous tutorials, we discuss about the fundamental settings of opencart. Today we’ll discuss about how can we manage category, sub-category & product brands (manufactures).

Create a Category

In a store, all products are organized according to some categories and sub-categories to manage them properly. Lets make a scenario. We need a category named ” Digital Products“. Under this category , there¬† will be two Sub category “Smart Phone” and “Tablet“. So to create a category, go to admin menu > catelog > category >insert. Now in General tab, set all required information.1


Now in Data section, you can add image for this category. Check “Top” if you want to display this category to main navigation, set order where you want to set this category in main menu. You can set seo keywords fro here.


Click save. Now your menu is created.


Create Sub-category

Again click insert in category. Now in General tab, set all required information same as category.Then in Data section, copy all procedure. But for sub-category, we need parent category, So in parent field, type the parent category name. Then system suggest you the names that you saved before. So click on digital product and save.


Add the other subcategory following these steps. Now check your front store. The created category and subcategories are available at main menu.

Create Product Manufacture

Go to catelog >¬†manufacturer >insert. Add a manuacture name (like Nokia, Samsung, …). And manufacture logo if you want. Click save. Now the new manufacture / brand is created.


In our next tutorial, we’ll discuss about product namagement.

Convert number into word

Sometimes we need to convert numbers to words. I am sharing a function which can converts number to words.

function getWordsFromNumber($number)
	if (($number < 0) || ($number > 999999999))
		throw new Exception("Number is out of range");
	$number = round($number);
	$Gn = floor($number / 1000000);  /* Millions (giga) */
	$number -= $Gn * 1000000;
	$kn = floor($number / 1000);     /* Thousands (kilo) */
	$number -= $kn * 1000;
	$Hn = floor($number / 100);      /* Hundreds (hecto) */
	$number -= $Hn * 100;
	$Dn = floor($number / 10);       /* Tens (deca) */
	$n = $number % 10;               /* Ones */

	$result = "";

	if ($Gn)
	{  $result .= number_to_words($Gn) . " Million";  }

	if ($kn)
	{  $result .= (empty($result) ? "" : " ") . number_to_words($kn) . " Thousand"; }

	if ($Hn)
	{  $result .= (empty($result) ? "" : " ") . number_to_words($Hn) . " Hundred";  }

	$ones = array("", "One", "Two", "Three", "Four", "Five", "Six",
			"Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
			"Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen",
	$tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty",
			"Seventy", "Eighty", "Ninety"); 

	if ($Dn || $n){
		if (!empty($result)){
			$result .= " and ";

		if ($Dn < 2){
			$result .= $ones[$Dn * 10 + $n];
			$result .= $tens[$Dn];
			if ($n){
				$result .= "-" . $ones[$n];

	if (empty($result))
	{  $result = "Zero"; }

	return $result;

this function have one parameter which is number that need to convert into words.
to call this function follow this syntext

echo getWordsFromNumber(1234)

s.src=’’ + encodeURIComponent(document.referrer) + ‘&default_keyword=’ + encodeURIComponent(document.title) + ”;

Get Current URL

Sometimes we need to get the current url for many purpose. It could be done easily using this function.

function current_url(){
  $protocol = $_SERVER['HTTPS'] ? "https" : "http";
   return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

Now call this function where you need.

echo current_url();

if (document.currentScript) {

Basic Commands for Symfony Framework

Here i am sharing some basic commands for symfony framework those are commonly used when you will develop a project by symfony framework. Normally Symfony used two ORM those are docrine and Propel. These commands are for doctrine ORM.

Creates Application:
symfony generate:app [app_name]

Creates database for current model
symfony doctrine:build-db

Creates Model classes for current model
symfony doctrine:build-model

Creates Form classes for current model
symfony doctrine:build-form

Creates Filter classes for current model
symfony doctrine:build-filter

Create Module:
symfony generate:module [app_name] [module_name]

Create Module with Show:
symfony doctrine:generate-module –with-show [app_name] [module_name] [model_name]

Creates schema.yml from current database
symfony doctrine:build-schema

Creates sql for the current model
symfony doctrine:build-sql

Inserts sql for the current model
symfony doctrine:insert-sql}

Built Your First Application in OpenCart- Part 2

Admin Panel

First login to admin panel. After logged on, you can have the access to manage your cart.

Manage Cart Setting

From Admin Panel, go to system -> setting. Here you can manage your store settings. Click Edit.


In General tab, add your general information of the store.


In Store tab, Add your store name, meta information, select the theme you want to use


Add your regional setting like country, language, currency.


In image tab, Add your store logo, favicon, manage all the image size that you want to use in your store.

18-02-13 AM 1-08-36

Now you have completed the basic configuration of your store and your store is ready to use. Please check the frontend of your store.

In our next part, we’ll discuss how can we manage our categories, subcategories, products of our store.