Jump to content

[Resolved] Tax Selection


ayz1

Recommended Posts

In admin, order on the inventory tab when trying to select a tax some of the country names are not showing up, just the country number is showing. This is on 6.1.1 on a clean install and all EU countires selected in the Taxes section. Is this happening to anyone else? Strange it picks up some country names and not others. Any idea how I can fix this?

 

tax.jpg

Link to comment
Share on other sites

Please view CubeCart's Countries/Zones screen. Regarding the ISO Numeric:

208 is Denmark
233 is Estonia
246 is Finland
250 is France

Determine if these countries are in the list. If they are, make sure the numerical value is purely a three-digit number - meaning the value shown does not have any leading spaces, trailing spaces, or a character other than three digits 0-9.

If there is any doubt, hover the mouse cursor over the three-digit value in the table. The mouse cursor will change to a pointy finger. Click to edit.

Delete the entire value, pressing the Delete key and Backspace key for good measure (to delete hidden whitespace characters). Enter the three-digit value. Save.

Repeat for the four instances.

Link to comment
Share on other sites

I just tried Denmark on my test site. Everything looked perfect when I setup a Denmark Sales Tax setting. But when I tried to create an order in Admin, I, too, see 208 instead of Denmark.

I deleted the 208 in the Countries table and typed it again. Then I cleared all cache and tried creating the order with Denmark Sales Tax again - still getting 208.

Link to comment
Share on other sites

As an experiment, be sure CubeCart's Debug mode is enabled. (Enter your IP address in the adjacent field so that only you will see the debug section. www.whatismyip.com) Make this edit:

/admin/sources/order.index.inc.php, near line 250, find:

$country = getCountryFormat($numcode);

Change to:

$country = getCountryFormat($numcode);trigger_error("The numcode is ".(string)$numcode.", and the country returned is ".($country?$country:'unknown'), E_USER_WARNING);

Bring an order up for editing.

Scroll to the bottom of the page where the debug section is shown.

You will find something like this in the PHP section:

PHP:
[Warning] \admin\sources\orders.index.inc.php:250 - The numcode is 56, and the country returned is Belgium
[Warning] \admin\sources\orders.index.inc.php:250 - The numcode is 484, and the country returned is Mexico
[Warning] \admin\sources\orders.index.inc.php:250 - The numcode is 840, and the country returned is United States

We are looking for the four anomalous country codes/names.

Link to comment
Share on other sites

Found it.

In the file /includes/functions.php

Near line 504, in the function getCountryFormat(), find:

if(($match == 'id' || $match == 'numcode') && !ctype_digit($input)) return $input;

Change to:

if(($match == 'id' || $match == 'numcode') && !ctype_digit((string)$input)) return $input;

This post has been edited! The above code has been edited since its initial posting!

 

Issue posted in the Github.

A few lines down, the function getStateFormat() also can be edited:

Near line 564, find:

if($match == 'id' && !ctype_digit($input)) return $input;

Change to:

if($match == 'id' && !ctype_digit((string)$input)) return $input;

 

Edited by bsmither
Link to comment
Share on other sites

line 503 >>

function getCountryFormat($input, $match = 'numcode', $fetch = 'name') {
	/* ORIGINAL 6.1.2 BSMITHER FIX FOR DENMARK BELOW if(($match == 'id' || $match == 'numcode') && !ctype_digit($input)) return $input; */
if(($match == 'id' || $match == 'numcode') && !ctype_digit((string)$input)) {
	$country = $GLOBALS['db']->select('CubeCart_geo_country', array($fetch), array($match => $input));
	return ($country) ? $country[0][$fetch] : false;
}

line 564>>

function getStateFormat($input, $match = 'id', $fetch = 'name') {
	/* STOCK 6.1.2 BSMITHER EDIT BELOW FOR DENMARK if($match == 'id' && !ctype_digit($input)) return $input; */
if($match == 'id' && !ctype_digit((string)$input)) return $input;
	if (($county = $GLOBALS['db']->select('CubeCart_geo_zone', false, array($match => $input))) !== false) {
		return ($fetch == 'abbrev' && empty($county[0][$fetch])) ? $county[0]['name'] : $county[0][$fetch];
	}
	return $input;
}

Other than that includes/functions.inc.php is stock from GitHub 6.1.2. I download the day's commit as a zipped file, extract, and compare with the previous commit. Then I make the changes on the test site. I cannot currently make the database index changes that are in 6.1.2 - Al suspected those changes would not work for everyone, and I'm one who can't use it as is. But I don't think those changes would be an issue here. Everything I've checked on the test site worked properly today, until I tried this Denmark edit.

Link to comment
Share on other sites

Original complete getCountryFormat() from CC611:

function getCountryFormat($input, $match = 'numcode', $fetch = 'name') {
	if(($match == 'id' || $match == 'numcode') && !ctype_digit($input)) return $input;
	$country = $GLOBALS['db']->select('CubeCart_geo_country', array($fetch), array($match => $input));
	return ($country) ? $country[0][$fetch] : false;
}


Changed complete function:

function getCountryFormat($input, $match = 'numcode', $fetch = 'name') {
	if(($match == 'id' || $match == 'numcode') && !ctype_digit((string)$input)) return $input;
	$country = $GLOBALS['db']->select('CubeCart_geo_country', array($fetch), array($match => $input));
	return ($country) ? $country[0][$fetch] : false;
}

Yup - messed up badly in my posting above. Will fix.

 

Link to comment
Share on other sites

The first edit

Change to:

if(($match == 'id' || $match == 'numcode') && !ctype_digit((string)$input)) return $input;

Seems to have solved the problem with my initial post. Country names are now showing and not getting any errors. I have added the second edit

Change to:

if($match == 'id' && !ctype_digit((string)$input)) return $input;

All seems OK, not getting any errors.

Will play about a bit more with it but looks like sorted for 6.1.1

Thank you.

 

tax2.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...