Zen Cart Logo
Forums / Currencies & Sales Taxes, VAT, GST, etc. / TaxJar Issue - Composer Related?

TaxJar Issue - Composer Related?

Views: 14,813

Results 1 to 20 of 31
10 Dec 2022, 11:59 PM
#1
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

TaxJar Issue - Composer Related?

Zen Cart 1.57d. PHP Version: 7.3.33. Not using any other plugins related to checkout process.

Testing the newest chuckphillips TaxJar plugin so I can get away from taxcloud.

Error Message

[10-Dec-2022 18:29:20 America/New_York] PHP Fatal error: require(): Failed opening required '/home/xxxxxxxxx/public_html/taxjar/vendor/autoload.php' (include_path='.:/opt/cpanel/ea-php73/root/usr/share/pear') in /home/xxxxxxxxx/public_html/includes/functions/extra_functions/taxjar.php on line 5

Confused.

autoload.php doesn't exist in that folder

Do I need to do something related to composer on my server or am I not understanding something else?

11 Dec 2022, 12:28 AM
#2
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

sorry to bump, this is the taxjar/composer.json in the plugin. thought this may matter?

{
"name": "taxjar/taxjar-php",
"description": "Sales Tax API Client for PHP 5.5+",
"keywords": [
"taxjar",
"sales tax",
"api"
],
"homepage": "https://www.taxjar.com/",
"license": "MIT",
"authors": [
{
"name": "TaxJar"
}
],
"require": {
"php": ">=5.5.0",
"guzzlehttp/guzzle": "^6.0.2"
},
"require-dev": {
"phpunit/phpunit": "4.8.*",
"internations/http-mock": "0.10.1",
"silex/silex": "2.2.2"
},
"autoload": {
"psr-4": { "TaxJar\" : "lib/" }
}
}

11 Dec 2022, 12:13 PM
#3
chuckphillips avatar

chuckphillips

Zen Follower

Join Date:
Sep 2012
Location:
Upstate South Carolina
Posts:
106
Plugin Contributions:
1

Re: TaxJar Issue - Composer Related?

Yes, its a composer issue. Sorry Ill update the docs to cover that.

Basically, you run composer and it installs the latest Taxjar client api into your store. From a command line, navigate to your store's folder and execute

composer require taxjar/taxjar-php

Taxjar's instructions for the above are here:

https://developers.taxjar.com/api/guides/php/#php-quickstart

Then, to prevent a warning about your PHP version, you will need to mod one more file:

../vendor/composer/platform_check.php

Change:

if (!(PHP_VERSION_ID >= 80100)) {
to 
if (!(PHP_VERSION_ID >= 70300)) {

We run the taxjar client on PHP 7.4 and have used it on 7.2 and 7.3. The latest Taxjar client is asking for php 8+, but has been successfully installed on earlier versions. YMMV

11 Dec 2022, 10:08 PM
#4
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

I just asked support at my host to help me with this.

Was told the following:

I ran the command from the document root, but getting an error : [RuntimeException]
Could not scan for classes inside "not_for_release/testFramework" which does not appear to be a file nor a folder

Now have a vendor folder located at the root with a couple dozen subfolders.

I see a composer and taxjar folder within the vendor folder.

Not seeing ../vendor/composer/platform_check.php that u mentioned

Not seeing an autoload.php file either.

thx for earlier response.
I've never used composer and I avoid CLI because I have limited knowledge at best
Guessing my issue is with Composer installation??

12 Dec 2022, 2:33 AM
#5
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

Request the hosting support to remove the taxjar/taxjar-php

When I was trying to run an update I was getting error message related to my version of php.

Will updating my php version to 8.0 just before I run the composer require again then roll back to php 7.3 give me what I need since the install is looking for php 8.0?

12 Dec 2022, 12:14 PM
#6
chuckphillips avatar

chuckphillips

Zen Follower

Join Date:
Sep 2012
Location:
Upstate South Carolina
Posts:
106
Plugin Contributions:
1

Re: TaxJar Issue - Composer Related?

The vendor folder should be inside the taxjar folder. Try moving it and its contents there.

Or run composer from the public_html/taxjar folder.

12 Dec 2022, 4:05 PM
#7
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

Can't move the vendor folder that was my host support helped me with.

I ended up running the composer require taxjar/taxjar-php command on a different domain that I don't use as a test (and out of fear).

I copied the vendor file from that host and placed it in the public_html/taxjar.

Seems to be working.

Hate to do things in such a roundabout way, but I never used composer and I should have tested it first in a dev environment.

Also

I'm getting the following error:

#1 ot_taxjar->__construct() called at [/home/xxxxxxxxx/public_html/admin/modules.php:106]
#2 require(/home/xxxxxxxxx/public_html/admin/modules.php) called at [/home/xxxxxxxxx/public_html/admin/index.php:11]
--> PHP Warning: Use of undefined constant MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER - assumed 'MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER' (this will throw an Error in a future version of PHP) in /home/xxxxxxxxx/public_html/includes/modules/order_total/ot_taxjar.php on line 20.

function __construct() {
$this->code = 'ot_taxjar';
$this->title = MODULE_ORDER_TOTAL_TAXJAR_TITLE;
$this->description = MODULE_ORDER_TOTAL_TAXJAR_DESCRIPTION;
$this->sort_order = MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER;

}

So I looked at the ot_tax file. Based on that I made the following change:

function __construct() {
$this->code = 'ot_taxjar';
$this->title = MODULE_ORDER_TOTAL_TAXJAR_TITLE;
$this->description = MODULE_ORDER_TOTAL_TAXJAR_DESCRIPTION;
$this->sort_order = defined('MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER') ? MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER : null;
if (null === $this->sort_order) return false;

}

Nothing has blown up yet, so maybe that'll work?

Thx again chuck

12 Dec 2022, 5:12 PM
#8
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

Just got this message:

#1 sizeof() called at [/home/xxxxxxxxx/public_html/includes/classes/order_total.php:66]
#2 order_total->process() called at [/home/xxxxxxxxx/public_html/includes/modules/checkout_process.php:83]
#3 require(/home/xxxxxxxxx/public_html/includes/modules/checkout_process.php) called at [/home/xxxxxxxxx/public_html/includes/modules/pages/checkout_process/header_php.php:14]
#4 require(/home/xxxxxxxxx/public_html/includes/modules/pages/checkout_process/header_php.php) called at [/home/xxxxxxxxx/public_html/index.php:35]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/xxxxxxxxx/public_html/includes/classes/order_total.php on line 66.

Not sure if my change above may have caused this or just the timing of a customer making a purchase?

Using PHP 7.3

12 Dec 2022, 6:19 PM
#9
chuckphillips avatar

chuckphillips

Zen Follower

Join Date:
Sep 2012
Location:
Upstate South Carolina
Posts:
106
Plugin Contributions:
1

Re: TaxJar Issue - Composer Related?

No code change should be necessary at this point. I think you should roll that back.

The constant MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER is undefined for some reason. That is set in the Order Total configuration for the Taxjar module. What do you have for that setting? It is expecting a number.

12 Dec 2022, 7:16 PM
#10
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

I really don't know any PHP, so thanks for ur time.

When I look for examples (like ot_tax.php) or similar files I went into the developers tool kit and searched: $this->sort_order

Seeing examples like ot_cod_fee.php, ot_group_pricing.php, flat.php, etc.

They are all defining the constant for $this->sort_order.

When I look at the bottom part of the ot_taxjar page, I'm seeing the numeric fields are part of the insert statement.

I'm getting the following warning running 7.3 using the original ot_taxjar.php:

#1 ot_taxjar->__construct() called at [/home/xxxxxxxxx/public_html/stifF-qrU-cHill/modules.php:204]
#2 require(/home/xxxxxxxxx/public_html/stifF-qrU-cHill/modules.php) called at [/home/xxxxxxxxx/public_html/stifF-qrU-cHill/index.php:11]
--> PHP Warning: Use of undefined constant MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER - assumed 'MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER' (this will throw an Error in a future version of PHP) in /home/xxxxxxxxx/public_html/includes/modules/order_total/ot_taxjar.php on line 20.

I think the change I attempted above (if it was correct by chance) should have also included an additional line: $this->output = array();

//$this->sort_order = MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER;
$this->sort_order = defined('MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER') ? MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER : null;
if (null === $this->sort_order) return false;

$this->output = array();

Figured the undefined constant was defaulting to true and making sort order values in the db record available?

I'm not saying you're wrong, just trying to understand the mod.

12 Dec 2022, 7:30 PM
#11
chuckphillips avatar

chuckphillips

Zen Follower

Join Date:
Sep 2012
Location:
Upstate South Carolina
Posts:
106
Plugin Contributions:
1

Re: TaxJar Issue - Composer Related?

We just need to determine why MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER is not getting set. It could just need to be configured:

Log in to your store's Admin. Go to Modules/Order Total/TaxJar Sales Tax. On the right side of the page, look for Sort Order. Make sure there is a number there. If not, click edit and put a number in that box.

12 Dec 2022, 7:59 PM
#12
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

ok thx.

It was/is set to 400.

I rolled back my changes.

12 Dec 2022, 8:50 PM
#13
chuckphillips avatar

chuckphillips

Zen Follower

Join Date:
Sep 2012
Location:
Upstate South Carolina
Posts:
106
Plugin Contributions:
1

Re: TaxJar Issue - Composer Related?

Is the error appearing when you visit Checkout Payment?

Are you using standard checkout or OPC?

12 Dec 2022, 9:05 PM
#14
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

Having all kinds of issues. None of them are due to your code.

Think it's all composer related because I stink.

I'm seeing sales tax in the cart, invoice and when I log into paypal to verify it was charged (use them for onsite processing (WPP)).

Not seeing either of my test transactions in TaxJar site yet.

Copied vendor file into taxjar manually. Maybe that's a problem?

Not sure which composer.json to edit but guessing I need to something to require taxjar ^2.0??

Regarding Warning Message:

This is the current error from last 2 customers transactions who didn't need to pay tax

#1 sizeof() called at [/home/xxxxxxxxxx/public_html/includes/classes/order_total.php:66]
#2 order_total->process() called at [/home/xxxxxxxxxx/public_html/includes/modules/checkout_process.php:83]
#3 require(/home/xxxxxxxxxx/public_html/includes/modules/checkout_process.php) called at [/home/xxxxxxxxxx/public_html/includes/modules/pages/checkout_process/header_php.php:14]
#4 require(/home/xxxxxxxxxx/public_html/includes/modules/pages/checkout_process/header_php.php) called at [/home/xxxxxxxxxx/public_html/index.php:35]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/xxxxxxxxxx/public_html/includes/classes/order_total.php on line 66.

Not getting the other message at the moment. Guessing I did something while all out of sorts.

Feel like i'm close but not so much.

12 Dec 2022, 9:47 PM
#15
carlwhat avatar

carlwhat

zennedOut

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

Re: TaxJar Issue - Composer Related?

fravac:

Having all kinds of issues. None of them are due to your code.

Think it's all composer related because I stink.

I'm seeing sales tax in the cart, invoice and when I log into paypal to verify it was charged (use them for onsite processing (WPP)).

Not seeing either of my test transactions in TaxJar site yet.

Copied vendor file into taxjar manually. Maybe that's a problem?

Not sure which composer.json to edit but guessing I need to something to require taxjar ^2.0??

Regarding Warning Message:

This is the current error from last 2 customers transactions who didn't need to pay tax

#1 sizeof() called at [/home/xxxxxxxxxx/public_html/includes/classes/order_total.php:66]
#2 order_total->process() called at [/home/xxxxxxxxxx/public_html/includes/modules/checkout_process.php:83]
#3 require(/home/xxxxxxxxxx/public_html/includes/modules/checkout_process.php) called at [/home/xxxxxxxxxx/public_html/includes/modules/pages/checkout_process/header_php.php:14]
#4 require(/home/xxxxxxxxxx/public_html/includes/modules/pages/checkout_process/header_php.php) called at [/home/xxxxxxxxxx/public_html/index.php:35]
--> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/xxxxxxxxxx/public_html/includes/classes/order_total.php on line 66.

Not getting the other message at the moment. Guessing I did something while all out of sorts.

Feel like i'm close but not so much.

i think your original changes were fine. that error was coming up only prior to taxjar being installed. once installed and the config values are entered into the database, the error disappears. i would think chuck phillips (if he is still maintaining the code) should address that.

i think the 2nd error, if i understand it correctly is only happening when someone has an order that is not taxable. if so, i would change the __construct method of includes/modules/order_total/ot_taxjar.php as so:

    function __construct()
    {
        $this->code = 'ot_taxjar';
        $this->title = MODULE_ORDER_TOTAL_TAXJAR_TITLE;
        $this->description = MODULE_ORDER_TOTAL_TAXJAR_DESCRIPTION;
        $this->sort_order = MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER;
        $this->sort_order = defined('MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER') ? MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER : null;
        if (null === $this->sort_order) return false;
        $this->output = [];
    }

i do not use this plugin, so pure guesses.

hope it helps.

best.

12 Dec 2022, 9:51 PM
#16
chuckphillips avatar

chuckphillips

Zen Follower

Join Date:
Sep 2012
Location:
Upstate South Carolina
Posts:
106
Plugin Contributions:
1

Re: TaxJar Issue - Composer Related?

That's good. If you're seeing values back from taxjar, your composer issue is solved. I wouldn't worry about that.

It takes a good while to see the transactions in taxjar.

Sounds like everything is working, other than you are getting a PHP warning.

12 Dec 2022, 10:22 PM
#17
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

thank u both.

I added the carlwhat code and I'll keep an eye on the php warnings.

hope ur right chuckphillips. I feel like I have a one-way relationship with taxjar right now.

Don't know how long it takes for transaction data to populate on their end.

I can already see that getting an email response from them is going a test of patience.

12 Dec 2022, 10:32 PM
#18
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

carlwhat, got a ?

what is the purpose of the first of these lines? I don't understand.

    $this->sort_order = MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER;
    $this->sort_order = defined('MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER') ? MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER : null;
13 Dec 2022, 12:06 AM
#19
carlwhat avatar

carlwhat

zennedOut

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

Re: TaxJar Issue - Composer Related?

fravac:

carlwhat, got a ?

what is the purpose of the first of these lines? I don't understand.

    $this->sort_order = MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER;
    $this->sort_order = defined('MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER') ? MODULE_ORDER_TOTAL_TAXJAR_SORT_ORDER : null;

the first line should be removed (as you did in post #10 above).

my mistake.

best.

13 Dec 2022, 12:33 AM
#20
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: TaxJar Issue - Composer Related?

thx carlwhat

so far so good

had a few transactions go thru without any php warnings since code change