Page 1 of 1

Changing Discount Price Break Price

Posted: Thu Mar 28, 2019 8:31 pm
by Need2Clean Admin
Hi Everyone,

I have a customized default theme for my website and I was wondering if anybody had any ideas how I could change the discount price to show as the price excluding VAT. I have used an XML file to make some changes so far and at present it is showing the price including VAT which is how the website is setup. As we are a mainly business 2 business supplier, we want to show the price ex. VAT as the "headline" price rather than including VAT. You can take a look at a discount break page at https://www.hutchingsdirect.co.uk/black ... 200-ew-bag , so what I am trying to achieve is that the blue box should read "2+ Price Only £9.61 Each - Ex. VAT" rather than "2+ Price Only £11.53 Each - Inc. VAT". Changing the text either side of the price is easy but I am struggling with changing the price from Including VAT to Excluding VAT. Currently the XML file in vqmod I use for this is:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<id><![CDATA[Swap Ex Tax And Inc Tax In Product 2.3.0.2]]></id>
	<version><![CDATA[1.0]]></version>
	<vqmver><![CDATA[2.6.1]]></vqmver>
	<author><![CDATA[Hutchings Direct]]></author>
	<file name="catalog/view/theme/default/template/product/product.tpl">
        <operation error="skip">
            <search position="replace" offset="27"><![CDATA[
				<?php if ($price) { ?>
			]]></search>
            <add position="replace"><![CDATA[
				<?php if ($price) { ?>
          <ul class="list-unstyled">
		  <?php if ($tax) { ?>
            <li><h2><?php echo $tax; ?><span style="font-weight: 500; font-size: 14px;">&nbsp; <?php echo $text_tax; ?></span></h2></li>
            <?php } ?>
            <?php if (!$special) { ?>
            <li>
             <h5><?php echo $price; ?> Including VAT</h5>
            </li>
            <?php } else { ?>
            <li><h2 style="color:rgb(147,0,0); font-weight: 500; font-size: 14px !important;">Was <?php echo $price; ?><span style="text-decoration: none; font-weight: 500; font-size: 14px;">&nbsp; Including VAT</span></h2></li>
			<li>
              <li><h2 style="font-family: 'Open Sans', sans-serif !important; background-color: rgb(35, 161, 209) !important; font-size: 19px !important; height: 42px !important; padding-top: 10px !important; padding-bottom: 10px !important; padding-left: 10px !important; padding-right: 10px !important; color: rgb(255, 255, 255) !important;">Now <?php echo $special; ?>&nbsp; Including VAT</h2></li>
            </li>
            <?php } ?>
            
            <?php if ($points) { ?>
            <li><?php echo $text_points; ?> <?php echo $points; ?></li>
            <?php } ?>
            <?php if ($discounts) { ?>
            <li>
              <hr>
            </li>
            <?php foreach ($discounts as $discount) { ?>
            <li><h5 style="background-color: rgb(35,161,209) !important; color: rgb(255, 255, 255) !important; padding-left: 10px !important; padding-right: 10px !important; padding-top: 10px !important; padding-bottom: 10px !important; font-weight: 700 !important; font-size: 17px !important;"><?php echo $discount['quantity']; ?><?php echo $text_discount; ?>&nbsp; <?php echo $discount['price']; ?><span style="color: rgb(255,255,255) !important;">&nbsp; Each - Inc. VAT</h5></span></li>
            <?php } ?>
            <?php } ?>
          </ul>
          <?php } ?>
			]]></add>
        </operation>
	</file>
</modification>

Re: Changing Discount Price Break Price

Posted: Tue Apr 02, 2019 1:39 pm
by ocmta
In default theme it already shows price without taxes here:

Code: Select all

 <?php if ($product['tax']) { ?>
                <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
 <?php } ?>
Needs "Display Prices With Tax" enabled in settings.

Re: Changing Discount Price Break Price

Posted: Tue Apr 02, 2019 1:53 pm
by ocmta
But if you want to copy price without tax into special price you can do the following in catalog/controller/product/product.php (using vqmod or otherwise):
find this block:

Code: Select all

if ($this->config->get('config_tax')) {
	$data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']);
} else {
	$data['tax'] = false;
}
And put this below:

Code: Select all

$data['special'] = $data['tax'];
Similarly, find this:

Code: Select all

if ($this->config->get('config_tax')) {
	$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
} else {
	$tax = false;
}
And put this below:

Code: Select all

$special = $tax;

Re: Changing Discount Price Break Price

Posted: Tue Apr 02, 2019 3:28 pm
by Need2Clean Admin
Thanks for the reply, but that is not what I was asking. I don't want to change what is displaying i.e. the discount price, I just need to show it excluding Tax.

I want to display the discount price excluding tax but Opencart only displays it including tax. Do you have any ideas how this can be achieved?

Re: Changing Discount Price Break Price

Posted: Tue Apr 02, 2019 3:51 pm
by ocmta
Need2Clean Admin wrote:
Tue Apr 02, 2019 3:28 pm
but Opencart only displays it including tax.
No, it shows excluding tax too, see my first reply.