Created
June 4, 2015 09:15
-
-
Save psaikali/ce7a3e95de90afb16ba2 to your computer and use it in GitHub Desktop.
Enregistrer les valeurs des nouveaux champs produits WooCommerce
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
/************************************************************************************************* | |
* 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