url image encoding bug
-
hello,
on my woocommerce I have noticed a bug regarding special characters in the image url sent to stripe checkout.I have the brand Levi’s?
and wordpress generates the image url with this character: ?Orders with stripe checkout have this error:
url_invalid – line_items[0][price_data][product_data][images][0]
Invalid URL: Non-ASCII characters in URLs must be percent-encoded in order for the URL to be valid.I tried editing your plugin file
wp-content\plugins\payment-gateway-stripe-and-woocommerce-integration\includes\class-stripe-checkout.php
line 315from:
$session_data[‘line_items’][$index][‘price_data’][‘product_data’][‘images’][] = array(($featured_image[0]);to:
$session_data[‘line_items’][$index][‘price_data’][‘product_data’][‘images’][] = array(url_encode($featured_image[0]));sending to stripe this url:
https%3A%2F%2Fgoccia.shop%2Fwp-content%2Fuploads%2F2023%2F01%2Fjeans-regular-loose-levis%C2%AE-denim-501-levis-original-00501-3261-1673274958-1-150×150.jpegthe error is no longer generated but stripe is no longer able to display the image preview in the checkout.
I therefore FINALLY SOLVED it by encoding only that specific character:
$entities = array(‘?’,);
$session_data[‘line_items’][$index][‘price_data’][‘product_data’][‘images’][] = array(str_replace($entities, ‘%C2%AE’,$featured_image[0]));I hope you can use this to fix this in a future update.
- The topic ‘url image encoding bug’ is closed to new replies.