VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: harrstar on October 01, 2013, 03:39:21 AM

Title: Bug fix for fancybox add to cart button in https page
Post by: harrstar on October 01, 2013, 03:39:21 AM
Hi,

I am using vm 2.0.22a on joomla 2.5.14.

The fancybox for the add to cart function from product detail view was not working on secure (https) pages, the popup was not showing. All browsers complained about cross referencing from https://... to http://... for the fancybox call. After some digging I found the culprit in /administrator/components/com_virtuemart/helpers/config.php on line 1136 :

      $jsVars .= "vmSiteurl = '". JURI::root( ) ."' ;\n" ;

needs to be changed into

      $jsVars .= "vmSiteurl = '". JURI::root(true ) ."/' ;\n" ;

The first line returns the absolute url to the site like :

                http://www.example.com/

whereas the second line returns

                /

which makes it a relative path from root.

It needs to be either a relative path or the absolute url should switch from http:// to https:// which it currently does not.

This little fix solved the problem and the add to cart popup is now working on https and http.

Uwe

               
Title: Re: Bug fix for fancybox add to cart button in https page
Post by: Milbo on October 01, 2013, 10:03:58 AM
Your fix generated for me as expected

vmSiteurl = 'http://vm2mp.stuprecht//' ;


ah lol overlooked the true in your statement. This is right, it gives back only the path. The question is how your patch works with subdomains.

But I think the real solution is to change the instance JURI to give  back an https link.
Title: Re: Bug fix for fancybox add to cart button in https page
Post by: Milbo on October 01, 2013, 10:26:16 AM
I added now this

if(VmConfig::get('useSSL',false)){
$jsVars .= "vmSiteurl = '". $uri->root( true ) ."/' ;\n" ;
} else {
$jsVars .= "vmSiteurl = '". $uri->root( ) ."' ;\n" ;
}

Title: Re: Bug fix for fancybox add to cart button in https page
Post by: harrstar on October 01, 2013, 14:24:19 PM
Hi Milbo,

Yes, I concur, the joomla function is what really needs to be changed. I like your fix for it though.

On a side note, why is vm not switching back to http if outside the sensitive area?

Uwe