MarketPress add to cart not working

I've moved a site from http to https and then MarketPress add to cart feature stopped working. Adding a product to the cart gets stuck at the animation.

Browser console show this error: Mixed Content:
The page at 'https://mydomain.com/store/products/category/audio/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://mydomain.com/wp-admin/admin-ajax.php?action=mp_update_cart'. This request has been blocked; the content must be served over HTTPS.

Did a search and replace from the database, but it didn't fix it.

  • Adam Czajczyk
    • Support Gorilla

    Hi Sandor,

    I hope you're find today!

    I checked the site and first thing that I noticed was that the "sma....com/yo...sis" sub-site, while re-directed to https was not actually configured for SSL. A requirement for a proper configuration for SSL is to make sure that both "Siteurl" and "Home" opitions are set to use valid URL with "https://" prefix.

    On your setup they were still set to use "http://" prefix. I took a liberty of tweaking that as this could could additional issues in future.

    As for the main issue in question. There's is an glitch in a plugin causing that issue if used with mapped domain. Our developers are already aware of this and are working on bringing the fix to the plugin.

    Meanwhile, there's a workaround that should solve that but it requires changing plugin files. I have applied it to your site and it seems it did the trick. The change I made was in a "/wp-content/plugins/marketpress/includes/common/template-functions.php" file inside a "'mp_get_ajax_url()" function, as described in point 2 of this post:

    https://premium.wpmudev.org/forums/topic/add-to-cart-is-showing-mixed-content-error-on-mapped-site#post-1304929

    Please check the site and confirm if that's fine now. In case it turned out that it broke some other part of the MarketPress on your setup, you can restore original file by accessing the site via FTP, removing the "template-functions.php" file from the location mentioned above and renaming "template-functions.phpORG" (that I left there - original file) to "template-functions.php".

    Best regards,
    Adam

  • Adam Czajczyk
    • Support Gorilla

    Hey @Sandor!

    "First settings" as in "changing from http:// to https://", right? Sorry, I should explain that better :slight_smile:

    Go to the "Network Admin -> Sites -> All sites" as a super-admin, find a sub-site that you wish to fix on a list and click "Edit", then switch to "Settings" tab and "Siteurl" and "Home" are the first two options there. Just tweak the "http://" to "https://" part there, scroll the page all the way down and save.

    Like I said, I have already set that properly for the sub-site in question but you might want to do that for others/for new sub-sites in future.

    Best regards,
    Adam

  • Adam Czajczyk
    • Support Gorilla

    Hi Sandor!

    This brings up the questions;
    If the domain mapping screen is not enough to admin the domain -

    Fair question :slight_smile: But it's actually not about domain mapping at all. This is the same for any sub-site of your site regardless whether it's got a domain mapped to it or not. The SSL certification is a server side thing and WordPress configuration is, well, WordPress configuration, so to speak :slight_smile: I mean - it's a matter of a right configuration of the site. Domain Mapping would direct traffic to https:// URL anyway if that protocol is chosen but it's WP "task" to handle it properly and if it's not set to do it, it might cause issues :slight_smile:

    That being said, actually sites that you create on your Multisite should follow main site's settings if it comes to the protocol. But if SSL was implemented while some sub-sites already existed, those sub-sites need such a manual tweak.

    Best regards,
    Adam

  • Sandor
    • WordPress Warrior

    Hmm,

    The main site was created with http and I see no way to change that via the admin area. Is that something that needs to be changed manually in the db - is there a reason it's not changeable (like it will destroy the world if changed)?

    Thanks,
    -Sandor

  • Adam Czajczyk
    • Support Gorilla

    Hi @Sandor!

    The change for main site is a bit more tricky. There's a couple of ways but I think this is quite an easy and reasonable guide here:

    https://wpengine.com/support/how-to-change-a-multi-site-primary-domain/

    It refers to changing entire domain but it's pretty much the same, you only change "protocol prefix" part where it is used.

    As for sub-sites it can be edited via back-end, you can also skip the "wp_#_options" table part from that guide.

    However, sometimes that might not be enough as some plugins may store the full URL in other places of the database and those URLs might also need to be updated. You could use a plugin like "Better Search Replace" for that:

    https://wordpress.org/plugins/better-search-replace/

    or this standalone script:

    https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

    The script has an advantage of a "dry run" feature that only simulates changes, that you can run before "Live run" to actually check and review the changes to make sure that's fine.

    Of course, as always in case of such actions, I strongly recommend taking a database backup before!

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.