Hi, I need a discount only if customer buy items from a specific different category, ex:
items from cat. A + cat. B = no discount
items from cat. A + cat. C= no discount
Items from cat. A + cat. D= discount
Items from cat. B + cat. D= discount
Do you know something to works in this way?
Thanks
Simone
for example
Code: Select all
<?php
class ModelTotalCategoryDiscount extends Model {
public function getTotal(&$total_data, &$total, &$taxes) {
$discount = 0;
AB = 0; //tems from cat. A + cat. B = no discount
AC = 0; //items from cat. A + cat. C= no discount
AD = NNN;//Items from cat. A + cat. D= discount
BD = MMM;//Items from cat. B + cat. D= discount
$this->load->model('catalog/product');
$cat = array();
foreach ($this->cart->getProducts() as $product) {
$categories = $this->model_catalog_product->getCategories($product['product_id']);
foreach ($categories as $category) {
$cat[$category] = $category;
}
}
$discount = 0;
if (isset($cat[A]) && isset($cat[B])) {
$discount = AB;
} elseif (isset($cat[A]) && isset($cat[C])){
$discount = AC;
} elseif (isset($cat[A]) && isset($cat[D])){
$discount = AD;
} elseif (isset($cat[B]) && isset($cat[D])){
$discount = BD;
}
if ($discount) {
$total_data[] = array(
'code' => 'categorydiscount',
'title' => 'categorydiscount',
'value' => -$discount,
'sort_order' => 0
);
$total -= $discount;
}
}
}
I bought this extension and it works fine for what I need!
http://www.opencart.com/index.php?route ... unt&page=2
http://www.opencart.com/index.php?route ... unt&page=2
Who is online
Users browsing this forum: No registered users and 6 guests