Hello!
Where in ОС 2.0.3 creates the array $discounts (elements of this array)?
It is used in catalog/view/theme/default/template/product/product.tpl Sample:
<?php if ($discounts) { ?><?php foreach ($discounts as $discount) { ?><li><?php echo $discount['quantity']; ?><?php echo $text_discount; ?><?php echo $discount['price']; ?></li><?php } ?><?php } ?>
Code: Select all
catalog/controller/product/product.php line 323
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Thank you, OSWorX, very much!
Please, be so kind help me understand where price with/without tax comes from for $discounts?
has:
I have print_r($discounts) and see price comes with/without tax depending of setting from opencart admin "Display Prices With Tax: Yes/No"
I have change:
again price comes with/without tax depending of setting from opencart admin.
I checked the discount function - there is no tax at all
I need switch setting from opencart admin "Display Prices With Tax: Yes" but to have price without tax in $discounts.
Please, be so kind help me understand where price with/without tax comes from for $discounts?
Code: Select all
/catalog/controller/product/product.php
Code: Select all
$discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
$data['discounts'] = array();
foreach ($discounts as $discount) {
$data['discounts'][] = array(
'quantity' => $discount['quantity'],
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')))
);
}
I have change:
Code: Select all
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')))
to
'price' => $discount['price'],
I checked the discount function - there is no tax at all
Code: Select all
public function getProductDiscounts($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' AND customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND quantity > 1 AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity ASC, priority ASC, price ASC");
return $query->rows;
}
Calculating prices with or without tax comes from the setting:
So if you change
to
you should have your net discount price.
(While I do not understand your change, because if you display prices to end customers EACH prices have to be WITH tax).
Code: Select all
$this->config->get('config_tax')
Code: Select all
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')))
Code: Select all
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], 0))
(While I do not understand your change, because if you display prices to end customers EACH prices have to be WITH tax).
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
OSWorX, thank you very much!!!!!!!
I did it! http://prntscr.com/ic03zy
You have asked why I need it - it is for UK web site. There is popular to show prices without tax. I don't know why it is so. It is like local feature. For me as client it is not handy way because I prefer to see price with tax cause I will pay it anyway.
If somebody use information from this topic I would draw attention to Refresh Modifications in OC 2.3. if you correct $discounts array in controller to have 2 prices with/wthout tax.
I did it! http://prntscr.com/ic03zy
You have asked why I need it - it is for UK web site. There is popular to show prices without tax. I don't know why it is so. It is like local feature. For me as client it is not handy way because I prefer to see price with tax cause I will pay it anyway.
If somebody use information from this topic I would draw attention to Refresh Modifications in OC 2.3. if you correct $discounts array in controller to have 2 prices with/wthout tax.
Who is online
Users browsing this forum: Google [Bot] and 44 guests