Show related products at the cart page in the Opencart site

For the up-sell strategy, we can show recommended or related products on the cart page, we show the added related products as per the products in the cart as recommended products for now.

We are confused about whether to show products like the featured products or show the related product in the cart that is related to the products in the cart. Following is the steps of code changes and addition we have done in the Opencart:

For Opencart version 2

Open catalog/view/theme/default/template/checkout/cart.tpl and find <?php echo $content_bottom; ?> and paste following code:

<?php
$this->load->model('catalog/category');
foreach ($products as $product) {
    $arrs[] = $results = $this->model_catalog_product->getProductRelated($product['key']);
}
if ($arrs) {
	foreach ($arrs as $arr) {
		foreach ($arr as $lastarr) {
			echo $lastarr['name'];
		}
	}
}
?>

How the above code works?

$this->load->model(‘catalog/category’);

This will just load the model for retrieving the data from the database.

foreach ($products as $product) {
$arrs[ ] = $results = $this->model_catalog_product->getProductRelated($product[‘key’]);
}

This lines detect the products in the cart and retrieve the related products as in the cart and keep things in the array $arrs.

if($arrs){

This checks whether there is related products or not, related with the products in the cart.

foreach ($arrs as $arr) {
foreach ($arr as $lastarr) {
echo $lastarr[‘name’];
}
}

This just prints the name of the related products related to the products in the cart. Module and Vqmod will be published soon. Let us know if need any support. Please subscribe to our YouTube Channel for Opencart video tutorials and get lots of other Opencart free modules. You can also find us on Twitter and Facebook also.

how to show modules in all pages of opencart 1.5

With the current Layout System we can:

  1. Set module to show on all page.
  2. Set different module to show on different page (based on route).
  3. Set different module (maybe Banner) to different Category, Product and Information page.
  4. If you have multi-store, you can set all feature above for different store.

Overview: How it works?

  1. First, opencart will check is there any Layout specifically for Category, Product or Information Page. Then apply it.
  2. When the first check above return false, opencart will check is their Layout based on route URL is available.
  3. When the second check above return false, opencart use Store Layout as a “fallback”.

Layout system in opencart, a specific module to a specific page

How the layout system works is explained well in the following links by Qahar from Indonesia. Thanks to him.

http://forum.opencart.com/viewtopic.php?f=138&t=37119

Increase the speed of loading the opencart sites

I am working as the opencart programmer for 6 months and found out that opencart as the best open source for the e-commerce site.
Yet some of the things to be taken into consideration which obviously increases the speed of the opencart sites.

We all know that indexing the table increases the performance of the database so creating the following index really increase the speed in the opencart sites. Run the query below and enjoy some little speed on loading your sites.

ALTER TABLE `category` ADD INDEX ( `parent_id` ) ;
ALTER TABLE `category` ADD INDEX ( `top` ) ;
ALTER TABLE `category` ADD INDEX ( `sort_order` ) ;
ALTER TABLE `category` ADD INDEX ( `status` ) ;
ALTER TABLE `option` ADD INDEX ( `sort_order` ) ;
ALTER TABLE `option_description` ADD INDEX ( `name` ) ;
ALTER TABLE `option_value` ADD INDEX ( `option_id` ) ;
ALTER TABLE `option_value_description` ADD INDEX ( `option_id` ) ;
ALTER TABLE `order` ADD INDEX ( `customer_id` ) ;
ALTER TABLE `product` ADD INDEX ( `model` ) ;
ALTER TABLE `product` ADD INDEX ( `sku` ) ;
ALTER TABLE `product` ADD INDEX ( `upc` ) ;
ALTER TABLE `product` ADD INDEX ( `manufacturer_id` ) ;
ALTER TABLE `product` ADD INDEX ( `sort_order` ) ;
ALTER TABLE `product` ADD INDEX ( `status` ) ;
ALTER TABLE `product_option` ADD INDEX ( `option_id` ) ;
ALTER TABLE `product_option_value` ADD INDEX ( `product_option_id` ) ;
ALTER TABLE `product_option_value` ADD INDEX ( `product_id` ) ;
ALTER TABLE `product_option_value` ADD INDEX ( `option_id` ) ;
ALTER TABLE `product_option_value` ADD INDEX ( `option_value_id` ) ;
ALTER TABLE `product_tag` ADD INDEX ( `product_id` ) ;
ALTER TABLE `product_tag` ADD INDEX ( `tag` ) ;
ALTER TABLE `url_alias` ADD INDEX ( `query` ) ;
ALTER TABLE `url_alias` ADD INDEX ( `keyword` ) ;
ALTER TABLE `user` ADD INDEX ( `username` ) ;
ALTER TABLE `user` ADD INDEX ( `password` ) ;
ALTER TABLE `user` ADD INDEX ( `email` ) ;

Likewise, we have to remove unnecessary queries which obviously increase the speed of the site.

Queries that can be removed are the category count in the opencart

Use the steps below to remove the category count:

Go to the file:
/catalog/controller/module/category.php
1.Search CODE:

‘name’ => $child[‘name’] . ‘ (‘ . $product_total . ‘)’,

Replace with CODE:

‘name’ => $child[‘name’],

2.Search CODE:

‘name’ => $category[‘name’] . ‘ (‘ . $product_total . ‘)’,

Replace with CODE:

‘name’ => $category[‘name’],
3. Search CODE:
‘name’=> $result[‘name’] . ‘ (‘ . $product_total . ‘)’,
Replace with CODE:
‘name’  => $result[‘name’],
This will remove the product count in the category module.
If there is product count in the top menu bar then you can remove them as well.
For the top bar go to /catalog/controller/common/header.php

Search CODE:

‘name’  => $child[‘name’] . ‘ (‘ . $product_total . ‘)’,
And Replace with CODE:
‘name’ => $child[‘name’],

SEO friendly URLs for opencart 3, htaccess rewrite URL

In this Opencart 3 tips and tricks, we are showing you how to make the friendly URLs in Opencart 3 and make changes in the .htaccess which will help in SEO and user-friendly URLs.

Enable SEO URL’s in the OpenCart Admin

First of all, enable the SEO URL’s in your store’s admin. Go to the Admin >>System >>Settings. Edit your store, and finally click the Server tab and set the SEO URLs radio to Yes and save your settings.

Rename the .htaccess.txt file to .htaccess

OpenCart provides a file called .htaccess.txt. Rename this file to .htaccess and you will be good to go. If you don’t have this file in your root directory where opencart installed, you need to make your own .htaccess file and then paste the following code:

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. 

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files

 Order deny,allow
 Deny from all

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

RewriteBase /
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

Enter SEO Keywords for URL’s

Finally, you need to enter SEO keywords for every page, information, product, and category you want to have URL rewrite. You can find the field for SEO Keywords under the Data tab when editing and creating items.

Once you have entered the SEO Keywords your URL will be working. Now go and enjoy more traffic and happy customers.

Things to take into consideration while Enter SEO Keywords for URL’s

When SEO URLs are activated now on keep in mind the following things while inserting the data:

  1. Always insert the SEO keywords while inserting the data
  2. Remove space in the SEO keywords like for this “Backyard Water Slide” use “Backyard-Water-Slide”.
  3. Remove special characters (/, & $ @ # etc) also, as some browser will not detect them.
  4. The most important things are that SEO Keywords must be unique throughout the site if repeated then the system will be confused which to show and it shows errors.
  5. I have found you are not inserting SEO keywords field for the category so insert it as well but remember must be unique through the site.

Read more about SEO for Opencart 3

Show images for the sub-categories in the opencart version 1.5+

Show images for the sub-categories in the opencart version 1.5+. If you are looking for 2.3 then: Show images for the sub-categories in the opencart version 2.3

Find lines below on catalog/controller/product/category.php

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

Replace with the following code:

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

Find following lines of code at catalog\view\theme\default\template\product\category.tpl

<?php if ($categories) { ?>
  <h2><?php echo $text_refine; ?></h2>
  <div class="category-list">
    <?php if (count($categories) <= 5) { ?>
    <ul>
      <?php foreach ($categories as $category) { ?>
      <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
      <?php } ?>
    </ul>
    <?php } else { ?>
    <?php for ($i = 0; $i < count($categories);) { ?>
    <ul>
      <?php $j = $i + ceil(count($categories) / 4); ?>
      <?php for (; $i < $j; $i++) { ?>
      <?php if (isset($categories[$i])) { ?>
      <li><a href="<?php echo $categories[$i]['href']; ?>"><?php echo $categories[$i]['name']; ?></a></li>
      <?php } ?>
      <?php } ?>
    </ul>
    <?php } ?>
    <?php } ?>
  </div>
  <?php } ?>

Replace with following lines of code:

<?php if ($categories) { ?>
  <h2><?php echo $text_refine; ?></h2>
  <div class="category-list">
    <?php if (count($categories) <= 5) { ?>
    <ul>
      <?php foreach ($categories as $category) { ?>
      <li><a href="<?php echo $category['href']; ?>">
          <?php if($category['image']){ ?>
          <img src="<?php echo $category['image']; ?>" /><br>
          <?php } ?>
          <?php echo $category['name']; ?></a></li>
      <?php } ?>
    </ul>
    <?php } else { ?>
    <?php for ($i = 0; $i < count($categories);) { ?>
    <ul>
      <?php $j = $i + ceil(count($categories) / 4); ?>
      <?php for (; $i < $j; $i++) { ?>
      <?php if (isset($categories[$i])) { ?>
      <li><a href="<?php echo $categories[$i]['href']; ?>">
          <?php if($category['image']){ ?>
          <img src="<?php echo $category['image']; ?>" /><br>
          <?php } ?>
          <?php echo $categories[$i]['name']; ?></a></li>
      <?php } ?>
      <?php } ?>
    </ul>
    <?php } ?>
    <?php } ?>
  </div>
  <?php } ?>

Save and things are done you will be able to see the pictures of the sub-categories
For demo visit: https://webocreation.com/nepalbuddha/index.php?route=product/category&path=20

Show All products Module for free in opencart 1.5.6.4

For the latest version of module please go to following link. Click following link to get latest post:
webocreation.com/show-all-products-opencart-module

Show All products Module for free in opencart

Today, I was wondering and searching in the Opencart forum but i was unable to find out the show all products like the category listing in the Opencart so decide to develop it and i was so tired today so i left it to the forum so hope to get the best module by Sunday :).

I have searched for the extensions but it was not free, it cost $10.

So i decided to make the things by my self and was able to make it but i was feeling so dizzy so left to the forum so that any one will like to extend further.

Please help me to broaden it.
Installation:

1 – Unzip showallproduct.zip in the folder of your choice.

2 – Upload the files inside the “root” folder to your server, no other files are overwritten.

3- Link to link the page is “index.php?route=product/productall”

For OpenCart version 1.5.6.4 you have to download following:

All Product Display Module OpenCart Version 1.5.6.4

Install VqMod to show link of All Products in Menu

https://github.com/vqmod/vqmod/releases/tag/v2.6.1-opencart

Demo at the link below

http://webocreation.com/nepaleverest/

Things are done Enjoy the Extensions, little help to the Opencart forum, hope some will help to extend it.

The easiest way for URL rewriting in Opencart

How to easily rewrite URL rewriting in the Opencart

Follow the below steps :

  1. In your server Rename your htaccess.txt to .htaccess.
  2. Login in the admin area.
  3. Go to Admin->Configuration->Settings->Server and check  SEO URL option Yes.
  4. Go to Admin >> Design >> SEO URL. Then you have to enter the SEO keyword field in every products/categories/information etc. Here is the code to automatically enter the SEO keyword as per the product name.
  5. You can find this field at that time of insertion or edition.

Animation fly image to the cart functionality in opencart 1.4, opencart 2

This opencart guide is to show how to add a fly animation of the image while adding to the cart functionality like in opencart 1.4.

For Opencart 1.4+ and Opencart 2

Assuming you are using the cart module, otherwise, you will need to change #module_cart to #cart

EDIT: /catalog/view/theme/default/template/product/product.tpl
– FIND:$('html, body').animate({ scrollTop: 0 }, 'slow');

– ADD ABOVE:animateProduct( $("#image") , $("#module_cart") ); 

– Edit: /catalog/view/javascript/common.js
– ADD inside the $(document).read; /* AddToCart */

$('.addToCart').click(function() {
  var tis = $(this);
  $.ajax({
    url: 'index.php?route=checkout/cart/update',
    type: 'post',
    data: 'product_id=' + tis.attr('data-id'),
    dataType: 'json',
    content: this,
    success: $.proxy(function(json) {
      $('.success, .warning, .attention, .information, .error').remove();
      if (json['redirect']) {
        location = json['redirect'];
      }
      if (json['error']) {
        if (json['error']['warning']) {
          $('#notification').html(
            '<div style="display: none;">' +
              json['error']['warning'] +
              '<img src="catalog/view/theme/default/image/close.png" alt="" /></div>'
          );
        }
      }
      if (json['success']) {
        $('#notification').html(
          '<div style="display: none;">' +
            json['success'] +
            '<img src="catalog/view/theme/default/image/close.png" alt="" /></div>'
        );
        $('.attention').fadeIn('slow');
        $('#cart_total').html(json['total']);
        $('#module_cart .cart-module').html(json['output']);
        animateProduct(
          tis
            .parents()
            .eq(2)
            .find('.image img'),
          $('#module_cart')
        );
        $('html, body').animate({ scrollTop: 0 }, 'slow');
      }
    }, this)
  });
});

– ADD to bottom:

function animateProduct(image, cart) {
  image.before(
    '<img src="' +
      image.attr('src') +
      '" id="temp" style="position: absolute; top: ' +
      image.top +
      'px; left: ' +
      image.left +
      'px;" />'
  );
  var cart_offset = cart.offset();
  params = {
    top: cart_offset.top + 'px',
    left: cart_offset.left + 'px',
    opacity: 0.0,
    width: cart.width(),
    height: cart.height()
  };
  $('#temp').animate(params, 'slow', false, function() {
    $('#temp').remove();
  });
}

We moved the majority of the code to the common.js in the hope that this will be updated less than the product.tpl

– Seen as we are now using a function and not inline JS to animate the image, we can reuse this throughout the website. So I though why not show you how this could work with HTML5 data attribute and eventually this might be updated in the core.

– EDIT: /catalog/view/theme/default/template/product/category.tpl
– FIND:<div><a onclick="addToCart('<?php echo $product['product_id']; ?>');"><span><?php echo $button_cart; ?></span></a></div>

– REPLACE WITH:

<div><a data-id="<?php echo $product['product_id']; ?>"><span><?php echo $button_cart; ?></span></a></div>

For Opencart 3

Remove Spaces Between lines in files of php code

0

The easiest way to remove the lines in the PHP files or in HTML files, aspx files cold fusion file, JSP file from the Dreamweaver. Likewise, we can remove the static page space like of the HTML, XSLT, CSS, XML, Javascript, XML and other as follows:

  1. Open the file
  2. Click CTRL + F
  3. Select “Current document” in “Find in” (You can also select the folder if you have multiple files)
  4. Search in “Source code”
  5. Tick “Use regular expression”
  6. Type “[rn]{2,}” (without quotes) in “Find”
  7. Type “n” (without quotes) in “Replace”
  8. Press “Replace All”

We can also replace the multiple line breaks through coding the coding is as below:

<?php
$base = array("f:/www/docs/files/");
while (!empty($base)) {
    $next = array_pop($base);
    foreach (glob($next . '*.php') as $item) {
        if (!is_dir($item)) {
            file_put_contents($item, preg_replace(array("#^s*r?n+#s", "#s*r?n+$#s", "#s*r?n+#s"), array("", "", "rn"), file_get_contents($item)));
        } else {
            $base[] = $item . '/';
        }
    }
}

echo "Removing extra lines is done";
?>

These are the two methods by which we can remove the extra lines.

Final Year Report on E-shopping, E-commerce with affiliation

2

This is final year report example on E-shopping, E-commerce with affiliation which details about the page title, declaration of the report, Acknowledgement, table of contents, and executive summary.

Final Year Report on E-shopping

named Rupjaygri Shop
By:

Rupak Nepali

P.U. Reg. No: #####, Roll. No: #####

Jayman Tamang

P.U. Reg. No: #####, Roll. No: ####

Grishma Shah

P.U. Reg. No: #####, Roll. No: ####

Final Year Project Report

Submitted To:

Nobel College

Faculty of management

Pokhara University

In partial fulfillment of the requirements for the degree of

Bachelor of Computer Information System (BCIS)

Kathmandu

November 2010

—————————————————————————–

Pokhara University

Faculty of Management

Nobel College

DECLARATION

We hereby declare that the work reported in this project work on E-shopping named Rupjaygri Shop submitted to Nobel College, Pokhara University is our original work done in the form of partial requirement for the degree of Bachelor of Computer Information System (BCIS) under the supervision of Mr. Surendra Shrestha Principal, Nobel College, and Mr. Dipesh Shrestha, Coordinator, Nobel College, Mr Sanjay Lama Project-Coordinator and Mr. Nimesh Shrestha Lecturer, Nobel College.

Grishma Sharma                        JaymanTamang                                 Rupak Nepali

——————————————————–

Faculty of Management Studies

PokharaUniversity

RECOMMENDATION

This is to certify that the final year report:

Submitted by:

Rupak Nepali

Jayman Tamang

Grishma Sharma

Entitled

E-Shopping named Rupjaygri Shop has been prepared as approved by this college. This internship report is forwarded for examination.

———————————                      ——————-

Principal                                                     Coordinator/Lecturer

Nobel College

Date: June 14, 2010

——————————————————————————

Acknowledgment

This report has been prepared for the Final Year Project on topic E-shopping named Rupjaygri Shop to implement the theory in the real field with the purpose of fulfilling the requirements of the course of BCIS (Bachelor of Computer Information System).

The aim of this project is to make familiar to the practical aspect and uses of theoretical knowledge and clarifying the career goals, so we have successfully completed the project and compiled this report as the summary and the conclusion that we have drawn from the project.

We would like to express our sincere gratitude to our Project Coordinator Mr. Sanjay Lama who had given his valuable time and given us chance to learn something despite having his busy schedule, Principal Mr. Surendra Shrestha and Coordinator Mr. Dipesh Shrestha for their great guidelines.

Lastly, we would like to thank Mr. Nimesh Shrestha who had provided us with the guidance and his easiest MVC framework and for his encouragement, patience and expert advice and also for supplying so much invaluable information and finally special thanks go to my friends and family who have supported us throughout our project.

——————————————————–

Table of Contents

SNContentsPage No
a.Title Pagei
b.Declarationii
c.Recommendationiii
dAcknowledgmentiv
e.Table of Contentsv
f.List of Figuresvii
g.Executive Summaryix
h.Chapters
 Introduction 1.1.  
Background of Study
1.2.   Objectives of the Study
1.3.   Limitations of the Study
1.4.   Selection Methods of Data Collection
Report Body
2.1.    Introduction of the D.P Sign
2.2.    Corporate Goal of the D.P Sign
2.3.    Mission Statement of the D.P Sign
2.4.    D.P Sign™s Spirit is infused into every component

2.5.    Services
2.5.1.      Web-Based Application Design and Development
2.5.2.      Flex printing and other printing services
2.5.3.       Custom Software Solutions
2.5.4.       Embedded Software Solutions
2.5.5.       Online Earning Training

2.6.    Engagement Models
2.6.1.       Fixed Price Turnkey Model
2.6.2.       Per Resource Model
2.6.3.       Offshore Model

2.7.    Delivery Model
2.8.    Process and Standards
2.9.    Domain Profile
2.10.                    Competitive Advantage of DP Sign
2.11.                    Physical Infrastructure
2.12.                    Organizational Hierarchy Chart
2.13.                    The number of employees
2.14.                    Introduction of Departments We have worked at
2.15.                   Major Clients
2.16.                    Business Volume
2.17.                    Products Offered by DP Sign
2.18.                    Time Frame of Internship Analysis

3.1.    Strategic Business Units
3.1.1         Web Development Department Analysis
3.1.2        Online Earning Department Analysis
3.1.3        PEST Analysis
3.1.4        SWOT Analysis

4            Recommendations
5            Summary and Conclusion 6            Program Workplace Relationship

1  
1
1
1
2
3
3
4
4
4
5

5
5
5
5
5
6
6

6
6
7
7

11
13
14
15
16
16
20
20
21
22
23
23
23

24
25
26
28
29

30
i.Bibliography 
j.Appendices

List of Figures

SNName of FigurePage No.
Fig:2.1Organization Structure13
Fig:2.2The business volume of DP Sign19
Fig:2.3Timeframe representation in Gantt chart22

List of Tables

SNName of TablePage No.
Tab:2.1System unit and its Software11
Tab:2.2List of technology with the platform
Tab:2.3Number of employees
Tab:2.4Collection of Pay Per Click sites
Tab:2.5List of major clients
Tab:2.6Printing product of DP Sign
Tab:2.7Web services providing by DP Sign

ABBREVIATION USED

DP SignDigital Printed Sign
CRMCus­­­tomer Relation Management
ITInformation Technology
QAQuality Assurance
CMSContent Management System
SWOTStrength, Weakness, Opportunity, and Threats
PESTPolitical, Economical, Social and Technological
RFQRequest For Quotation
RFPRequest For Proposal
GISGeographic Information System
PMBOKProject Management Body of Knowledge
PMIProject Management Institute
CMMICapability Maturity Model Integration
ISOInternational Organization for Standardization
ODCOffshore Development Center
IPInternet Protocol
CVSCurrent Version Software
TFSTeam Foundation Server

EXECUTIVE SUMMARY

The main objective of this report is to recapitulate our Final Year Project on E-shopping named Rupjaygri Shop and to be familiar with the practical aspect of the theoretical knowledge gained in a classroom. This report is the part of the final year project, required by Pokhara University in partial fulfillment for the requirement of BCIS program.

We (Rupak Nepali, Jayman Tamang, and Grishma Sharma) feel that Nepal is progressing in the ICT field thus the import and export of this country are mounting with the help of e-commerce and e-businesses. Thus, there is a need for shopping software so that people can broaden their business worldwide.

Our Team was inspired by the quote