Last active
June 23, 2022 18:37
-
-
Save maxrice/289b8730a363d46fcb7d048f3d9e2e26 to your computer and use it in GitHub Desktop.
Remove the leading "woocommerce_" from the Woo REST API payment_method attribute
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 | |
add_filter( 'woocommerce_rest_prepare_shop_order_object', function( $response ) { | |
// strip leading woocommerce_ from payment method | |
if ( ! empty( $response->data['payment_method'] ) ) { | |
$response->data['payment_method'] = str_replace( 'woocommerce_first_data_', '', $response->data['payment_method'] ); | |
} | |
return $response; | |
}, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment