Hi Muleque,
hope you are doing well! 🙂
The code you sent is executed when you save a default WooCommerce coupon, for this reason, it’s not working with the YITH Gift Cards.
If you want to add the post meta “is_voucher” when a gift card is pruchased and the code created, you have to add the next code in the functions.php of your active theme:
if( ! function_exists( 'yith_ywgc_add_new_meta_to_gift_card' ) ){
function yith_ywgc_add_new_meta_to_gift_card( $gift_card ) {
update_post_meta( $gift_card->ID, 'is_vourcher', 'yes');
}
add_action('yith_ywgc_after_gift_card_generation_save', 'yith_ywgc_add_new_meta_to_gift_card', 10 );
}
Please, note that it will work only on the new gift card purchases.
Could you check it, please?
Have a nice day!
so I do not know if it actually changes the meta (how to debug this behavior?) I only know that it still does not do the changes I hoped for.
Best
Muleque
Hi Muleque,
After the gift card is generated, you can check the gift card metadata in the wp_postmeta table from the database, searching it by the gift card post ID, and check if this meta is correctly added.
Could you take a look and let us know, please?
Have a nice day!
It actually worked, but was not the intended outcome another plugin this was aimed at.