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?
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/" }
}
}
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
Code:
composer require taxjar/taxjar-php
Taxjar's instructions for the above are here:
https://developers.taxjar.com/api/gu...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:
Code:
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
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??
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?
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.
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
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
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.
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.