Thread: Plus VAT

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Plus VAT

    Currently I have set up a cart where after prices it displays + VAT

    This is coded into languages/english.php as define('TEXT_PRICE_TAX', '<div class="plusVat">&nbsp;+ VAT</div>');

    I have put it in a dive so that it can be disabled on a per category basis in a stylesheet with ‘display:none;’

    However I would like this to show or hide ‘+ VAT’ depending on if the product is a Taxable Product or not.

    So in the admin, if the product Tax Class is set up as Taxable Goods then it will display on the front end as £1.99 + VAT. If the product is set up as Tax Class: None if would display on the front end as £1.99 NO VAT or just £1.99
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  2. #2
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Plus VAT

    Instead of the define having the + VAT, create a new define that has that text. Change the above + VAT to %s. Then wherever the above define is used, change to
    Code:
    sprintf(TEXT_PRICE_TEXT, $is_taxable ? NEW_VAT_DEFINE : '');
    $is_taxable can be replaced by a function evaluation or earlier it could be set to a true or false condition based on the current product/display.

    That at least is one way to do it.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Re: Plus VAT

    Quote Originally Posted by mc12345678 View Post
    Instead of the define having the + VAT, create a new define that has that text. Change the above + VAT to %s. Then wherever the above define is used, change to
    Code:
    sprintf(TEXT_PRICE_TEXT, $is_taxable ? NEW_VAT_DEFINE : '');
    $is_taxable can be replaced by a function evaluation or earlier it could be set to a true or false condition based on the current product/display.

    That at least is one way to do it.
    Ok you mean change it in functions_prices.php?

    in this case I have this line:

    $show_normal_price = '<br /><span class="productBasePrice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . TEXT_PRICE_TAX . '</span>';

    So where it says TEXT_PRICE_TAX how would I change the code?
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  4. #4
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Plus VAT

    Quote Originally Posted by Nick1973 View Post
    Ok you mean change it in functions_prices.php?

    in this case I have this line:

    $show_normal_price = '<br /><span class="productBasePrice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . TEXT_PRICE_TAX . '</span>';

    So where it says TEXT_PRICE_TAX how would I change the code?
    Ok. So now that I've tried to search a vanilla install for TEXT_PRICE_TAX to no avail, my answer changes a little.

    So, in your setup above:
    Code:
    $show_normal_price = '<br /><span class="productBasePrice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . (zen_get_tax_rate($product_check->fields['products_tax_class_id']) != 0.0 ? TEXT_PRICE_TAX : '') . '</span>';
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Plus VAT

    Quote Originally Posted by mc12345678 View Post
    Ok. So now that I've tried to search a vanilla install for TEXT_PRICE_TAX to no avail, my answer changes a little.

    So, in your setup above:
    Code:
    $show_normal_price = '<br /><span class="productBasePrice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . (zen_get_tax_rate($product_check->fields['products_tax_class_id']) != 0.0 ? TEXT_PRICE_TAX : '') . '</span>';
    Yes you won't find that in a vanilla install as it is my own custom define.

    I will try this in the morning. Thank you.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  6. #6
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Plus VAT

    Quote Originally Posted by Nick1973 View Post
    Yes you won't find that in a vanilla install as it is my own custom define.

    I will try this in the morning. Thank you.
    Pay attention to the logs directory. While I haven't done the necessary research, I'm concerned that there might be a case depending on server configuration where the result from the zen_get_tax_rate may return an integer (0) instead of a float (0.0) and causing a type mismatch. May require casting the function(s) result as a float to prevent that problem if it becomes one. I am also making a few assumptions about it becoming an issue but have seen related issues where 0 was used instead of 0.0.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    Default Re: Plus VAT

    Quote Originally Posted by mc12345678 View Post
    Pay attention to the logs directory. While I haven't done the necessary research, I'm concerned that there might be a case depending on server configuration where the result from the zen_get_tax_rate may return an integer (0) instead of a float (0.0) and causing a type mismatch. May require casting the function(s) result as a float to prevent that problem if it becomes one. I am also making a few assumptions about it becoming an issue but have seen related issues where 0 was used instead of 0.0.
    Ok no worries, will give it a go anyway and report back if anything flags up. Obviously I am experienced to know that backups are essential as well so it will be just a case of testing it and seeing if it works. Then if it doesn't, put the original back and see whats wrong.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  8. #8
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Plus VAT

    Quote Originally Posted by mc12345678 View Post
    Pay attention to the logs directory. While I haven't done the necessary research, I'm concerned that there might be a case depending on server configuration where the result from the zen_get_tax_rate may return an integer (0) instead of a float (0.0) and causing a type mismatch. May require casting the function(s) result as a float to prevent that problem if it becomes one. I am also making a few assumptions about it becoming an issue but have seen related issues where 0 was used instead of 0.0.
    Or just avoid the 0 vs 0.0 and change != 0.0 to > 0
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,227
    Plugin Contributions
    6

    red flag Re: Plus VAT

    Quote Originally Posted by DrByte View Post
    Or just avoid the 0 vs 0.0 and change != 0.0 to > 0
    Ok thanks for this :-)
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  10. #10
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Plus VAT

    Quote Originally Posted by DrByte View Post
    Or just avoid the 0 vs 0.0 and change != 0.0 to > 0
    I didn't chase back to see if it was allowed/possible, but I chose != 0.0 with consideration of a possible negative tax possibly used as some sort/form of price reduction. Though come to think of it I think much of the tax related code does a test similar to the suggested and seems to deal only with 0 or positive numbers.

    Now something else Nick1973, the way I suggested this change doesn't fully align with your requested "identifier". Ie. You asked for the identifier to be present if there was no tax class assigned (-none-) as compared to having a zero tax (-none- and if the tax rate were set to 0). This was chosen out of immediate ease and relative likelihood of coming across a tax rate identified as 0%.

    Having looked back at the entirety of the code section and the actions that get taken when calling zen_get_tax_rate, it would save processing (and database queries) if the added code for the "test" used data that was already available at that point.

    So instead of adding this portion "zen_get_tax_rate(...)"
    You could use the following and there would not be any issue(s) of floats, integers, etc...

    Code:
    ($product_check->fields['products_tax_class_id'] !== 0 ? TEXT_PRODUCT_TAX : '')
    Code:
    $show_normal_price = '<br /><span class="productBasePrice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . ($product_check->fields['products_tax_class_id'] !== 0 ? TEXT_PRICE_TAX : '') . '</span>';
    This would be in line with your original request even if the previously provided code "worked".
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Dispplaying Both With VAT and Without VAT Prices on Products
    By BoydBreen in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 3 Jul 2013, 09:44 PM
  2. How to add PRICE With VAT and Without VAT?
    By staycu in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 25 Jun 2011, 06:16 PM
  3. I have a problem with cupons and vat - EU VAT Mod
    By oberheimer in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 8 Feb 2011, 04:31 PM
  4. How to add Service Tax Plus VAT to items...?
    By ginc in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 1
    Last Post: 29 Mar 2010, 12:56 PM
  5. Price incl. __% VAT. plus shipping etc - please gone
    By jami1955 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 16 Jun 2009, 05:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR