Skip to content

Instantly share code, notes, and snippets.

@kilbot
Last active November 7, 2021 12:41
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 kilbot/311cf30800339dd17cf063b710f9b9fe to your computer and use it in GitHub Desktop.
Save kilbot/311cf30800339dd17cf063b710f9b9fe to your computer and use it in GitHub Desktop.
Support for PW Gift Cards plugin
<?php
// add to your theme functions.php file
function pw_gift_card_product_response($response) {
if( ! function_exists('is_pos') || ! is_pos() )
return $response;
$data = $response->get_data();
$type = isset( $data['type'] ) ? $data['type'] : '';
if($type == 'pw-gift-card') {
$data['type'] = 'variable';
$response->set_data( $data );
}
return $response;
}
add_filter( 'woocommerce_rest_prepare_product_object', 'pw_gift_card_product_response', 9, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment