• Resolved henrischiltz

    (@henrischiltz)


    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 ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Alberto Perez

    (@studiosweb)

    Hi @henrischiltz.

    I think that your suggestions could be:

    In the plugin settings page add a checbox which say “Add body text or description product”. If people select “body text” then, its is the enabled functionally now…but if people check description, then we can get the description product to show in the body of coupon. Is that your suggestion?

    Regards.

    • This reply was modified 6 years, 11 months ago by Alberto Perez.
    Thread Starter henrischiltz

    (@henrischiltz)

    That would work, but in my case the PRODUCT description would still not be what i want to be displayed. So i added a way to set the COUPON description
    On the original code in the function.php i replaced :
    'post_excerpt' => 'Discount Coupon',
    by
    'post_excerpt' => $description,
    and made a bunch of stuff to that on the product page in the admin pannel i have this box (sorry for the bits in french… i’m french… pardon) :
    link to th
    this field (who adds <p></p> around the text… for some reason i ignore) changes the woocommerce description of the coupon as seen on the coupon page :
    link to the image
    On the email template i then call this description to be displayed in place of the price (and i moved the price at the bottom)
    The idea is that people can gift the coupon for a product (in my case, a hotel night) to someone.

    I think this is a nice addition so i thought i could make other enjoy it.
    But on my end, it’s all working, no need for you to do anything.

    Now that i think about it, replacing the body text by the procuct description would be really cool too.

    PS : sorry for my poor explenation, i blame my level of english and my lake of sleep due to the fact i worked late on this ??

    • This reply was modified 6 years, 11 months ago by henrischiltz.

    I strongly support this suggestion.

    We sell 2 different coupons in our webshop, which are both restricted to different products. However there seems to be no way to clarify this in the e-mail/pdf coupon. Clients will thin their coupon can be used for any product, which is not the case.

    It would be cool if the price could be replaced with the coupon product name (or a description).

    Plugin Author Alberto Perez

    (@studiosweb)

    Hi @roelvdp

    Next version 2.8 will include:

    1 – Can reemplace the title by the title′s coupon
    2 – Can reemplace the description by the description′s coupon

    In the plugin settings page, you can choose if you want to display a custom title or coupon title…Similar with description.

    I think that the versión 2.8 would be upload today or tomorrow!

    Regards.

    • This reply was modified 6 years, 11 months ago by Alberto Perez.
    Plugin Author Alberto Perez

    (@studiosweb)

    Hi @roelvdp

    This issue is fixed in a new release 2.8. Please upgrade your plugin to this version.

    Thanks a lot.

    Please help us to continue developing with a low donation ??

    • This reply was modified 6 years, 11 months ago by Alberto Perez.

    I just installed the new version and it seems to work like a charm. Thanks a lot, it’s great tha twe can use this for the holidays! I donated a small amount ??

    One small suggestion though: in a next update, if possible, maybe build in an option to “hide coupon price” – so that you can just see the title. It’s nothing major of course, but for us specifically this would come in useful. We have coupons for subscriptions on our magazine, but we want all customers to pay 0,02 € so we can still link their credit or debitcard for future automatic recurring renewals. So for example our coupons are not 100%, but 99,92%. This is a bit of a weird number to display in a gift coupon. So it would be cool if this could be hidden.

    Thread Starter henrischiltz

    (@henrischiltz)

    Wow, so elegant and simple.
    And i can even keep my custom coupon_excerpt AND use your solution.
    Clap
    Clap
    Clap ??

    PS : @roelvdp if you want to hide the price, open mail-template.php and delete line 76 :
    `<h2 style=”text-transform:uppercase; color:#fff; text-align:center; font-size: 86px; font-family:Helvetica, Arial, sans-serif; font-weight:bold;display: block;margin: 0;”>‘ . $data[‘price’] . ‘</h2>’
    That’s the line that displays the price. (And that’s how i hide it personaly)
    Always keep an original of the file in case it breaks, and always have an acces to your ftp to replace the file in case the site breaks (this shouldn’t happen… but better safe than sorry)

    Plugin Author Alberto Perez

    (@studiosweb)

    Hi @roelvdp

    Thank you a lot for you donation :). We try to the next update create a checbox in the plugin admin page to allow administrator to hice prize if he wants.

    Thank you @henrischiltz.

    Regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Coupon description (suggestion)’ is closed to new replies.