For up-sell strategy, most of my client ask me to show recommended products in the cart page, so i started to think about it.
I am confused with 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. I analyzed and at last i make a decision to show the related products in the cart as recommended products for you.
Following is the steps of code i have done in the opencart:
Paste the code in the cart.tpl
<?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.


