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 361 to 367 of 367
17 Jan 2020, 12:42 PM
#361
mattbough avatar

mattbough

New Zenner

Join Date:
Feb 2015
Location:
UK
Posts:
13
Plugin Contributions:
0

Display price with VAT/TAX and Ex VAT/TAX

Hi,

Just a quick question. If i wanted to use this plugin on the tpl_modules_products_all_listing.php file for the category products to show in / ex vat how would I go about doing this?

Thanks

4 Jun 2020, 8:10 PM
#362
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

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

Tried this module on a 1.5.6c install and I'm getting incorrect values in checkout.
Line item shows £59.72
Sub Total shows £60.00 Ex VAT, £71.94 Inc VAT
UK VAT (20%) £11.94
Total £71.66

I've identified it as an issue with the following code in tpl_modules_order_totals.php

foreach($products as $product) {
$cartShowTotalIncTax+=(zen_round($product['final_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($product['final_price'], zen_get_tax_rate($product['tax_class_id'])))$product['quantity'];
$cartShowTotalExTax+=(zen_round($product['final_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']))
$product['quantity'];
}

where $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] is returning no value. If i replace that specific part of the code with a hardcoded 2 then it displays the correct values.

DEFAULT_CURRENCY is being correctly identified as GBP.
Echoing $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] in shopping cart page will output '2', but nothing during checkout.

Not found a reason for this yet. Has anybody else experienced this issue, and how did you resolve it?

Zen Cart developer since 2009 — Zen Cart Solutions
Ecommerce development, integrations & automation — Junction Solutions

10 May 2021, 2:24 PM
#363
cunningstunt2 avatar

cunningstunt2

Zen Follower

Join Date:
Jan 2019
Location:
UK
Posts:
113
Plugin Contributions:
0

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

Is this plugin ok to use on 1.5.7c? I have a development store im building to update my live store to the latest version of zen-cart, but after installing this plugin i'm getting a few warnings logged.

[10-May-2021 13:37:23 UTC] Request URI: /index.php?main_page=product_info&cPath=101&products_id=283, IP address: 195.162.105.81
#1  include(/home/thegluep/devstore.thegluepeople.co.uk/includes/functions/extra_functions/inc_ex_functions.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/includes/modules/extra_functions.php:43]
#2  include(/home/thegluep/devstore.thegluepeople.co.uk/includes/modules/extra_functions.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/includes/init_includes/init_general_funcs.php:51]
#3  require_once(/home/thegluep/devstore.thegluepeople.co.uk/includes/init_includes/init_general_funcs.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/includes/autoload_func.php:37]
#4  require(/home/thegluep/devstore.thegluepeople.co.uk/includes/autoload_func.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/includes/application_top.php:222]
#5  require(/home/thegluep/devstore.thegluepeople.co.uk/includes/application_top.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/index.php:25]
--> PHP Warning: Use of undefined constant zen_get_products_display_price - assumed 'zen_get_products_display_price' (this will throw an Error in a future version of PHP) in /home/thegluep/devstore.thegluepeople.co.uk/includes/functions/extra_functions/inc_ex_functions.php on line 10.

[10-May-2021 13:37:23 UTC] Request URI: /index.php?main_page=product_info&cPath=101&products_id=283, IP address: 195.162.105.81
#1  get_products_display_price() called at [/home/thegluep/devstore.thegluepeople.co.uk/includes/templates/bootstrap/templates/tpl_product_info_display.php:71]
#2  require(/home/thegluep/devstore.thegluepeople.co.uk/includes/templates/bootstrap/templates/tpl_product_info_display.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/includes/modules/pages/product_info/main_template_vars.php:153]
#3  require(/home/thegluep/devstore.thegluepeople.co.uk/includes/modules/pages/product_info/main_template_vars.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/includes/templates/bootstrap/common/tpl_main_page.php:195]
#4  require(/home/thegluep/devstore.thegluepeople.co.uk/includes/templates/bootstrap/common/tpl_main_page.php) called at [/home/thegluep/devstore.thegluepeople.co.uk/index.php:94]
--> PHP Warning: Use of undefined constant display_special_price - assumed 'display_special_price' (this will throw an Error in a future version of PHP) in /home/thegluep/devstore.thegluepeople.co.uk/includes/functions/extra_functions/inc_ex_functions.php on line 56.
10 May 2021, 2:38 PM
#364
cunningstunt2 avatar

cunningstunt2

Zen Follower

Join Date:
Jan 2019
Location:
UK
Posts:
113
Plugin Contributions:
0

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

I should probably mention, although i'm getting warning logs generated, the inc/ex vat prices are being displayed correctly.

25 May 2021, 11:58 PM
#365
cunningstunt2 avatar

cunningstunt2

Zen Follower

Join Date:
Jan 2019
Location:
UK
Posts:
113
Plugin Contributions:
0

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

strelitzia:

Tried this module on a 1.5.6c install and I'm getting incorrect values in checkout.
Line item shows £59.72
Sub Total shows £60.00 Ex VAT, £71.94 Inc VAT
UK VAT (20%) £11.94
Total £71.66

I've identified it as an issue with the following code in tpl_modules_order_totals.php

foreach($products as $product) {
$cartShowTotalIncTax+=(zen_round($product['final_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($product['final_price'], zen_get_tax_rate($product['tax_class_id'])))$product['quantity'];
$cartShowTotalExTax+=(zen_round($product['final_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']))
$product['quantity'];
}

where $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] is returning no value. If i replace that specific part of the code with a hardcoded 2 then it displays the correct values.

DEFAULT_CURRENCY is being correctly identified as GBP.
Echoing $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] in shopping cart page will output '2', but nothing during checkout.

Not found a reason for this yet. Has anybody else experienced this issue, and how did you resolve it?

I believe I also had this issue as documented here
https://www.zen-cart.com/showthread.php?228058-Strange-problem-with-prices-displayed-at-final-stage-of-checkout&p=1380953#post1380953

but had not managed to find the code where it was rounding the information shown before payment. I 'fixed' the problem by replacing the VAT modules tpl_modules_order_totals.php with the one that came with my bootstrap template.

27 Jun 2021, 8:50 AM
#366
billj avatar

billj

New Zenner

Join Date:
Sep 2013
Location:
Devon, UK
Posts:
88
Plugin Contributions:
1

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

I just fixed this myself in 1.57c after finding the rounding problem. The issue is that $currencies, which is a global, appears not to have been declared as global and therefore a local copy is created implicitly instead, which doesn't contain anything. I assume in previous Zen Cart versions $currencies was declared global in some code that included the template. I've only previously tried it up to 1.55f so I can't comment on 1.56 versions but it sounds like they're affected too.

The solution for me was to edit the template file includes/templates/YOUR_TEMPLATE/templates/tpl_modules_order_totals.php as follows.

Original:

<?php 
/**
 * Displays order-totals modules' output
 */
  for ($i=0; $i<$size; $i++) { ?>

to:

<?php 
/**
 * Displays order-totals modules' output
 */
  global $currencies;
  
  for ($i=0; $i<$size; $i++) { ?>

Having found and fixed the problem, however, I may now just delete the template override altogether, which is pretty much what CunningStunt2 has done. I think I prefer never to display the subtotal with VAT, even when showing prices inclusive of VAT to our UK customers. Including VAT in the subtotal and then showing the VAT on a separate line on the invoice prompts periodic queries from customers who think they have been charged VAT twice and haven't actually tried totting up the numbers to see that they haven't. I currently get around this by changing the "VAT: £x.xx" line to read "(Includes VAT: £x.xx)" but it is conventional for the subtotal on an invoice not to include VAT.

4 Aug 2023, 9:44 PM
#367
billj avatar

billj

New Zenner

Join Date:
Sep 2013
Location:
Devon, UK
Posts:
88
Plugin Contributions:
1

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

Wow! No posts since my own last post.

Now trying to get this working on 1.58, it all looks fine from the catalog side but things fail on the admin side, for example in the catalog listing.
The reason appears to be that the prices functions that were previously specific to the admin side have been removed in 1.58 and it now shares the catalog-side prices functions, which are replaced by this mod.

The solution for 1.58+ only:

After merging all the changes to install the mod, edit includes/functions/functions_prices.php and replace this line:

//function zen_get_products_display_price($product_id)

with these lines:

function zen_get_products_display_price($product_id)
{
    if (IS_ADMIN_FLAG === false)
        return get_products_display_price($product_id);
    else
        return xxx_get_products_display_price($product_id);
}