Forums / Features Wish List / Display price with VAT/TAX and Ex VAT/TAX

Display price with VAT/TAX and Ex VAT/TAX

Views: 57,806

Results 21 to 40 of 367
17 Oct 2007, 6:15 PM
#21
rufus avatar

rufus

Zen Follower

Join Date:
Sep 2007
Posts:
214
Plugin Contributions:
0

Display price with VAT/TAX and Ex VAT/TAX

Hi Hem, Birch

I hacked my own version of this but yours is better so I have switched. Problem is though is that I have the same issue as Birch, what was the final fix?

17 Oct 2007, 6:25 PM
#22
rufus avatar

rufus

Zen Follower

Join Date:
Sep 2007
Posts:
214
Plugin Contributions:
0

Re: Display price with VAT/TAX and Ex VAT/TAX

Hi Guys,

Sorry just figured it out. Hem you should add this as a contribution.

18 Oct 2007, 8:09 AM
#23
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Thanks Rufus, what I would like to do before making it an 'official' contribution is to add it into the admin panel and then try an automate the install as much as possible in order to make it less of a hassle to implement.

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

18 Oct 2007, 10:32 AM
#24
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

To add the admin component:

  1. Change the admin setting DISPLAY_PRICE_WITH_TAX to make it an integer array rather than a boolean and default it to "Display tax included AND excluded prices":
UPDATE `zencart`.`zen_configuration` 
SET `configuration_description` = 'Display prices with Tax?<br /> 0= Display with tax excluded<br /> 1= Display with tax included<br /> 2= Display tax included AND excluded prices',
`set_function` = 'zen_cfg_select_option(array(''0'', ''1'', ''2''),',
`configuration_value` = '2'
WHERE `zen_configuration`.`configuration_id` =15;
  1. Activate the commented out code in includes\functions\functions_prices.php (should start at line 275 and is tagged with !!! AGM), so it should look like:
	if(DISPLAY_PRICE_WITH_TAX==2)
	 $final_display_price = $final_display_price . $show_special_price . $show_sale_price . $final_display_ex_tag . $show_sale_discount . $final_display_price_with_tax . $final_display_inc_tag;
	else
	 $final_display_price = $final_display_price . $show_special_price . $show_sale_price . $show_sale_discount;

