i edited module Latest for my new template.
and now i want to add the Add Cart button in home page for specific product.
i create a function in latest.php for show product details :
Code: Select all
public function productdetails($category_id,$number) {
$output = '';
$i=0;
$results = $this->model_catalog_product->getProductsByCategoryId($category_id);
foreach ($results as $result ) {
$output.='<div class="product-shop"><div class="product-shop-left"><img src="';
$i++;
if ($result['image']) {
$thumb = $this->model_tool_image->resize($result['image'], 165, 110);
} else {
$thumb = 'no_image.jpg';
}
$output .=$thumb;
$output.='" /></div><div class="product-shop-right"><a href="#" rel="tooltip" title="امتياز دهيد"><img src="catalog/view/theme/default/image/stars_';
if ($this->config->get('config_review')) {
$rating = $this->model_catalog_review->getAverageRating($result['product_id']);
} else {
$rating = 0;
}
$output .=$rating;
$output .='.png" /></a><a href="#" rel="tooltip" title="add to cart"><img src="catalog/view/theme/default/image/addcart.png" /></a><a href="#" rel="tooltip" title="more"><img src="catalog/view/theme/default/image/moredetails.png" /></a>';
$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
$output .='<a href="#" rel="tooltip" title="price"><p>';
$output .= $price;
$output .= '</p></a></div></div>';
if ($number) {
if ($number == $i ) return $output ;
}
}
return $output;
}
Please help me to solve it.
Thanks