Skip to content

Instantly share code, notes, and snippets.

@psaikali
Created June 4, 2015 09:15
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 psaikali/ce7a3e95de90afb16ba2 to your computer and use it in GitHub Desktop.
Save psaikali/ce7a3e95de90afb16ba2 to your computer and use it in GitHub Desktop.
Enregistrer les valeurs des nouveaux champs produits WooCommerce
/*************************************************************************************************
* On enregistre les valeurs de LOVES & HATES lorsqu'on enregistre un post
*************************************************************************************************/
function msk_save_loves_hates_product_fields($product_id, $post, $update) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if ($post->post_type == 'product') {
if (isset($_POST['loves'])) {
$loves = (int)$_POST['loves'];
update_post_meta($product_id, 'loves', $loves);
}
if (isset($_POST['hates'])) {
$hates = (int)$_POST['hates'];
update_post_meta($product_id, 'hates', $hates);
}
}
}
add_action('save_post', 'msk_save_loves_hates_product_fields', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment