Skip to content

Instantly share code, notes, and snippets.

@tamarazuk
Last active March 31, 2018 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tamarazuk/54cfd7384843fb838294 to your computer and use it in GitHub Desktop.
Save tamarazuk/54cfd7384843fb838294 to your computer and use it in GitHub Desktop.
WooCommerce Admin Custom Order Fields - Allow custom order fields to be accessed by the WooCommerce REST API
<?php // only copy this line if needed
function sv_wc_api_allow_acof_protected_meta() {
add_filter( 'is_protected_meta', 'sv_wc_acof_is_protected_meta', 10, 2 );
}
add_action( 'woocommerce_api_loaded', 'sv_wc_api_allow_acof_protected_meta' );
function sv_wc_acof_is_protected_meta( $protected, $meta_key ) {
if ( 0 === strpos( $meta_key, '_wc_acof_' ) ) {
$protected = false;
}
return $protected;
}
@bobby5892
Copy link

Where would this code even go? Put in themes functions.php?

@abr4xas
Copy link

abr4xas commented Apr 28, 2016

@bobby5892 yes.

@caseywreed
Copy link

Just wanted to thank you for this code! Helped out a lot. Appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment