News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Cart Module not updating

Started by sscheidegger, May 16, 2014, 15:21:30 PM

Previous topic - Next topic

sscheidegger

Hi all

After updating to VM 2.6.1 and J 2.5.20 I have a problem with my cart module. The js/ajax updating the cart module when someone adds a product seems to be broken. I already removed all overrides and disabled some other components in joomla.

So far I tracked the problem down to vmprices.js in the productUpdate function. The function gets called, but the callback function in getJSON is never called...

Does anyone else have the same problem? Any idea what could be the reason?

Thanks!

GJC Web Design

on a clean upgrade to 2.6.x can confirm std. vm cart module works fine

live url?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

sscheidegger

Ok, I just set up a test environment with a clean install of J 2.5.20 and VM 2.6.1. The problem exists also there: When I click on "Add to Cart", the module is not updated. Only after a refresh or going to a different page, the cart module shows the newly added product.

Detailed steps to reproduce the problem:
- Set-up VM 2.6.1, do the basic configurations and add some products
- Activate the VM - Shopping Cart module
- Go the product details page and click on "Add to Cart"
  --> A pop-up message is displayed saying "1 x Product xy was added to your cart. The product quantity has been updated." At the same time, the shopping cart should show "1 x Product xy  10,00 Euro, Total: 10,00 Euro" or similar. But in VM 2.6.1 it still says "Cart empty"
- Don't click on "Continue Shopping" or "Show Cart", but click the little cross to close the pop-up message.
  --> Now you're back on the page and it seems that the cart is still empty.
- Refresh the page
  --> Now the cart module is updated

This bug might seem not very important, but we have a shop where we don't show the pop-up message. The expected behavior is, that whenever a customer clicks on "Add to Cart", the cart module updates (without a page refresh). With this not working, the customer is very confused, probably clicks several times on "Add to Cart" and nothing happens and as soon as he navigates to a different page, he has many products in his cart!

gripped

Same here and on 2.6.2 as well.

I mentioned in another thread I have overridden padded.php so that 'continue shopping' stays on the same page and does not reload.
On 2.6.0a you can see the cart module update at the same time as the modal appears, before clicking 'continue shopping'.

On 2.6.2 with my override in place the cart does not update at all until the page is reloaded manually or a different page is loaded.

With my override removed the cart does not update at the same time as the modal appears, as it did before. Only after  'continue shopping' is clicked and the page automatically reloads.

gripped

#4
OK

The only thing  I've discovered about this so far is that in 2.6.2 I get this in the chromium console when add to cart is clicked

GET http://test.ecigsoutlet.co.uk/index.php?option=com_virtuemart&nosef=1&view=cart&task=viewJS&format=json&_=1400667587576 500 (Internal Server Error) jquery.min.js:2
send jquery.min.js:2
p.extend.ajax jquery.min.js:2
p.(anonymous function) jquery.min.js:2
p.extend.getJSON jquery.min.js:2
Virtuemart.productUpdate vmprices.js:29
(anonymous function) vmprices.js:96
k jquery.min.js:2
l.fireWith jquery.min.js:2
y jquery.min.js:2
d jquery.min.js:2


Doesn't happen in 2.6.0a

gripped

same '500 (Internal Server Error)' on a fresh install (2.5.20, 2.6.2) with sample data when add to cart is clicked

gripped

#6
seems to be because $lang is not defined anymore

used to be at components/com_virtuemart/controllers/cart.php line 168

$lang = JFactory::getLanguage();


Used a few lines after
$this->data->billTotal = $lang->_('COM_VIRTUEMART_CART_TOTAL') . ' : <strong>' . $this->data->billTotal . '</strong>';

Putting the line back fixes the cart ajax but I doubt it's the correct solution.

sscheidegger

Adding the line to cart.php works as a temporary workaround. Now I can run the website again without the modal. Thanks a lot for analyzing this!

Could someone from the dev team fix this for the next version?

Milbo

Just replace the $lang-> by vmText:: that should be the correct fix
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

#9
Hmm something changed that broke it!

I will test Milbos suggestion

I did not want the users to have to click any link in the modal popup to continue shopping  as this "continue shopping" ends up reloading the page and hence a wasted server hit.

So I change vmprice.js to make the modal popup timeout and removed the contimue link from padded.php (old school!)

Hence I never have users clicking "continue"




Regards
A

Joomla 3.10.11
php 8.0

AH

Milbo's fix tested and working  ;)
components\com_virtuemart\controllers\cart.php

Line 186

$this->data->billTotal = vmText::_('COM_VIRTUEMART_CART_TOTAL') . ' : <strong>' . $this->data->billTotal . '</strong>';

Cart updates as expected

I thank you Milbo on behalf of many!
Regards
A

Joomla 3.10.11
php 8.0

borro

Quote from: gripped on May 21, 2014, 13:13:42 PM
seems to be because $lang is not defined anymore
Thank you very much. Please tell how did you understand that? I want to learn from you to be able to solve similar problems in future
Wish you happiness!

borro

Quote from: Hutson on May 21, 2014, 16:10:50 PM
Line 186
$this->data->billTotal = vmText::_('COM_VIRTUEMART_CART_TOTAL') . ' : <strong>' . $this->data->billTotal . '</strong>';
Cart updates as expected
here is a litle problem. If your shop uses English language everything works fine. But if you are using another default language the correct COM_VIRTUEMART_CART_TOTAL value is being taken only at page reload. And if you fills your cart then every ajax update is using english value of 'COM_VIRTUEMART_CART_TOTAL' constant. How to fix this issue?
Wish you happiness!

gripped

Quote from: borro on May 29, 2014, 15:14:25 PM
Quote from: gripped on May 21, 2014, 13:13:42 PM
seems to be because $lang is not defined anymore
Thank you very much. Please tell how did you understand that? I want to learn from you to be able to solve similar problems in future
By using the chromium console, looking at the server error.log and once I'd seen the error comparing the code prior to the update and after.
I can't code but experience means I can sometimes spot the odd bug or 'hack' code a bit.
The only advice I can give is study the code and the logs and try to figure it out. Sometimes I can. Most often I can't.

borro

Quote from: gripped on May 30, 2014, 19:56:32 PM
By using the chromium console, looking at the server error.log and once I'd seen the error comparing the code prior to the update and after.
I can't code but experience means I can sometimes spot the odd bug or 'hack' code a bit.
The only advice I can give is study the code and the logs and try to figure it out. Sometimes I can. Most often I can't.
Thank you. Were you watching an html code in chromium or some php code? Where the error.log usually can be found?
Wish you happiness!