Warning- make sure the first line reads "if(DISPLAY_PRICE_WITH_TAX==2)" as there are two errors in my original code

  1. Change the line in includes/functions/functions_taxes.php in the zen_display_tax_value function (should be line 97). The line looks like:
    if ( ($include_tax==true || DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) {

change this to handle the new values of DISPLAY_PRICE_WITH_TAX:

    if ( ($include_tax==true || DISPLAY_PRICE_WITH_TAX == '1') && ($tax > 0) ) {

Finally change all occurrences of "if (DISPLAY_PRICE_WITH_TAX == 'true')" to "if (DISPLAY_PRICE_WITH_TAX != '0')" in the order total modules found at includes/modules/order_total/ and the advance search page. The files requiring change are:

includes/modules/order_total/ot_cod_fee.php
Line #85 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

includes/modules/order_total/ot_coupon.php
Line #49 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

includes/modules/order_total/ot_group_pricing.php
Line #39 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

includes/modules/order_total/ot_gv.php
Line #44 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

includes/modules/order_total/ot_loworderfee.php
Line #90 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

includes/modules/order_total/ot_shipping.php
Line #85 : if (DISPLAY_PRICE_WITH_TAX == 'true') $order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);

includes/modules/pages/advanced_search_result/header_php.php

Line #207 : if ((DISPLAY_PRICE_WITH_TAX == 'true') && ((isset($_GET['pfrom']) && zen_not_null($_GET['pfrom'])) || (isset($_GET['pto']) && zen_not_null($_GET['pto'])))) {

Line #225 : if ((DISPLAY_PRICE_WITH_TAX == 'true') && ((isset($_GET['pfrom']) && zen_not_null($_GET['pfrom'])) || (isset($_GET['pto']) && zen_not_null($_GET['pto'])))) {

Line #356 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

Line #381 : if ((DISPLAY_PRICE_WITH_TAX == 'true') && ((isset($_GET['pfrom']) && zen_not_null($_GET['pfrom'])) || (isset($_GET['pto']) && zen_not_null($_GET['pto'])))) {

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

18 Oct 2007, 10:47 AM
#25
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Other occurrences of "if (DISPLAY_PRICE_WITH_TAX == 'true')" to change to "if (DISPLAY_PRICE_WITH_TAX != '0')":

admin/products_price_manager.php
Line #872 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

includes/classes/order.php
Line #502 : if (DISPLAY_PRICE_WITH_TAX == 'true') {
Line #525 : if (DISPLAY_PRICE_WITH_TAX == 'true') {

If in doubt use the Admin -> Developer Tools and do a Lookup in all files for DISPLAY_PRICE_WITH_TAX

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

18 Oct 2007, 12:37 PM
#26
rufus avatar

rufus

Zen Follower

Join Date:
Sep 2007
Posts:
214
Plugin Contributions:
0

Re: Display price with VAT/TAX and Ex VAT/TAX

Hi Hem,

I have another issue regarding VAT and EX VAT, I have sent you a PM

Regards,

RuFuS

18 Oct 2007, 1:17 PM
#27
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Rufus- read and replied to.

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

18 Oct 2007, 11:28 PM
#28
rufus avatar

rufus

Zen Follower

Join Date:
Sep 2007
Posts:
214
Plugin Contributions:
0

Re: Display price with VAT/TAX and Ex VAT/TAX

I didn't receive anything? :blink:

19 Oct 2007, 10:01 AM
#29
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

How about now???

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

19 Oct 2007, 10:06 AM
#30
birch avatar

birch

New Zenner

Join Date:
Mar 2007
Location:
Amsterdam, The Netherlands
Posts:
11
Plugin Contributions:
0

Re: Display price with VAT/TAX and Ex VAT/TAX

Andrew,
works like a charm!
Much better configurable now.

Just to be consistent I added single quotes around the number 2
in the if statement in includes/functions/function_prices.php line 275

 
if(DISPLAY_PRICE_WITH_TAX ==  2 )

to

 
if(DISPLAY_PRICE_WITH_TAX == '2' )

The function display_price_without_tax in currencies.php is obsolete so I deleted that one. (It is only 3 lines of code but it keeps it lean without them)

Regards,
Peter.

19 Oct 2007, 11:56 AM
#31
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Thanks Peter- you are correct it should be quoted as it is a text field (even though PHP allows the other way too).

The display_price_without_tax was left there for future projects or possibly tighter logic in the zen_get_products_display_price function.

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

21 Oct 2007, 10:44 PM
#32
birch avatar

birch

New Zenner

Join Date:
Mar 2007
Location:
Amsterdam, The Netherlands
Posts:
11
Plugin Contributions:
0

Re: Display price with VAT/TAX and Ex VAT/TAX

Andrew,
Do you have any idea how I let sideboxes/shopping_cart.php show the prices with the Inc and Ex tax setup?

Regards,
Peter.

21 Oct 2007, 11:09 PM
#33
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Let me have a look and I'll get back to you tomorrow

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

22 Oct 2007, 12:17 PM
#34
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Peter, do you want each line in the shopping cart to display an Ex/Inc price or just the total at the end??? And if putting the Ex/Inc prices on each line do you want them one under the other (like the display in the product info???) or do you want a separate column in the cart listing???

Note the decimal points don't line up with the Ex/Inc display.

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

22 Oct 2007, 2:57 PM
#35
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

To do main shopping cart display:

  1. Edit includes/modules/pages/shopping_cart/header_php.php

Look for the following lines (they were at line 129 on mine):

  $productsPrice = zen_get_products_display_price($products[$i]['id'], $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
  $productsPriceEach = zen_get_products_display_price($products[$i]['id'], 1). ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');

Replace those two lines with the following (I copied and commented them out).

//  $productsPrice = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
  $productsPrice = zen_get_products_display_price($products[$i]['id'], $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
//  $productsPriceEach = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
  $productsPriceEach = zen_get_products_display_price($products[$i]['id'], 1). ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
  1. Back to the zen_get_products_display_price function in includes/functions/functions_prices.php. First we need to extend the functions parameters to include a quantity. Find the function declaration (it's on line 149 on mine)- it looks like:
function zen_get_products_display_price($products_id) {

change to:

function zen_get_products_display_price($products_id,$quantity=1) {
  1. Within the same function change the following lines (at line 196 on mine):
    $display_normal_price = zen_get_products_base_price($products_id);
    $display_special_price = zen_get_products_special_price($products_id, true);
    $display_sale_price = zen_get_products_special_price($products_id, false);

so that they now multiply the price by the quantity:

    $display_normal_price = zen_get_products_base_price($products_id)*$quantity;
    $display_special_price = zen_get_products_special_price($products_id, true)*$quantity;
    $display_sale_price = zen_get_products_special_price($products_id, false)*$quantity;
  1. Finally we need to do the subtotal box at the bottom of the cart. This means quite a large overhaul of the shoppingCart class in includes/classes/shopping_cart.php. If you've not made any changes to this then probably the best thing is to replace the entire file with the version in the zip file (all the other changed files are there too). Otherwise all my changes are tagged !!! AGM.

Now edit your custom tpl_shopping_cart_default.php (in includes/templates/YOUR CUSTOM FOLDER/templates). Find the line that reads:

<div id="cartSubTotal"><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $cartShowTotal; ?></div>

and completely replace with the following:

<div id="cartSubTotal">
<?php
 echo SUB_TITLE_SUB_TOTAL.' ';
 echo $cartShowTotal;
 if(DISPLAY_PRICE_WITH_TAX=='2')
 {
	echo '<span class="productTaxExTag"> '.PRICE_EX_TAX_TEXT.'</span>';
	echo $cartShowTotalIncTax;
	echo '<span class="productTaxIncTag"> '.PRICE_INC_TAX_TEXT.'</span>';
 }
?>
</div>

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

22 Oct 2007, 3:17 PM
#36
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

If you've got the above code in place, then adding to the sidebox is simple. Open up your custom tpl_shopping_cart.php sidebox (location includes/templates/YOUR CUSTOM FOLDER/sideboxes). Find the line that reads:

    $content .= '<div class="cartBoxTotal">' . $currencies->format($_SESSION['cart']->show_total()) . '</div>';

and replace with:

    $content .= '<div class="cartBoxTotal">' . $currencies->format($_SESSION['cart']->show_total());
	if(DISPLAY_PRICE_WITH_TAX=='2')
    {
		$content .= '<span class="productTaxExTag"> '.PRICE_EX_TAX_TEXT.'</span><br />';
		$content .= '<span class="productTaxPrice">'.$currencies->format($_SESSION['cart']->show_total_inc_tax(false)).'</span>';
		$content .= '<span class="productTaxIncTag"> '.PRICE_INC_TAX_TEXT.'</span>';
    }
	$content .= '</div>';

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

22 Oct 2007, 7:28 PM
#37
birch avatar

birch

New Zenner

Join Date:
Mar 2007
Location:
Amsterdam, The Netherlands
Posts:
11
Plugin Contributions:
0

Re: Display price with VAT/TAX and Ex VAT/TAX

Man, you're fast... and good too! :clap:

The term "New Zenner" with your avatar is a bit of an understatement, right?

Thanks to your coding I now have a real good grasp of the template override system as well.

Thank you very much.

Regards,
Peter.

23 Oct 2007, 7:56 AM
#38
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Not at all Peter, thank you for being my lead beta tester :)

I'm afraid the ranking terms are measured by the number of posts- I think I need to get above 100 messages before I'm no longer a "New Zenner".

Final question- do you think this solution is stable enough to be added as a full contribution???

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com

23 Oct 2007, 4:42 PM
#39
birch avatar

birch

New Zenner

Join Date:
Mar 2007
Location:
Amsterdam, The Netherlands
Posts:
11
Plugin Contributions:
0

Re: Display price with VAT/TAX and Ex VAT/TAX

hem:

Final question- do you think this solution is stable enough to be added as a full contribution???

I most certainly do.

Are there any other configurable items (sideboxes or so) in zencart where one might want to display Inc/Ex prices?
I can't think of any right now. But if there are then maybe it is worth making them configurable as well.

Regards,
Peter.

23 Oct 2007, 10:40 PM
#40
hem avatar

hem

Totally Zenned

Join Date:
Sep 2007
Location:
Dublin, Ireland
Posts:
1,281
Plugin Contributions:
5

Re: Display price with VAT/TAX and Ex VAT/TAX

Can't think of any but I will do a Developer Tools search and check

Andrew

Andrew Moore
Omnicia Agile Development
www.omnicia.com