Created
March 15, 2023 06:18
-
-
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/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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