Search code examples
.htaccesssslcartprestashop-1.6

How to change http to https in Prestashop 1.6 add cart


I enabled SSL on my Prestashop 1.6:

Preferences > General > Enable SSL
Preferences > General > Enable SSL on all pages

In .htaccess I used a following code:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

before

# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again

Everything looks fine but in view page source of website still I see:

<a class="button ajax_add_to_cart_button btn btn-default" href="http://www.myeshop.com/cart?add=1&amp;id_product=9&amp;token=2db68311c3192a52b4eca5bc1b2c218f" rel="nofollow" title="Add to cart" data-id-product="9"> <span>Add to cart</span> </a>

A href link in Add to cart button directs to http instead https. Can you help me please? Regards Jan


Solution

  • You should look at the smarty template concerned and seeing if classes or controllers are not overridden.

    at least you can correct it, with Javascript with something like :

    $(document).ready(function()
    {
    
       $('.ajax_add_to_cart_button').each(function() {
                    var href = $(this).attr('href');
                    href = href.replace('http:', 'https:');
                    $(this).attr('href', href);
            });
    
     });    
    

    But it's only for test mode not in production due to security !!! please read this thread : Change all occurrences of "http" to "https" on a wordpress page