Coupon description (suggestion)
-
Morning,
I’m the one having issues with spam, I had to do something else cause that was driving me crazy.
First, i’m not a programmer, so go easy on me, it took me the full day to do that !
So i wanted to display a different text on the mail sent to the client depending on wich coupon he bought. I quickly (not so quickly actualy !) discovered that i cannot just ‘had stuff’ randomly and it will magicly work. I had to use one of woocommerce ‘variables’ (i think). I found out that you did not use the ‘description’ of the coupon, so i used that.
Here is what i’ve done :In function.php i added :
line 145 :
$description = wc_format_content( $_POST[‘coupon_gift_name’] );
and i changed the ‘post_excerpt’ to be $description, a couple lines under
line 167 :
update_post_meta( $post_id, ‘coupon_gift_name’, $description );
In class-wc-gift-coupon-metaboxes.php I added :
line 23:
$description = reset(get_post_meta( $post->ID, ‘coupon_gift_name’ ));
line 102:
woocommerce_wp_text_input( array(
‘id’ => ‘coupon_gift_name’,
‘label’ => __( ‘Coupon gift name’, ‘woocommerce’ ),
‘placeholder’ => __( ‘Coupon name on email’, ‘woocommerce’ ),
‘description’ => __( ‘Coupon name on email.’, ‘woocommerce’ ),
‘data_type’ => ‘coupon_gift_name’,
‘desc_tip’ => true,
) );
In mail.php i added :
line 130 :
$description = reset(get_post_meta( $product_id, ‘coupon_gift_name’ ));
update_post_meta( $new_coupon_id, ‘coupon_gift_name’, $description );
line 201 :
$coupons_mail[‘coupon_gift_name’] = $description;
And finaly in mail-template.php i used this $data[‘coupon_gift_name’] to display the description.The little bonus is that on the woocoomerce coupon pannel, i can see where the coupon are comming from via the description.
PS : i added a bunch of //////// around my codes, so the line number might be off by a couple, but i’m sure you will get the idea.
I hope this makes sense, and that other could benefit from it ??
- The topic ‘Coupon description (suggestion)’ is closed to new replies.