Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created March 15, 2023 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webtoffee-git/49d1323b0009cca33cb9c7ead564d9f8 to your computer and use it in GitHub Desktop.
Save webtoffee-git/49d1323b0009cca33cb9c7ead564d9f8 to your computer and use it in GitHub Desktop.
To resolve the url_invalid - line_items[4][price_data][product_data][images][0] error - Stripe Payment Plugin for WooCommerce (https://wordpress.org/plugins/payment-gateway-stripe-and-woocommerce-integration/)
<?php // do not copy this line
add_filter('wt_stripe_alter_checkout_request_params', 'wt_stripe_alter_checkout_request_params', 10, 2);
function wt_stripe_alter_checkout_request_params($request, $order){
if(isset($request['line_items']) && !empty($request['line_items']) ){
foreach($request['line_items'] as $key => $line_item){
if(isset($line_item['price_data']['product_data']['images']) && is_array($line_item['price_data']['product_data']['images']) && !empty($line_item['price_data']['product_data']['images'])){
$url = sanitize_url($line_item['price_data']['product_data']['images'][0][0]);
$request['line_items'][$key]['price_data']['product_data']['images'][0][0] = $url;
}
}
}
return $request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment