Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.