Category Archives: eCommerce

Easy Currency Conversion in eCommerce Website using CurrencyLayer

If you are an eCommerce developer creating eCommerce websites or mobile apps or mobile web apps, you always have to deal with currency conversation. Specifically if you are dealing with global customers.  This has to be done properly and carefully or else it will create chaos in system. Some time Customers have to pay more than actual amount and receiver will get less money and nobody would like that. So it will be better if you use some secure and reliable API for currency conversation and CurrencyLayer is one such API.

CurrenyLayer

Adding CurrencyLayer to your eCommerce Application

It gives you free account with limited API requests. Also there are other paid plans with more API request. You can signup from here. Start using currency layer API.

Once you signup you will get an API key, which you have to pass in API requests. Now we will see some APIs of currency layer and see how we can use it.

Please note here base currency will be USD.

Getting all currency listing

To get list of all the supported currency by API. You have to make get request with following params.

http://apilayer.net/api/list?access_key=YOUR_API_KEY&format=1

Here we have specified format = 1, which will give us return data in JSON format, Here is sample output.

{
“success”:true,
“terms”:”https://currencylayer.com/terms”,
“privacy”:”https://currencylayer.com/privacy”,
“currencies”:{
“AED”:”United Arab Emirates Dirham”,
“AFN”:”Afghan Afghani”,
“ALL”:”Albanian Lek”,
“AMD”:”Armenian Dram”,
“USD”:”United States Dollar”,
“UYU”:”Uruguayan Peso”,
“UZS”:”Uzbekistan Som”,
“VND”:”Vietnamese Dong”
}
}

Getting real time conversation rate

You have to make API call with following params.

http://apilayer.net/api/live?format=1&currencies=USD&access_key=YOUR_API_KEY&currencies=GBP,EUR,

And following is sample output.
{
“success”: true,
“terms”: “https://currencylayer.com/terms”,
“privacy”: “https://currencylayer.com/privacy”,
“timestamp”: 1496300046,
“source”: “USD”,
“quotes”: {
“USDGBP”: 0.77777,
“USDEUR”: 0.889028
}
}

Here we are passing API key format and currencies as param and it will give us conversation rate for this currencies for USD

So using this API you can easily add conversation features to your eCommerce application. It will be reliable and real time so you don’t have to worry about issue in conversation. The currencylayer API is one of the easiest to use APIs I’ve ever worked with.

Magento 1.9 Ajax Login with Social Connectors

We are using Magento 1.9 right now for one the project as Magento 2.0 has certain performance issue and some of the extensions are not yet available for Magento 2.0. In this project we have a requirement to add Ajax Login with Social connector options which includes, login with Facebook and Login with Google. Problem we faced is, there is no free extension available in market which allows both ajax login and give you social connector options. So what I did is I installed two different extensions for Ajax Login and Social Connectors and then merged code from social connector plugin to Ajax Login plugin.

In this blog I am going to explain how you can do this.

First of you have to install following two plugins in Magento.

GoMage Social Connector
Ajax Login

With the first login you will get social login options in admin where you can configure your social networks like Facebook and Google and add necessary information like App id and redirect URL etc.

Once it’s configured in admin, you will get Social Connectors option in login page like this.

But we need this options in Ajax Login Popup.

So to do this we will copy code for GoMage Extension to this. To do this go to.

app/design/frontend/base/default/template/digitalpianism/ajaxlogin

And open index.phtml file.

Add following code before buttons code.

<!– Social Login –>
<a href=”#” onclick=”gomageSocialFBLogin();return false;” title=”<?php echo $this->getText(‘facebook’) ?>”>
Login with Facebook
</a>

<a href=”<?php echo $this->getUrl(‘gomage_social/google/login’, array(‘_secure’ => true, ‘gs_url’ => Mage::helper(‘core’)->urlEncode(Mage::helper(‘core/url’)->getCurrentUrl())));  ?>” title=”<?php echo $this->getText(‘google’) ?>”>
Login with Google
</a>

That’s it and now you will have social connector options in Ajax login.

I have just added basic designs, you can change it as per your requirements.

Update Magento 2 From 2.0.0 to 2.0.2

In this blog I am going to mention how to update Magento 2.0 from 2.0.0 to 2.0.2 This procedure you can follow for future updates as well.

There are two ways to do this. If you don’t like to work with command line tools, then you can upgrade Magento from System Upgrade in admin.

Login to Magento Admin and Go to

System > Tools > Web Setup Wizard

Here there is an option “System Upgrade”

Select that option and follow through wizard. For more information check following link.

Other way to upgrade is with command lines which I like the most as it’s just matter of typing some commands and your Magento is upgraded.

Go to terminal and go to your Magento root directory and run following commands.

composer require magento/product-community-edition 2.0.2 –no-update
composer update

This will update your Magento. After update do some clean up and indexing with following set of commands.

rm -rf var/di var/generation
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex

And you have updated Magento 2 version.

Magento 2.0 Missing Write Permissions in Directory var When Run bin/magento setup:upgrade

Hello,

Recently in of our Magento product we installed a Payment Gateway module on our Magento for that we have to run following command.

php bin/magento setup:upgrade php

But every time we run this command we end with following exception.

Missing write permissions to the following directories: public_html/var

so at first it looks like write permission issue in directory, so we gave write permission to directory

chmod 777 ./var

And command run successfully but still we were getting same error while running

php bin/magento setup:upgrade php

That was little wired as we have all the necessary permission but still command was not working. So I decided to get error location and found out following file from where this error is thrown.

setup/src/Magento/Setup/Model/Installer.php

Open this and find following function.

/**
     * Check permissions of directories that are expected to be writable for installation
     *
     * @return void
     * @throws Exception
     */
    public function checkInstallationFilePermissions()
    {
        $results = $this->filePermissions->getMissingWritableDirectoriesForInstallation();
        if ($results) {
            $errorMsg = “Missing write permissions to the following directories: ‘” . implode(“‘ ‘”, $results) . “‘”;
            throw new Exception($errorMsg);
        }
    }

This is the function which throws an error so what I did is I commented all the code in this function and run the command again

php bin/magento setup:upgrade php

and it worked, it updated properly and after that I again uncommented this code and upload file back to server.

PLEASE NOTE THIS IS A HACK, AS A MAGENTO DEVELOPER I DO NOT SUGGEST TO UPDATE SOURCE FILE BUT THERE WAS NO OTHER OPTION SO I TRIED IT. IF YOU ARE TRYING THIS ON YOUR SIDE, PLEASE BE CAREFUL.

Why you should upgrade to Magento 2.0


Magento is the recognized as the leading eCommerce platform for open commerce innovation with over $50B in gross merchandise volume transacted on the platform annually. 

Key features of Magento 2.0

Performance & New Technology:
  • Magento 2.0 is 20% faster than old 1.x versions.
  • A new flexible architecture built on a modern technology stack making it quick to build new sites embracing the latest technology.
Better Security:

  • This latest Magento version supports some steps to deal with server validation. Your online store will get better security.
Improved checkout process:
  • It is no secret that most merchants modify default 6 step checkout to make it easier for the customers. Magento 2.0 addresses this issue with its Shipping & Payment checkout flow. It makes it easy to purchase now and it increases conversation rates.

Improved backend processes:
  • Magento 2.0 makes it easy to add/edit your products, manage orders and customers. You can now change backend grids manually by adding/removing columns. Ajax (without page refresh) requests now all over Magento 2.0 backend. 
 A Countdown for Magento 1.X Support
  • Magento will provide its Magento 1 support until 2018.

Easy to Upgrade
  • Simplified upgrade process our merchants an easier path to the latest version of Magento without costly and complex upgrades. 

Auto-testing 

  •  Automated testing to improve code quality which in itself speeds up time to market for new site builds and changes.

If you planning to upgrade by yourself, Unless you are experienced Magento developer do not do that! You would ruin your online business and would most probably loose some crucial customer data along the way. Migration would involve data, theme, extensions and customizations transfer that require extensive code knowledge to perform bug-free. 

Plan your migration ahead for Magento 2 upgrade at fair price. 

contact us now at info@thedesignshop.co.in or call on (+919898171728)

Magento – Multiple Actions for Single Coupon Code

Hello,

Recently in one of my project we had a requirements to supports multiple actions for single coupon code. For example if my my cart total is between 500 to 1000, the coupon should give flat 50 off discount and if total is more than 1000, coupon should give flat 100 off discount. But coupon code should be same.

We all know that magento only allows unique coupon code and each coupon will have only once action. So how to do this? I have explained it in this blog.  Please note that this solution needs changes in magento database. So only use it if you database very well.

So while looking to solve this issue. I found out that, in magento database there is a unique key defined for coupon code. So to solve this problem we have to remove that unique key.

