Skip to content

Instantly share code, notes, and snippets.

@qant
Created April 26, 2023 07:01
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 qant/52fa02625763778eb447023be79ee9aa to your computer and use it in GitHub Desktop.
Save qant/52fa02625763778eb447023be79ee9aa to your computer and use it in GitHub Desktop.
modify printify response for wordpress http request http_response
<?php
/**
* @see Printify_Shipping_API::get_shipping_rates()
* @see \WP_Http::request()
*/
function modify_printify_response( $response, $parsed_args, $url ) {
// Check is it a request to Printify.
if( 0 !== strpos( $url, 'https://api-prod.printify.com' ) ) {
return $response;
}
$body = json_decode( $response['body'] );
// TODO Manipulate the repsonse.
$response['body'] = wp_json_encode( $body );
return $response;
}
add_filter( 'http_response', 'modify_printify_response', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment