If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Currencies & Sales Taxes, VAT, GST, etc. / Where can I find "zen_get_tax_locations()" function

Where can I find "zen_get_tax_locations()" function

Started by wsworx on 12 Jun 2018, 3:30 PM · Views: 20,218

Results 1 to 13 of 13
12 Jun 2018, 3:30 PM
#1
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #1 by wsworx

https://www.wildsteedworx.com
1.5.5f
PHP 7
winchester_black_updated
admin_new_orders_1.4
edit_orders-4.3.3
encrypted_master_password-2.3.0
MSRP_Display_1.3.1
Personalized My Account Link v2.0_For_ZCv150
super_orders_4.0.9_revised
twitch_base_cost_16a_for_154
Twitch_HiddenSearchable_ModelNo_for_155f
USPS_2018_03_28_K10
zen_TyPackageTracker-master

I am having an issue with "admin_new_orders_1.4" where when I create a new order I get an error page initially and the following error log is created:

" PHP Fatal error: Uncaught Error: Call to undefined function zen_get_tax_locations() in /home2/wildstee/public_html/includes/modules/order_total/ot_loworderfee.php:64
Stack trace:
#0 /home2/wildstee/public_html/includes/classes/order_total.php(72): ot_loworderfee->process()
#1 /home2/wildstee/public_html/****************/new_order.php(252): order_total->process()
#2 {main}
thrown in /home2/wildstee/public_html/includes/modules/order_total/ot_loworderfee.php on line 64"

Of course it is obvious that what is wrong is the "zen_get_tax_locations()" is missing but I cannot figure out where it is to replace it.
I had installed TaxCloud a while back but did not realize exactly how their system worked until after I got it installed and began using it.
I subsequently decided to remove it which I thought I had done successfully but now I have this issue.

Any help would be greatly appreciated.

Thank You

12 Jun 2018, 4:11 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #2 by mc12345678

Includes/functions/functions_taxes.php

Right where one might expect to find tax related functions. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jun 2018, 4:22 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #3 by lat9

@wsworx, your issue with "Admin New Order" might have to do with this EO GitHub issue, which was incorporated in EO 4.3.2.

Essentially, EO "used to" provide that function as an "include if not present" for everyone and now includes the function only for its use.

12 Jun 2018, 4:35 PM
#4
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #4 by wsworx

mc12345678:

Includes/functions/functions_taxes.php

Right where one might expect to find tax related functions. :)

I thought the same thing but when I looked originally I could not find it in the "functions_taxes".
Must have been late when I looked in it originally......now I see it in the file but I am still getting the error.

12 Jun 2018, 4:42 PM
#5
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #5 by wsworx

lat9:

@wsworx, your issue with "Admin New Order" might have to do with this EO GitHub issue, which was incorporated in EO 4.3.2.

Essentially, EO "used to" provide that function as an "include if not present" for everyone and now includes the function only for its use.

Thank You lat9

I have read through the Git Hub and I get what is happening to a degree but totally unclear as to how to fix it.
So is it throwing the error because it is being called from New Order's file and not Edit Orders file?

12 Jun 2018, 5:51 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #6 by lat9

wsworx:

Thank You lat9

I have read through the Git Hub and I get what is happening to a degree but totally unclear as to how to fix it.
So is it throwing the error because it is being called from New Order's file and not Edit Orders file?
What you said is correct. That change to EO makes those function declarations only available when EO is active.

I'm not familiar with "Admin New Order", so I'm hesitant to provide required code to get you going but I'll give it a shot.

At the very top of the 'admin_new_orders.php' (or whatever the module's name is), after the line that requires 'includes/application_top.php', add the following:

if (!function_exists('zen_get_tax_locations')) {
 function zen_get_tax_locations($store_country = -1, $store_zone = -1) {
  global $db;
    switch (STORE_PRODUCT_TAX_BASIS) {

      case 'Shipping':
        $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                                from " . TABLE_ADDRESS_BOOK . " ab
                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                and ab.address_book_id = '" . (int)$_SESSION['sendto'] . "'";
        $tax_address_result = $db->Execute($tax_address_query);
      break;
      case 'Billing':

        $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                                from " . TABLE_ADDRESS_BOOK . " ab
                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                and ab.address_book_id = '" . (int)$_SESSION['billto'] . "'";
        $tax_address_result = $db->Execute($tax_address_query);
      break;
      case 'Store':
        $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                                from " . TABLE_ADDRESS_BOOK . " ab
                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                and ab.address_book_id = '" . (int)$_SESSION['billto'] . "'";
        $tax_address_result = $db->Execute($tax_address_query);

        if ($tax_address_result ->fields['entry_zone_id'] == STORE_ZONE) {

        } else {
          $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                                  from " . TABLE_ADDRESS_BOOK . " ab
                                  left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                                  where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                                  and ab.address_book_id = '" . (int)$_SESSION['sendto'] . "'";
        $tax_address_result = $db->Execute($tax_address_query);
       }
     }
     $tax_address['zone_id'] = $tax_address_result->fields['entry_zone_id'];
     $tax_address['country_id'] = $tax_address_result->fields['entry_country_id'];
     return $tax_address;
 }
}

I'm guessing, though, that that function's missing is the "tip of the iceberg".

12 Jun 2018, 9:57 PM
#7
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #7 by wsworx

lat9:

What you said is correct. That change to EO makes those function declarations only available when EO is active.

I'm not familiar with "Admin New Order", so I'm hesitant to provide required code to get you going but I'll give it a shot.

At the very top of the 'admin_new_orders.php' (or whatever the module's name is), after the line that requires 'includes/application_top.php', add the following:

if (!function_exists('zen_get_tax_locations')) {
function zen_get_tax_locations($store_country = -1, $store_zone = -1) {
global $db;
switch (STORE_PRODUCT_TAX_BASIS) {

  case 'Shipping':
    $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                            from " . TABLE_ADDRESS_BOOK . " ab
                            left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                            where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                            and ab.address_book_id = '" . (int)$_SESSION['sendto'] . "'";
    $tax_address_result = $db->Execute($tax_address_query);
  break;
  case 'Billing':

    $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                            from " . TABLE_ADDRESS_BOOK . " ab
                            left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                            where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                            and ab.address_book_id = '" . (int)$_SESSION['billto'] . "'";
    $tax_address_result = $db->Execute($tax_address_query);
  break;
  case 'Store':
    $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                            from " . TABLE_ADDRESS_BOOK . " ab
                            left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                            where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                            and ab.address_book_id = '" . (int)$_SESSION['billto'] . "'";
    $tax_address_result = $db->Execute($tax_address_query);

    if ($tax_address_result ->fields['entry_zone_id'] == STORE_ZONE) {

    } else {
      $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id
                              from " . TABLE_ADDRESS_BOOK . " ab
                              left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)
                              where ab.customers_id = '" . (int)$_SESSION['customer_id'] . "'
                              and ab.address_book_id = '" . (int)$_SESSION['sendto'] . "'";
    $tax_address_result = $db->Execute($tax_address_query);
   }
 }
 $tax_address['zone_id'] = $tax_address_result->fields['entry_zone_id'];
 $tax_address['country_id'] = $tax_address_result->fields['entry_country_id'];
 return $tax_address;

}
}

> 
> I'm guessing, though, that that function's missing is the "tip of the iceberg".

Tried that but it did not change anything.
It appears as though the Admin New Order Designer was attempting to address this issue in the "new_order.php" file:

// Create the new order
zen_db_perform(TABLE_ORDERS, $sql_data_array);
$cInfo->orders_id = $db->Insert_ID();

		// Use the normal order class instead of the admin one
		require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'order.php');
		$GLOBALS['order'] = new order($cInfo->orders_id);
		$GLOBALS['order']->info['tax_groups'] = array();

		// Load required modules for order totals if enabled
		if(defined('MODULE_ORDER_TOTAL_INSTALLED') && zen_not_null(MODULE_ORDER_TOTAL_INSTALLED)) {
			// Edit Orders 4.0
			if(version_compare(EO_VERSION, '4.0', '>=') && version_compare(EO_VERSION, '4.1', '<')) {
				$supported_order_total_modules = 'ot_subtotal;ot_total';

				require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'order_total.php');
				$GLOBALS['order_total_modules'] = new order_total();
				$module_list = explode(';', $supported_order_total_modules);

				foreach($module_list as $module) {
					$module_file = DIR_FS_CATALOG . DIR_WS_MODULES . 'order_total/' . $module . '.php';
					if(@file_exists($module_file)) {
						include_once($module_file);
						$GLOBALS[$module] = new $module;
						$GLOBALS['order_total_modules']->modules[] = $module . '.php';
					}
				}
			}
			// Edit Orders 4.1+
			else if(version_compare(EO_VERSION, '4.1', '>=')) {
				require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'order_total.php');
				$GLOBALS['order_total_modules'] = new order_total();

				require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'shopping_cart.php');
				$_SESSION['cart'] = new shoppingCart();
			}
			else {
				// Could not find a supported version of Edit Orders
				break;
			}

Your thoughts on this chunk of code.
12 Jun 2018, 11:10 PM
#8
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #8 by carlwhat

wsworx,
i will give you my 2 cents... for free...

when you say, you tried that, but it did not change anything, are you saying the error log is exactly the same? after implementing lat9's suggestion? if so, i find that curious....

instead of the change that lat9 recommended, you could try removing the top code from:

YOUR_ADMIN/includes/functions/extra_functions/edit_orders_functions.php

//remove this part:

if (basename($PHP_SELF, '.php') != FILENAME_EDIT_ORDERS) {
    return;
}

however, i look at your OP, and whoa nellie.... you have these plugins installed:

admin_new_orders_1.4
edit_orders-4.3.3
encrypted_master_password-2.3.0
super_orders_4.0.9_revised

now, my experience is that 3 of these do not play nice together. and how you could get them all to work together.... well, apparently they do not.

my recommendation would be to use EMP (encrypted_master_password-2.3.0) to place any new orders and get rid of admin_new_orders. i think it is a much more elegant solution, and you can get much familiar with how good/bad your customer checkout process is....

barring those 2 suggestions, you can add the function into:

YOUR_ADMIN/includes/functions/extra_functions/custom_functions.php

and leave everything else unaffected. why i dislike this is the repeat of all the code. in addition to which, it seems that some of it makes use of session variables, and i'm not sure if admin_new_order is setting the customer id.

i have all my clients use EMP to place admin new orders. that leaves me with one set of order entry code to maintain and keep straight.

with regards to the last piece of code that you want some thoughts on, again use EMP and you can ignore this bit of code. checking for version numbers?? oy! in addition, that code is only loading classes and not functions.

good luck! (and i really mean that!)

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

13 Jun 2018, 1:37 AM
#9
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #9 by wsworx

carlwhat:

wsworx,
i will give you my 2 cents... for free...

when you say, you tried that, but it did not change anything, are you saying the error log is exactly the same? after implementing lat9's suggestion? if so, i find that curious....

instead of the change that lat9 recommended, you could try removing the top code from:

YOUR_ADMIN/includes/functions/extra_functions/edit_orders_functions.php

//remove this part:

if (basename($PHP_SELF, '.php') != FILENAME_EDIT_ORDERS) {
return;
}

> 
> however, i look at your OP, and whoa nellie....  you have these plugins installed:
> 
> admin_new_orders_1.4
> edit_orders-4.3.3
> encrypted_master_password-2.3.0
> super_orders_4.0.9_revised
> 
> now, my experience is that 3 of these do not play nice together.  and how you could get them all to work together.... well, apparently they do not.
> 
> my recommendation would be to use EMP (encrypted_master_password-2.3.0) to place any new orders and get rid of admin_new_orders.  i think it is a much more elegant solution, and you can get much familiar with how good/bad your customer checkout process is....
> 
> barring those 2 suggestions, you can add the function into:
> 
> YOUR_ADMIN/includes/functions/extra_functions/custom_functions.php
> 
> and leave everything else unaffected.  why i dislike this is the repeat of all the code.  in addition to which, it seems that some of it makes use of session variables, and i'm not sure if admin_new_order is setting the customer id.
> 
> i have all my clients use EMP to place admin new orders.  that leaves me with one set of order entry code to maintain and keep straight.
> 
> with regards to the last piece of code that you want some thoughts on, again use EMP and you can ignore this bit of code.  checking for version numbers??  oy!  in addition, that code is only loading classes and not functions.
> 
> good luck!  (and i really mean that!)

*when you say, you tried that, but it did not change anything, are you saying the error log is exactly the same?   after implementing lat9's suggestion?  if so, i find that curious....*
I have all of them playing together accept for this one issue. I have not had any database mismatch issues or missing info so far.
Yes that is what I was saying. However, after walking away for a bit and coming back I now realize that it has changed slightly.

PHP Fatal error:  Uncaught Error: Call to undefined function zen_get_tax_description() in /home2/wildstee/public_html/includes/modules/order_total/ot_loworderfee.php:66
Stack trace:#0 /home2/wildstee/public_html/includes/classes/order_total.php(72): ot_loworderfee->process()
#1 /home2/wildstee/public_html/***************/new_order.php(299): order_total->process()#2 {main}
  thrown in /home2/wildstee/public_html/includes/modules/order_total/ot_loworderfee.php on line 66

