PHP - Prestashop E-Commerce articles tutorials: January 2015

Friday, 9 January 2015

Displaying "Total Discount" in Prestashop Shopping Cart

In this article i am going to explain how we can show our valued customers/visitors how much they have saved by purchasing items/products at a discounted price.  
I will also show how to calculate and output total customer's savings i.e. discount on the shopping cart page.

Firstly we need to alter the template "shopping-cart.tpl" under your current theme directory.
Following code will calculate the total savings- discount in the shopping cart.

{assign var='totalReductonPercent' value=0}
{assign var='totalReductonValue' value=0}
{foreach $products as $product}
      {assign var='totalReductonValue' value=$totalReductonValue + $product.price_without_specific_price * $product.quantity}
{/foreach}
{assign var='totalReductonPercent' value=(($totalReductonValue - $total_products) / $totalReductonValue) * 100}



We need to use following code to display discount on shopping cart page.

<tr class="cart_total_discount">
    <td colspan="{$col_span_subtotal}" class="text-right">{l s='Total discount'}</td>
    <td colspan="2" class="price" id="total_discount">
        {convertPrice price=$totalReductonValue - $total_products}<br>
        <span class="price-percent-reduction small">{($totalReductonPercent)|round|string_format:"%d"}%</span><br>
    </td>
</tr>

Prestashop database import tutorial into phpMyAdmin

I would like to show you how to import this  to new database. The same as before PHPMyAdmin is necessary, so log in please to your account. 
Firstly you need to check database exist or not which you are going to create.
To do so lets check left side menu whether database exists or not ?
If not then contact your system administrator to create database.

We will import prestashop.sql file to database created in our web hosting account. Click on your new database that created like below:




After clicking on the database you will see database configuration settings.
Just to verify that whether tables are already exists are not? 
Your prestashop.sql file contains tables structures as well as data for same. 


Click on "Import" button from top menu, you will see import settings page. All you have to to is select the .sql file that you exported, in this case the filename is prestashop.sql




Finally click on "Go" button, wait for a few secs because your database is now uploading into system.
After uploading database system will give you notification about successfull transaction.

How to create prestashop database backup using phpmyadmin?

Database Backup

Go to PHPMyAdmin panel and Log in to  PHPMyAdmin account, Click on databases link from Top menu or from left side menu select database that you want to export 


After entering in database you will see lots of prestashop tables listing here. Click on "Export" button.


After clicking on "Export" button you will see export feature settings like export method and format :










Select quick from export method and format which will be sql.
After that database will be downloaded systematically. Finally you have full database backup.