So open your Magento database and run following SQL command.

ALTER TABLE salesrule_coupon DROP INDEX UNQ_SALESRULE_COUPON_CODE;

This will drop unique key index.

Now go back to magento admin panel and clear the cache and create two different shopping cart rules with different discounts and keep the coupon code same and it will work.

Hope this helps you.

Magento Get All Products With Special Prices

Hello,

Recently in one of my projects we were working with Magento APIs. Where we have to fetch a list of all products with special prices to display hot deals on site. There are no APIs for this in Magento so I decided to write custom logic for that.

Here is how you can fetch it.

First get product collections.

$productCollection = Mage::getModel(‘catalog/product’)->getCollection();
$productCollection->addAttributeToSelect(array(
        ‘image’,
        ‘name’,
        ‘price’,
        ‘short_description’
 ))
 ->addFieldToFilter(‘visibility’, array(
        Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
        Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
 ));

Then apply filter on product collection to get products with only special prices.

$productCollection->addAttributeToFilter(‘special_from_date’, array(‘date’ => true, ‘to’ => $todayDate))
                        ->addAttributeToFilter(‘special_to_date’, array(‘or’=> array(
                        0 => array(‘date’ => true, ‘from’ => $tomorrowDate),
                        1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
                        ), ‘left’);

That’s it and now it will give you collections of only those products for which there is a special price set.

Now just loop through it and add to array.

$hotDeals = array();
foreach ($productCollection as $product){
        $product = Mage::getModel(‘catalog/product’)->load($product->getId());
$name = $product->getName();
$productPrice = number_format($product->getPrice(), 2, ‘.’, ‘,’);
$specialPrice = number_format($product->getSpecialPrice(), 2, ‘.’, ‘,’);

        $hotDeals[] = array(
“product_id” => $product->getId(),
“product_name” => $name,
“product_image” =>  ($product[‘image’] == ‘no_selection’) ? $skinUrl.’frontend/default/default/images/catalog/product/placeholder/thumbnail.jpg’ : (string)Mage::helper(‘catalog/image’)->init($product, ‘image’)->resize(60),
“product_price” => $productPrice,
“special_price” => $specialPrice
);
}

And return it as JSON array.

$resultArray[‘success’] = true;
$resultArray[‘hot_deals’] = $hotDeals;

echo json_encode($resultArray);

Hope this helps you.

Magento Load Quote Generated By API on Frontend

Hello,

Recently in one of my project we were using magento to implement checkout process for third party website. Basically we were using Magento APIs to create quote. Now for the paypal payment we were redirecting users to magento url and start checkout process by redirecting them to paypal and on successful payment redirect back to magento site, place and order and redirect them back to their site. Now the problem is when we redirect user to magento site to start checkout process there is no customer or checkout session hence checkout can not be started as shopping cart was empty. In this blog I am going to explain how to load quote generated by API on frontend and start checkout process.

First of all let me explain why we have to this changes. Magento has its own session management on front end. It will not load cart of there is no checkout session found on front end. So we have to store everything in frontend session so magento can remember it.

First of all you have to pass three params when user is redirecting to magento site. Following are three params required.

customer_id
quote_id
store_id

As on front end we have to set specific store and create customer session with customer_id and load shopping cart. I was using following URL for redirection.

http://yourmagento/paypal/express/start/button/1/?customer_id=1&store_id=3&quote_id=146

As you can see above we are directly starting checkout process and redirecting user to paypal. But before that we have to set store and generate customer session and load quote. So lets go step by step. First of all open following file.

app/code/core/Mage/Core/Controller/Varien/Front.php
and find following function.
/**
     * Init Front Controller
     *
     * @return Mage_Core_Controller_Varien_Front
     */
    public function init()
    {
    }
This function is called first for any magento URL request. So here are going to do some initialization steps.
First let’s set up the store for which quote id was generated. Add following code to start of init function.
$storeId = ”;
//////////////////////////////////////Setting up store id///////////////////////////
if(isset($_REQUEST[‘store_id’])){
        $storeId = $_REQUEST[‘store_id’];
    Mage::getSingleton(‘core/session’)->setStoreId($_REQUEST[‘store_id’]); 
}
if( Mage::getSingleton(‘core/session’)->getStoreId()){
$storeId = Mage::getSingleton(‘core/session’)->getStoreId();
}
switch($storeId){
case “1” : Mage::app()->setCurrentStore(‘store1’);break;
case “2” : Mage::app()->setCurrentStore(‘store2’);break;
default: Mage::app()->setCurrentStore(‘store1’);break;
}
//////////////////////////////////////////////////////////////////////////////////////
First we are checking if there is store id in request then first we are storing it to magento core session. Later we are getting it from session and storing respective store. Please note this is required if you have multiple stores, else you can avoid this. In my case there were multiple stores. 
Now next step is to create customer session. Add following code after above code.
////////////////////////////////////////Setting up customer id////////////////////////
if(isset($_REQUEST[‘customer_id’])){
Mage::getSingleton(‘core/session’)->setCustomerId($_REQUEST[‘customer_id’]); 
}
        
if( Mage::getSingleton(‘core/session’)->getCustomerId()){
Mage::getSingleton(‘customer/session’)->loginById(Mage::getSingleton(‘core/session’)->getCustomerId());
}
//////////////////////////////////////////////////////////////////////////////////////
Now next step is to store quote id in session so it can be used later.
/////////////////////////////////////////Saving Quote Id//////////////////////////////
if(isset($_REQUEST[‘quote_id’])){
Mage::getSingleton(‘core/session’)->setQuoteId($_REQUEST[‘quote_id’]); 
}
//////////////////////////////////////////////////////////////////////////////////////
Now open following file.
/app/code/core/Mage/Checkout/Model/Session.php
And check following function.
/**
     * Get checkout quote instance by current session
     *
     * @return Mage_Sales_Model_Quote
     */
    public function getQuote()
    {
    }
Add below code to the function after following line.
Mage::dispatchEvent(‘custom_quote_process’, array(‘checkout_session’ => $this));
//////////////////////////////////////////Returning quote stored in session////////////////////////
if(Mage::getSingleton(‘core/session’)->getQuoteId()){
    $this->_quote = Mage::getModel(‘sales/quote’)->setStore(Mage::app()->getStore())->load(Mage::getSingleton(‘core/session’)->getQuoteId());
return $this->_quote;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
That’s it and now you can start checkout process with this quote. Hope this helps you. 

Convert your Magento Store to Mobile Store and Mobile Web Application (Magento Mobile)

Do you have a Magento store and you want to reach to maximum number customers? Then read this blog.

As we know that mobile revolution has changed the world. Number of people are using smart phones and tablets now a days for day to day work. They use mobile internet for almost everything. So your customers may browse your magento store from mobile devices and if your store is not optimized for mobile, it may not load on mobile, or have some issue. Hence users may not be able to buy products on your store and eventually you lost your customer. Now lets see in details, why you need separate mobile web app for your store.

1) Limited Screen Size

On mobile devices screen size is limited so we don’t get much space like desktop computers to show data. In very small space you have to effectively show the content to user so user can easily read it and see it. Many magento stores have this issues. As the site is optimized for desktop only, so the content is not visible properly.

2) Limited BandWidth

Generally mobile networks are slow you your magento store may take time to load. As we know that for each magento page there are some CSS some JS files. There are plenty of images, banners etc. Every time when user navigate on your magento store there is considerable delay in loading resources of the page. This may slow down performance on the mobile devices. Some of the users don’t like slow websites.  If we use responsive mobile theme, we can improve the layout performance but still we have delay in page refresh

3) Different Resolutions

As we know that there are mobile devices with different screen resolutions. For example iPhone has high resolution retina display. Some of the android phones also support HD graphics. While some mobiles does not support HD graphics. In this scenario your assets like images, CSS should support high resolution and normal resolution. So if you don’t support high graphics, your website does not look good on high resolution devices.

So how to solve all above problems and optimize your magento store for all the mobile devices? We have a solution for that. We have built an JavaScript/HTML 5 /CSS 3 based application for magento stores. This application has following features. With our solution your magento store is easily converted to Magento Mobile Store.

1) Responsive layout to fit all the devices.
2) Support all types of touch gestures
3) Show resources based on resolution
4) Rendering engine to support landscape and portrait orientation
5) Have services to load data instead of page refreshes.
6) Supports private browsing
7) Slide navigation for menus
8) Support for local storage of data
9) Supports all types of magento products
10) Customized from same magento admin
11) Optimized for best speed and performance.
12) Rich user interface

Our solution is completely build in HTML and JavaScript. So once the application is loaded. There is no page refresh. All the navigation is local navigation. Data is coming via Ajax request with JSON format. It drastically reduces the network usage. It uses space such a way that you will see the clear information about products and content.

Don’t believe it? See the difference
This is our recent implementation in one of the biggest magento store. Following is the regular desktop site in iPhone.

As you see that it looks bit cluttered in iPhone. None of the content is visible unless you zoom in. So to read the content properly, you have to zoom in and zoom out. After zoom in you have to scroll left and right to see the content properly.Now lets how our mobile web app for magento looks in mobile browser.

Pretty cool right? With our application your magento store look like mobile web application in mobile phones and users have easy to use navigation, clear content, rich media, high resolution graphics, high performance. When you implement our solution, your users will still see the desktop site when they view it on desktop browsers. But they will see above mobile app when they visit your store from mobile browser.

Want this app for your magento store? Contact me right away.

Email : hdave10@gmail.com
Skype: hiren.dave
Phone: +91-9327452580

Convert your eCommerce Store to Mobile Store and Mobile Application

If you read my earlier blog on eCommerce to mCommerce you will come to know about importance of having mobile commerce, in this blog I am going to explain you mobile commerce solution provided by my company. We have a solution to convert your online store to mobile website or mobile application. If you are using Magento, OpenCart, Big Commerce, WordPress, Joomla, osCommerce, PrestaShop, osCommerce, Zen Cart, Tomato Cart or any other open source shopping cart, we can convert it to mobile web store or application.

When you need Mobile Website and When you need Mobile Application?

There is a difference between mobile website and mobile application. Mobile website is something which user can directly open in the browser and access data of the website.  Mobile application is something which user has to download from the stores and install it and then they can access it.

Following are some advantages of mobile website.

  • Mobile website is instantly available.
  • It can be viewed on almost all the mobile devices.
  • One can find mobile website easily with search engines.
  • Mobile website can be shared easily.
  • Mobile website can act as mobile application as well.

Following are some advantages of mobile application.

  • One can use mobile application offline.
  • One can personalize application.
  • When you need hardware support.

What we offer?

Our solution converts your online store (your eCommerce website) to mobile website/application by using the facilities and services of your existing eCommerce platform. We build a separate mobile website for your store. That means you can manage your website and mobile website with same admin panel offered by your eCommerce platform. All the changes in your store will be available on both the websites.

Why we give you separate mobile website?

As we know the some of the eCommerce platform gives you mobile or responsive theme. These themes are specially designed for mobile screens. But those themes are not 100% user friendly and touch friendly. Also it just gives good look to your mobile website, but in terms of server communication and data usage, it’s not up to mark. As for each request your page is refreshed and it go to server and render new page again. This may be slow in some devices depending your network strength. Also it consumes more bandwidth which may not be good for some users. Sometimes it slow down performance in some of the devices as all the device browsers do not have enough computing power. So with responsive theme your site is not 100% user friendly on mobile devices.

What we offer is site built with JavaScript framework. It’s a HTML 5 based framework with advanced layout engines. It has a controls with rich user interface. Site build with this framework works very well on the mobile devices at it has on demand rendering. It will crate layout only when it’s required, that improves the performance. Once this site is loaded, it will communicate with server only for data. There is no page refresh. Everything works with Ajax based services and only when it’s required. Using this approach your data usage will be reduced and site navigation will be much faster. Application built with this framework has look and feel like native application. This is one more benefit, as normally user likes native designs much. Also with this framework you get offline storage was well your website can work offline as well. Also this website can be converted to mobile application easily and with minimum efforts. So it’s very cost effective solution. With one mobile website, you also get mobile application.

How does backend works on your existing store?

For back end we use web services and those web services uses your existing platform data. So whatever your platform is web services fetch data from it and send data back to mobile website or application. Our solution is not like predefined and fully developed product as we understand that each customer have their unique requirements and needs. So what we have is basic product developed and we customize it according to your need. Some of the current eCommerce platform offers mobile website and applications they have predefined products, you can not make much changes in it and you just have to use what they offer. In stead of this we offer you customized solution for your need.

Everything from mobile websites to web services are customized as per your requirements. Designs of mobile websites are built according to your requirements as we know that you want keep your branding as it is in mobile websites.

So with our solution you get mobile website on your existing eCommerce platform as per your requirements and your needs. You can manage both your site from your existing admin panel of eCommerce Platform. Our mobile website is designed to work all the mobile devices. With our solution, you can reach to more customers and increase your business.

Contact me if you need such solution.

Email : hdave10@gmail.com
Skype: hiren.dave
Phone: +91-9327452580