EMP has been recommended to me before and I looked at it but I do not like accessing the customer's log in just to generate a new order. While I understand what your saying and to some degree agree with it I find it to be unprofessional and dangerous to have data entry folks accessing customer's accounts online just to enter phone orders. I find it rather odd that the ZenCart developers have never implemented some of these very basic features.
13 Jun 2018, 1:47 AM
#10
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #10 by wsworx

"instead of the change that lat9 recommended, you could try removing the top code from:

YOUR_ADMIN/includes/functions/extra_functions/edit_orders_functions.php

PHP Code:
//remove this part:

if (basename($PHP_SELF, '.php') != FILENAME_EDIT_ORDERS) {
return;
}"

So I removed the changes lat9 recommended and did the change you recommended above but still get the same error now as before about zen_get_tax_locations. I'm going to try your other two suggestions now.

13 Jun 2018, 1:55 AM
#11
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #11 by wsworx

Is there not a way to simply tell new_order.php file to use the functions from the functions_taxes.php file?
Of course it is the ot_loworderfee.php file that is making the call so it seems it would need to be in there but then again if it was in there it would probably screw with Edit_Orders when it was trying to run.

13 Jun 2018, 1:38 PM
#12
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #12 by carlwhat

wsworx:

Is there not a way to simply tell new_order.php file to use the functions from the functions_taxes.php file?
Of course it is the ot_loworderfee.php file that is making the call so it seems it would need to be in there but then again if it was in there it would probably screw with Edit_Orders when it was trying to run.

apparently there is not a simple way. i would think that our previous attempts would have solved this problem. looking back at the thread, the first error log calls it out at line 64. the second error log calls it out at line 66. i'm not sure what you have added to:

includes/modules/order_total/ot_loworderfee.php

as zen_get_tax_locations() is only called once in that script.

there is more than 1 way to skin a cat (or so they say...), and previous suggestions should work... especially the part about removing the beginning of the code from the edit_orders_functions.php. i have tested this on my own systems, so i'm not real sure what to say.

we can try one last thing. create a new file here:

YOUR_ADMIN/includes/auto_loaders/config.admin_taxes.php

in that file add the following code:

<?php
$autoLoadConfig[200][] = array(
    'autoType' => 'require',
    'loadFile' => DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/functions_taxes.php'
);

this should load all of the tax functions for the admin side.

where you can run into a problem with this approach is for edit_orders as that add on makes use of functions with the same name and they may be slightly different. you might want to look at that.

i agree with your assessment that these functions should be part of the base ZC install. the 3 add-ons we are talking about have always been my least favorite to debug, and i empathize with you.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

13 Jun 2018, 6:59 PM
#13
wsworx avatar

wsworx

Zen Follower

Join Date:
Jun 2012
Location:
California
Posts:
260
Plugin Contributions:
0

Post #13 by wsworx

carlwhat:

apparently there is not a simple way. i would think that our previous attempts would have solved this problem. looking back at the thread, the first error log calls it out at line 64. the second error log calls it out at line 66. i'm not sure what you have added to:

includes/modules/order_total/ot_loworderfee.php

as zen_get_tax_locations() is only called once in that script.

there is more than 1 way to skin a cat (or so they say...), and previous suggestions should work... especially the part about removing the beginning of the code from the edit_orders_functions.php. i have tested this on my own systems, so i'm not real sure what to say.

we can try one last thing. create a new file here:

YOUR_ADMIN/includes/auto_loaders/config.admin_taxes.php

in that file add the following code:

<?php $autoLoadConfig[200][] = array( 'autoType' => 'require', 'loadFile' => DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/functions_taxes.php' ); ``` > > this should load all of the tax functions for the admin side. > > where you can run into a problem with this approach is for edit_orders as that add on makes use of functions with the same name and they may be slightly different. you might want to look at that. > > i agree with your assessment that these functions should be part of the base ZC install. the 3 add-ons we are talking about have always been my least favorite to debug, and i empathize with you. > > best. Can't thank you enough for taking time out to help me with this issue. I will go back and test your previous suggestions again before moving to the new one. I won't claim to ever get anything right the first time, or in some cases even the second time, but eventually it gets handled. Thank You and I will update here as soon as I have tested again.