Taxcloud and Duplicate Orders
Zen Cart: 1.5.5f
PHP: 7.1.29
Payment Modules : Paypal Express & Heartland
I installed the TaxCloud code and I've been having an intermittent issue with duplicate orders.
The issue has occurred with both payment modules and for states that collect sales tax and states that don't.
No PHP errors.
I'm not able to recreate a double order myself.
It appears as though the users arrive at the checkout confirmation and start circling back to the site.
I disable the paypal express button because I noticed those users tend to leave the confirm page from time to time to edit their shipping information.
Since I have done that I'm not seeing any duplicates with paypal but that could just be based on user behavior going forward I guess.
Also, the orders can be as far apart as a couple minutes in time (time stamp). They aren't 4 to 5 seconds apart.
I noticed while the customer is getting charged for both orders, zen cart is not posting the data back from the payment processor (authorization code, etc)
I don't have any redirect plugins and the cart was trouble free before the taxcloud installation.
Over 90% of the time, it works great.
I'm a hack at best when it comes to code.
Is there something I should be looking at specifically.
Re: Taxcloud and Duplicate Orders
Have you had any luck tracking down the source cause of the duplicates (redundant) Lookups?
Let us know if we (TaxCloud) can help.
-David
Re: Taxcloud and Duplicate Orders
I have not had any luck.
I did just observe a customer that was logged in with 2 different Session IDs.
One Session ID had one item in the cart.
The second Session ID had 2 items (one of the items was the same as in the first Session ID)
I observed all of this on the Who's Online page in real time by chance.
It looks like they are getting to the checkout confirmation page (where paypal drops you back off or where the credit card information is entered (heartland plugin).
Then they circle back through the site and that create some kind of loop and they end up with another Session ID. Another Session ID meaning a second instance of the same customer with a different Session ID.
This one particular customer circled back to add an item.
I can't recreate this but the pattern is that any duplicate orders have all landed on the Checkout Confirmation and then started shopping again or they go into their address information.
The customer I observed never checked out so I don't have 2 invoices but I believe what I observed would have resulted in at least 2 submitted orders. They bailed out of the cart for whatever reason, but not during the checkout process.
Re: Taxcloud and Duplicate Orders
I think I finally figured out what is causing my issue (duplicates and unfinished orders that are still charged).
My problem is caused by customers who enters a 9 digit zip code.
includes/modules/TaxCloud/func.taxcloud.php
Line 91
function func_taxcloud_get_customer_address($delivery) {
// Customer's address
$destination = new Address();
$destination->setAddress1($delivery['street_address']);
$destination->setAddress2('');
$destination->setCity($delivery['city']);
//$destination->setState($delivery['state']); // Two character state appreviation
$destination->setState($delivery['state_code']); // Two character state appreviation
$destination->setZip5($delivery['postcode']);
$destination->setZip4('');
return $destination;
I just had a customer who had a few failed attempts, then changed his Shipping Postal Code, and the sale the went through.
This array works fine is there is a five digit zip.
I don't see any code that checks the length of postcode or manipulates the postcode in any way to prepare it for formatting.
I just took a look at the latest version of the TaxCloud plugin and the code is the same.
Am I missing something, or am I making sense?
Re: Taxcloud and Duplicate Orders
I was a little vague.
The customer was initially trying to make a purchase with a 9 digit zip code. After some failed attempts he changed his shipping address to a 5 digit zip code.
Sorry.
Re: Taxcloud and Duplicate Orders
I just made this change and tested it:
function func_taxcloud_get_customer_address($delivery) {
// Customer's address
$destination = new Address();
$destination->setAddress1($delivery['street_address']);
$destination->setAddress2('');
$destination->setCity($delivery['city']);
//$destination->setState($delivery['state']); // Two character state appreviation
$destination->setState($delivery['state_code']); // Two character state appreviation
//$destination->setZip5($delivery['postcode']);
$destination->setZip5($trunczip = substr($delivery['postcode'], 0, 5));
$destination->setZip4('');
return $destination;
I don't really know much about php (or posting on a forum) but this appears to be working.
I think this is an ugly hack because I'm not seeing an other examples of string manipulation being done inside of any array.
Re: Taxcloud and Duplicate Orders
sorry for all the post
the code change I made with the substring failed further testing.
I just didn't want anyone to think it worked.
Re: Taxcloud and Duplicate Orders
Sorry to keep bumping my own thread, but I think I found a solution.
I'm using Zec 1.5.5f.
I think this code works for that and the 1.56c version.
I think I have fixed the problem I was having with customers who were using 9 digit zip codes.
includes/modules/TaxCloud/func.taxcloud.php
Line 91
function func_taxcloud_get_customer_address($delivery) {
// Customer's address
$destination = new Address();
$destination->setAddress1($delivery['street_address']);
$destination->setAddress2('');
$destination->setCity($delivery['city']);
//$destination->setState($delivery['state']); // Two character state appreviation
$destination->setState($delivery['state_code']); // Two character state appreviation
$destination->setZip5($delivery['postcode']);
$destination->setZip4('');
return $destination;
}
I added some code to handle a zip code longer than 5 digits and pass it back to the taxcloud api correctly
function func_taxcloud_get_customer_address($delivery) {
// Customer's address
$destination = new Address();
$destination->setAddress1($delivery['street_address']);
$destination->setAddress2('');
$destination->setCity($delivery['city']);
//$destination->setState($delivery['state']); // Two character state appreviation
$destination->setState($delivery['state_code']); // Two character state appreviation
$fullzipcode = trim($delivery['postcode']);
if (strlen($fullzipcode) > 8){
$fivedigitzip = substr($fullzipcode,0,5);
$fourdigitzip = substr($fullzipcode,-4);
$destination->setZip5($fivedigitzip);
$destination->setZip4($fourdigitzip);
} else {
$destination->setZip5($delivery['postcode']);
$destination->setZip4('');
}
return $destination;
}
I test for > 8 because I will get a customers who omits the hypen when using a 9 digit zip.