• When comparing the src URLs of the product images located in the cart from the previous version of WooCommerce to the new 3.0updated version, we noticed the urls prefixes are stripped. Although not a problem when on the site, but when the data is exported into a quotelist in an email, the urls links are broken. Here is the comparison of the link structure of a product:

    WooCommerce 3.0
    <img width="180" height="270" src="//qualitinc.com/wp-content/uploads/2017/03/CS402P_Red_model_front-180x270.jpg" alt="" />

    WooCommerce 2.6.14
    <img width="180" height="270" src="https://www.qualitinc.com/test2/wp-content/uploads/2017/03/AA2833_ashhthr_model_front_022016-180x270.jpg" alt="" />

    What file can I Edit to have the full URL string listed in the cart?

    • This topic was modified 7 years, 10 months ago by burtcav.
Viewing 5 replies - 1 through 5 (of 5 total)
  • If your site is locked down with an https redirect on the hosting environment the wc 3 urls will work with https… Having url’s as // instead of https:// or https:// pretty much makes them compatible either way, if your server has an ssl redirect to enforce https then it wouldn’t be a problem regardless where the links were accessed from as the destination page would always use https, if you don’t have ssl set up with a redirect and just changed your Settings>General>Address entries to https it wouldn’t be enough to load pages as https, if you have the redirect and it’s not set in Settings>General/Address then I could see that possibly making things weird… How is your ssl set up on your server/website?

    Thread Starter burtcav

    (@burtcav)

    It is not a problem when it is on the site and in the cart. The problem is when the cart data is used in an email as the order details. We use a quotelist plugin and it is taking the information from the cart. When the email is received the product images do not show, because the pre-fix is missing. The url of the product in the email shows us what color the product is.

    Here is what the email data looks like with broken image URLS:
    <table cellspacing="1" cellpadding="1" style=""> <thead> <tr style=""> <td>&nbsp;</td> <td>Product</td> <td>SKU</td> <td>Quantity</td> </tr> </thead> <tbody> <tr style=""> <td style=""><a href="https://qualitinc.com/product/alternative-athletics-eco-fleece-pullover-hoodie-aa9596/?attribute_color=Camo"><img width="180" height="270" src="//qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016-180x270.jpg" class="attachment-shop_thumbnail size-shop_thumbnail wp-post-image" alt="" srcset="//qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016-180x270.jpg 180w, //qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016-200x300.jpg 200w, //qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016-768x1152.jpg 768w, //qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016-683x1024.jpg 683w, //qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016-378x567.jpg 378w, //qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016-818x1227.jpg 818w, //qualitinc.com/wp-content/uploads/2017/03/AA9596_camo_model_front_022016.jpg 1200w" sizes="(max-width: 180px) 100vw, 180px" /></a></td>

    Thread Starter burtcav

    (@burtcav)

    Any way to force the use of absolute URLs in the cart, rather than relative so we can extract that data for the quote list submission. htaccess redirect?, Maybe function?, edit wc-cart? Any help would be TOTS appreciated so our store can continue on after this update!!!

    Hi @burtcav, same problem here. Do you find any fix?

    For those looking for a fix for this issue, the culprit is a single line in one template file. For my client, the file and line of code were as follows. Yours may be slightly different depending on your configuration, but hopefully this will give you a way to approach the problem.

    File: wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php
    Line: line 1735.

    return str_replace( array( ‘https://&#8217;, ‘https://&#8217; ), ‘//’, $image );

    I edited this to the following, making as small a change as possible:
    return str_replace( array( ‘https://&#8217;, ‘https://&#8217; ), ‘https://&#8217;, $image );

    The shopping cart element now renders the thumbnail with a full URL, which gets passed into the quote email.

    Note that if your implementation enforces https, you may need to change the prefix. This code exists, I imagine, to standardise the protocol for the images to whatever is in use in any installation, but as we’ve seen it breaks third-party integration when it drops the image into an email.

    Hope this helps.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cart URL’s of product images are Stripped of https:’ is closed to new replies.