TeaCommerce Cart edit doesn't work after adding customer details
Hi,
My client has noticed what looks like a bug, which seems to be the same with the starter kit demo site. If you add a product to cart, view cart, and check out all the way to cart step 4 (accept) but then go back to the cart, there's a javascript error when you try to change the quantity of the item in the cart.
Sure. There are console errors. When I go back to the cart on the starter kit website and click the plus button to increase the quantity of the item I get:
POST http://starterkit.teacommerce.net/base/TC/FormPost.aspx 500 (Internal Server Error) jquery.min.js:3 send jquery.min.js:3 st.extend.ajax jquery.min.js:3 $.fn.ajaxSubmit jquery.form.js:208 (anonymous function) st.event.dispatch jquery.min.js:2 y.handle jquery.min.js:2
In my own implementation oddly the error is different:
Uncaught TypeError: Cannot read property 'quantity' of null ecommerce.js:39 (anonymous function) ecommerce.js:39 TCService.fireEvent TCService.fireAfterEvent TCService.success settings.success options.success jquery.form.js:170 c jquery-1.9.1.min.js:3 p.fireWith jquery-1.9.1.min.js:3 k jquery-1.9.1.min.js:5 r jquery-1.9.1.min.js:5
The line it's referring to is if (orderLine.quantity <= 0) { in the function below:
TC.bind('afterAddOrUpdateOrderLine', function (orderLine, data, jQForm) {
var updatingElement = jQForm.closest('.updating');
if (updatingElement.hasClass('item')) {
if (orderLine.quantity <= 0) {
var deleteElement = jQuery('#orderLine' + orderLine.id);
deleteElement.remove();
} else {
updateCartOrderLine(orderLine);
}
updateCart(data.order);
}
});
If its any help we also noticed the same problem when a transaction fails and goes to the failed URL, and then the customer tries to buy again by going through the cart process.
Yes, That would create the same issue. It's related to a safty mechanic that kicks in when the user is about to pay for the order. Happens when the payment form is generated.
Also note that I have added a few chars of code to the starter kit setup to make use of the fix in the UI as well. More specificly we have introduced a new property on orderlines called copiedFromOrderLineId, which can be used to update the UI.
I'm struggling to get the UI to update when applying this fix.
I've updated to 3.1.1, copied the ecommerce.js from the updated starter kit, but when a product is added or updated in the cart after returning to the cart from beyond customer information (as described in previous posts), the cart UI hangs as "adding to cart". The order line has successfully been updated since when I refresh the page the correct quantity/price is shown. There is no error in the console either.
This works fine before going past the customer information stages.
Hi Rune, it seems so, it doesn't look like the afterCartUpdated event is firing at all (only when I go past the customer information it does not fire).
I've sent an email to you with a link, a second opinion would be much appreciated! :)
I found the problem. Aparently the json returned from Tea Commerce is not valid because of the "comments" property on the order. More specifically it's because of some tabs that are automatically insertet. I guess you have some line breaks in your razor file. Try making the textarea as a one liner. That should do the trick.
TeaCommerce Cart edit doesn't work after adding customer details
Hi,
My client has noticed what looks like a bug, which seems to be the same with the starter kit demo site. If you add a product to cart, view cart, and check out all the way to cart step 4 (accept) but then go back to the cart, there's a javascript error when you try to change the quantity of the item in the cart.
Any ideas how to patch this?
Thanks
Hi Dan,
How do you go back to the cart? Using the back button in the browser?
/Rune
By clicking the cart step at the top. Or in my implementation I have a button under the cart summary which is just a hyperlink to the 1st cart step.
Could you please check the browser console to see if there's and error?
/Rune
Can also confirm this bug - going back to the cart at step 4 causes it to hang at "updating". There is no error in JS console.
I am still running 2.0 though, I understand in 2.1 the orderline process was changed.
Sure. There are console errors. When I go back to the cart on the starter kit website and click the plus button to increase the quantity of the item I get:
In my own implementation oddly the error is different:
The line it's referring to is if (orderLine.quantity <= 0) { in the function below:
I'm running 2.0.
Hi Matt and Dan,
I can confirm the problem and it is something we can fix in the Tea Commerce engine.
We will make a fix asap and get back to you guys.
Thanks for your effort. It's much appreciated.
/Rune
Cool, thanks Rune.
Thanks Rune,
If its any help we also noticed the same problem when a transaction fails and goes to the failed URL, and then the customer tries to buy again by going through the cart process.
Hi Matt,
Yes, That would create the same issue. It's related to a safty mechanic that kicks in when the user is about to pay for the order. Happens when the payment form is generated.
/Rune
Hi guys,
We have fixed the bug and released a new version of Tea Commerce. Remember to check the revision history for breaking changes:
http://documentation.teacommerce.net/revision-history/
Also note that I have added a few chars of code to the starter kit setup to make use of the fix in the UI as well. More specificly we have introduced a new property on orderlines called copiedFromOrderLineId, which can be used to update the UI.
/Rune
I'm struggling to get the UI to update when applying this fix.
I've updated to 3.1.1, copied the ecommerce.js from the updated starter kit, but when a product is added or updated in the cart after returning to the cart from beyond customer information (as described in previous posts), the cart UI hangs as "adding to cart". The order line has successfully been updated since when I refresh the page the correct quantity/price is shown. There is no error in the console either.
This works fine before going past the customer information stages.
Any ideas?
Hi Matt,
Something must be wrong! :)
Sounds like something goes wrong in the afterCartUpdated event. Have you tried debugging the JavaScript to see what happens in that event?
Do you have anywhere where we can see your site not working?
/Rune
Hi Rune, it seems so, it doesn't look like the afterCartUpdated event is firing at all (only when I go past the customer information it does not fire).
I've sent an email to you with a link, a second opinion would be much appreciated! :)
Hi Matt,
I found the problem. Aparently the json returned from Tea Commerce is not valid because of the "comments" property on the order. More specifically it's because of some tabs that are automatically insertet. I guess you have some line breaks in your razor file. Try making the textarea as a one liner. That should do the trick.
/Rune
Ahh, that was it! Thank you! :) I copied it from the Starter Kit template so maybe some line breaks got added somewhere.
Your visual studio will add them automatically and if you have it set up for tabs instead of spaces it will f**k it up :)
/Rune
is working on a reply...