Zen Cart Logo
Forums / Zen Cart Code Suggestions / ot_tax.php language definition ignored

ot_tax.php language definition ignored

Views: 216

Results 1 to 9 of 9
6 Dec 2011, 4:10 PM
#1
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

ot_tax.php language definition ignored

All versions of Zen-Cart, e.g. 1.3.9h and upcoming 1.5
Clean Install

Problem:
You can define a text for the tax description in includes/languages/english/order_total/ot_tax.php
This is normally defined as:

define('MODULE_ORDER_TOTAL_TAX_DESCRIPTION', 'Order Tax');

No matter what you define here during the checkout and in the order confirmation email this definition is not called and you only get shown the tax percentage as defined in Location/Taxes > Tax Rates > Description
So you get something like this:
Sub-Total: €583.09
Per Item (Best Way):€2.50
19%:€93.10
Total:€585.59

Solution:
Change in includes/modules/order_total/ot_tax.php
line 48 (1.3.9h)
from

$this->output[] = array('title' => ((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  $key) . ':',

to

$this->output[] = array('title' => $this->description .' '.((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  $key) . ':',

and in line 56 (1.3.9h)
from

$taxDescription .= ((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  $key) . ' + ';

to

$taxDescription .= $this->description .' '.((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  $key) . ' + ';

and you will get what is supposed to be:
Sub-Total: €583.09
Per Item (Best Way):€2.50
Order Tax 19%:€93.10
Total:€585.59

9 Apr 2019, 7:20 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: ot_tax.php language definition ignored

It appears in those cases you have not given a Tax Description when defining the Tax Rate.

When a description is provided in the Admin "Tax Rates" screen, it shows up as intended.

Your proposal would double-up both descriptions, so question: what will you do in that case?

Attachment 18405 Attachment 18406

9 Apr 2019, 10:14 PM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: ot_tax.php language definition ignored

I will investigate further when possible,
thanks.

10 Apr 2019, 6:13 AM
#4
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: ot_tax.php language definition ignored

I agree, this thread can be closed.

10 Apr 2019, 7:57 AM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: ot_tax.php language definition ignored

Hand raised in the corner.

Not having 2 or more languages installed on a test server that I can think of, the "tax rates" screen's description box: does it support multi-language? Meaning, can different text be entered for each language supported by the store or is it a one entry for all type thing?

If it is a one-size fits all, then I could see where it just might be desirable to have more flexibility with a language constant. Unless I'm wrong, the OP doesn't appear to imply the need for multi-language support, just some level of language.

10 Apr 2019, 10:18 AM
#6
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: ot_tax.php language definition ignored

Doh, that should be my hand since I do fall over language stuff that others forget.

This has cropped up as I have this post referenced in the file and so spotted it on 156 merging, even though I now do not use it.

So you are both right, the description in the tax definition does show up, BUT as it is not multilingual, it is something that does needs correcting as per this thread!

No doubt that was my (long-forgotton) reason for implementing it.

10 Apr 2019, 2:00 PM
#7
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,682
Plugin Contributions:
56

Re: ot_tax.php language definition ignored

torvista:

So you are both right, the description in the tax definition does show up, BUT as it is not multilingual, it is something that does needs correcting as per this thread!

Steve, would you please work up a PR for this?

11 Apr 2019, 9:27 AM
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: ot_tax.php language definition ignored

ok, but don't hold your breath.

25 Apr 2019, 9:29 PM
#9
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: ot_tax.php language definition ignored

I spent some time on this but it's too much of a rabbit hole for me.

I defined multiple taxes in the admin, then used the db id as part of the constant that would provide the language title.

includes/modules/order_total/ot_tax.php

define('MODULE_ORDER_TOTAL_TAX_TITLE_1', 'EN Tax 1');
define('MODULE_ORDER_TOTAL_TAX_TITLE_2', 'EN Tax 2');
define('MODULE_ORDER_TOTAL_TAX_TITLE_3', 'EN Tax 3');

Then in

class ot_tax {
  var $title, $output;

  function __construct() {
    $this->code = 'ot_tax';
    $this->title = "MODULE_ORDER_TOTAL_TAX_TITLE_";//stub of tax title constants
    $this->description = MODULE_ORDER_TOTAL_TAX_DESCRIPTION;
    $this->sort_order = defined('MODULE_ORDER_TOTAL_TAX_SORT_ORDER') ? MODULE_ORDER_TOTAL_TAX_SORT_ORDER : null;
    if (null === $this->sort_order) return false;

    $this->output = array();
  }

  function process() {
    global $order, $currencies;

    $taxTitles = '';//concatenated tax titles shown for non-split display
    $taxValue = 0;
    if (STORE_TAX_DISPLAY_STATUS == 1)
    {
      $taxAddress = zen_get_tax_locations();
      $result = zen_get_all_tax_descriptions($taxAddress['country_id'], $taxAddress['zone_id']);
      if (count($result) > 0)
      {
        foreach ($result as $description)
        {
          if (!isset($order->info['tax_groups'][$description]))
          {
            $order->info['tax_groups'][$description] = 0;
          }
        }
      }
    }
    if (count($order->info['tax_groups']) > 1 && isset($order->info['tax_groups'][0])) unset($order->info['tax_groups'][0]);
    $index = 1;
      foreach($order->info['tax_groups'] as $key => $value) {
      if (SHOW_SPLIT_TAX_CHECKOUT == 'true')
      {
        if ($value > 0 or ($value == 0 && STORE_TAX_DISPLAY_STATUS == 1 )) {
            $this->output[] = array('title' => ((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  constant($this->title . $index) . ':'),
                                  'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
                                  'value' => $value);
        }
      } else
      {
        if ($value > 0 || ($value == 0 && STORE_TAX_DISPLAY_STATUS == 1))
        {
          $taxTitles .= ((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  constant($this->title . $index)) . ' + ';
          $taxValue += $value;
        }
      }
      $index++;
    }
    if (SHOW_SPLIT_TAX_CHECKOUT != 'true' && ($taxValue > 0 or STORE_TAX_DISPLAY_STATUS == 1))
    {
      $this->output[] = array(
                      'title' => substr($taxTitles, 0 , strlen($taxTitles)-3) . ':' ,//remove final '+' from concatenated titles
                      'text' => $currencies->format($taxValue, true, $order->info['currency'], $order->info['currency_value']) ,
                      'value' => $taxValue);
    }
  }

Which gives these, depending if tax is split or not
Attachment 18420Attachment 18421
So this would require either a column in the admin taxes table to show users the constant name they need to define for each tax/or the constant name in the info box.

Then I looked at this constant
MODULE_ORDER_TOTAL_TAX_DESCRIPTION
and saw it gets used with
function zen_get_all_tax_descriptions
which collects the non-language-dependent descriptions defined in the admin...and I thought "nah".
I personally don't need this functionality so cannot justify the time to code this completely.
Just documenting it here for someone who DOES need it enough to work it through properly...