News:

Support the VirtueMart project and become a member

Main Menu

Cart is allways empty - Joomla 1.5.26 - VM 2.0.14

Started by razor7, December 01, 2012, 01:22:49 AM

Previous topic - Next topic

razor7

Hi, Just installed VM 2.0.14 on a working site because my client need a shopping cart for his site.

VM works just ok, but when adding a prodct to the cart, the JS popup appears without the link to go to checkuot and the cart module says that the cart is empty. I didn't touched anything, just installed VM, installed samle data and created the menu links.

Is anyone having the same issue?

The site is  Joomla 1.5.26 - VM 2.0.14.

Tanks a lot!

[attachment cleanup by admin]
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

bytelord

Hello,

Using old joomla but never mind :)

Did you try without template overrides? Do you use any third party cart module? Do you Cache enabled?

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

razor7

#2
Cache disabled, no overrides at all (just installed VM), no 3rd party cart module, just mod_virtuemart_cart, as seen on attachment...

EDIT: Using rhuk_milkyway template behaves the same
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

bytelord

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

razor7

MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

bytelord

Hello,

Typical js conflict i suppose, also the cart is not working, there are no products there...

First you are running jquery twice, then you are using https (SSL) without a valid SSL this can produce issues. First please remove ssl option and then unload a jquery instance from loading. You could unload vm jquery and load 1.7.x version instead of 1.8.x from where you running (i suppose k2).

<script src="/gicspa/plugins/system/mtupgrade/mootools.js" type="text/javascript">
<script src="https://.....templates/gicspa2011/js/domready_fix.js" type="text/javascript">
<script src="/gicspa/media/system/js/modal.js" type="text/javascript">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js" type="text/javascript">
<script src="/gicspa/media/k2/assets/js/k2.noconflict.js" type="text/javascript">
<script src="/gicspa/components/com_k2/js/k2.js" type="text/javascript">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript">
<script src="/gicspa/components/com_virtuemart/assets/js/jquery.noConflict.js" type="text/javascript">
<script src="/gicspa/components/com_virtuemart/assets/js/vmsite.js" type="text/javascript">
<script src="/gicspa/components/com_virtuemart/assets/js/facebox.js" type="text/javascript">
<script src="/gicspa/components/com_virtuemart/assets/js/vmprices.js" type="text/javascript">
<script src="/gicspa/plugins/system/jcemediabox/js/jcemediabox.js?version=114" type="text/javascript">
<script src="https://.,,.,.,..ar/gicspa/templates/gicspa2011/js/gk.script.js" type="text/javascript">
<script src="https://,.,,.,.,..com.,.,./gicspa/modules/mod_news_pro_gk4/interface/scripts/engine-mootools-11.js" type="text/javascript">

Use firebug to examine your site code and styling .. also for checking js conflicts ...
http://forum.virtuemart.net/index.php?topic=102850.0

Javascript conflicts:
http://dev.virtuemart.net/projects/virtuemart/wiki/General_JS-Problems_with_templates_and_jQuery
http://dev.virtuemart.net/projects/virtuemart/wiki/JavascriptCSS_Template_Overrides_and_Avoiding_Conflicts_between_Libraries

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

razor7

Hi, the jQuery load issue was solved, but I really dont think it is a JS issue, because the popup displays very well, the issue is with the cart. Just sent you a new PM with a link to test. I have changed the template to rhuk_milkyway to avoid any issues with the original template of the site but the problem persists.

So to be short, I can't add products to cart even using a native template with a fresh VM 2.0.14 install.
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

razor7

Well, I think I found the bug in VM 2.0.14. The issue is that JS function cartEffect : function(form) in vmprices.js, serializes the data to request TWICE!, so, in the other end, the variables get this way quantity%5B%5D=1&option=com_virtuemart&view=cart&virtuemart_product_id%5B%5D=6   (this can be viewed clearly using Eclipse PDT and xDebug), so the whole code fails, because the variables are a complete mess.

I had to change the code from this

var datas = form.serialize();
$.getJSON(vmSiteurl+'index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json'+vmLang,encodeURIComponent(datas),


To this (no double encode)
var datas = form.serialize();
$.getJSON(vmSiteurl+'index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS&format=json'+vmLang,datas,


Also found that VM determines which message to show in the popup BEFORE the decission has to be made!, so changed the code in controllers/cart.php, function addJS, and added a new language string to show the correct error.

$errorMsg = '';
if ($cart->add($virtuemart_product_ids, $errorMsg )) {
        $errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart") . '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL') . '</a>';
if ($errorMsg) $this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '1';
} else {
        $errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_NOT_ADDED');
//$this->json->msg = '<p>' . $cart->getError() . '</p>';
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<div>'.$errorMsg.'</div>';
$this->json->stat = '2';
}


New lang string
Quote
COM_VIRTUEMART_CART_PRODUCT_NOT_ADDED="Something went wrong when adding the product to the cart. Please notify the webmaster."
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

bytelord

Hello,

I cannot agree with the first one using encodeURIComponent is the only way to work with Unicode UTF-8 urls,  if you remove it then may not properly decode how escape encodes upper ASCII or non-ASCII characters such as: รขầẩềểễếệ, so you url will not work! May be adding an option if Unicode Aliases on Joomla Configuration is enabled then make use of encodeURIComponent. The variables are not mess is how are converted, also encodeURIComponent allows spaces.

encodeURIComponent used twice in vmprices.js, also when i am using it ... fix my urls to the variables are NOT getting this way quantity%5B%5D=1&option=com_virtuemart&view=cart&virtuemart_product_id%5B%5D=6

Some more: http://www.w3.org/TR/html401/interact/forms.html#form-content-type

I am thinking you still have JS conflicts with jquery libraries.

On the second haven't check it yet :)

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

razor7

Well, in my case, the variables get too messy. I can't see any enctype in the product forms. MAybe is my server fault, but I don't know why.

Thanks a lot anyway!
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

Simsan

Quote from: bytelord on December 01, 2012, 01:25:15 AM
Hello,

Using old joomla but never mind :)

Did you try without template overrides? Do you use any third party cart module? Do you Cache enabled?

Regards

Thank You Dud. Today I got same problem on my clients site. I just fix it by your question. :) He was using third party cart module but it's come my mind after read your question. Thank You  :)