Jump to content

[SOLVED] Cart contents disappear when switching to SSL subdomain, Prestashop 1.5


Recommended Posts

Shopping cart contents all disappear whenever a user clicks on "Log in" or "Checkout". I realize that this is because the contents of the cart cookie are not being made available across the two subdomains (in this case "www" and "secure"). In Prestashp 1.4 there was an option in the tools to add a subdomain that took care of this issue. In Prestashop 1.5 I don't see those options.

 

Has anyone been able to figure this out? Does it require the multistore functionality to be enabled?

Edited by elameno (see edit history)
  • Like 1
Link to comment
Share on other sites

Well digging into the code I found this "fix". I don't know the Prestashop core all that well so it may be inadvisable to add this, but this seemed to fix my problem of my shopping cart contents disappearing when the user clicked a link that switched them over to the SSL subdomain. Keep in mind that I'm looking at the Prestashop 1.5.1 code.

 

In the config/config.inc.phe file at line 123 you will see code that looks like this:

 

if (Context::getContext()->shop->getGroup()->share_order)
 $cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookieLifetime, Context::getContext()->shop->getUrlsSharedCart());
else
 $cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime);

 

I inserted an "else if" statement in there which looks to see if the ssl domain and the main store domain are not the same. If not then it passes the two domains into the Cookie constructor as the final parameter. Here's the code after the hack fix (including the other two branches of the if/then/else.

 

if (Context::getContext()->shop->getGroup()->share_order)
 $cookie = new Cookie('ps-sg'.Context::getContext()->shop->getGroup()->id, '', $cookieLifetime, Context::getContext()->shop->getUrlsSharedCart());
else if(Context::getContext()->shop->domain != Context::getContext()->shop->domain_ssl)
 $cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime, array(Context::getContext()->shop->domain, Context::getContext()->shop->domain_ssl));
else
 $cookie = new Cookie('ps-s'.Context::getContext()->shop->id, '', $cookieLifetime);

 

Seems to solve my problems. Though I know not whether it will create any others.

  • Like 2
Link to comment
Share on other sites

I got error warning like this :

 

Error occurred:

 

Please refer to logs:

  1. PayPal response:
  2. TIMESTAMP -> 2012-10-18T09:21:08Z
  3. L_ERRORCODE0 -> 10605
  4. L_SHORTMESSAGE0 -> Transaction refused because of an invalid argument. See additional error messages for details.
  5. L_LONGMESSAGE0 -> Currency is not supported
  6. L_SEVERITYCODE0 -> Error

so i can not check out with this module!!

Anybody know what should i do? please

 

I disable EN language and change the default with ID language!!!

 

thank you!

Edited by jesen (see edit history)
Link to comment
Share on other sites

The "fix" I put in place for 1.5.1 may be considered hackish, so I'd love for the development team to take a look and see if there's a better way to permanently fix the problem. I haven't verified that the problem still exists in 1.5.2 so I can't comment there. mmony?

 

In 1.4 there was a page in the back office to add subdomains so the cookies would persist across the subdomains added. That page is gone now and it'd be fantastic to have access to it again, or be given another way to accomplish the same thing.

Link to comment
Share on other sites

  • 2 weeks later...

I haven't upgraded to 1.5.2.0 yet so I couldn't tell you about that release. I have my hack fix that makes this work in 1.5.1.0 but at some point I'd like to upgrade. I'm waiting to hear of some progress on these critical features I need before I do.

 

My 1.5.1.0 install was a fresh install and the issue happens when the "Shop Domain" and "SSL domain" names use different subdomains. In my case I'm using:

Shop Domain = www.domainhere.com

SSL Domain = secure.domainhere.com

Link to comment
Share on other sites

  • 4 weeks later...
  • 9 months later...

Hi Benjamin,

 

I had just posted it to the forge. Here is the ticket number:

PSCFV-5260

 

I'm launching tomorrow (or least I was suppose to) so it's really critical I can get a work-around for this.

 

Thanks

After review of this post I wanted to follow up that this forge report was closed as 'Fixed'.

 

http://forge.prestashop.com/browse/PSCFV-5260

 

I was looking into this as a customer has a 1.5.4.1 shop running as a subdomain, then switching to another subdomain and oddity of order status on return from PayPal order history.  This may differ to OP in that they ssl goes from cTLD to subdomain.

Link to comment
Share on other sites

×
×
  • Create New...