• As I understand, a gift card code is not created until the shop owner sets its related order to Processing or Complete. Am I right? When this happens, a notification email with this code is sent to the recipient of the gift card.

    My question is, is there a way to create the gift card code without sending this email automatically?

    I’ve added the following code to my functions.php file:

    add_filter( 'ywgc_send_gift_card_code_by_default', '__return_false' );

    but the email is sent anyway.

    Is there a way to really prevent the sending of these emails when creating gift card codes?

    Thanks in advance

    • This topic was modified 3 years, 3 months ago by leemon.
    • This topic was modified 3 years, 3 months ago by leemon.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Christian Rodríguez

    (@christianrh)

    Hello there,

    hope you are doing well ??

    You can disable the email “YITH Gift Cards – Dispatch of the code” in “WooCommerce > Settings > Emails”. In this way the email will only be sent if you do it manually (plugin settings > “send now” button).

    Let us know any news, please.

    Have a nice day!

    Thread Starter leemon

    (@leemon)

    Even though I disabled the email “YITH Gift Cards – Dispatch of the code” in “WooCommerce > Settings > Emails”, the mail with the gift code is still sent automatically when setting an order containing a gift card to “Processing” or “Complete”.

    • This reply was modified 3 years, 3 months ago by leemon.
    Thread Starter leemon

    (@leemon)

    The plugin never checks the value of the woocommerce_email_enabled_<id> filter before sending the mail:

    https://hookr.io/filters/woocommerce_email_enabled_id/

    So your solution is not going to work.

    You should check this filter before the following line in the trigger function in the class-yith-ywgc-email-send-gift-card.php file, like the WooCommerce core email files do.

    You should change this:

    $result = $this->send(
        $this->get_recipient(),
        $this->get_subject(),
        $this->get_content( $case ),
        $this->get_headers(),
        $this->get_attachments()
    );

    to this:

    if ( $this->is_enabled() && $this->get_recipient() ) {
        $result = $this->send(
    	$this->get_recipient(),
    	$this->get_subject(),
    	$this->get_content( $case ),
    	$this->get_headers(),
    	$this->get_attachments()
        );
        ......
    }

    Hello there,

    Thanks for your reply, hope you are doing well ??

    Do you have the last version of the plugin installed? We tested on our local and is working as we sent to you.

    Could you check it? If you have an error again could you test with only WooCommerce and our plugin activated?

    Let us know any news, please.

    Have a nice day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Don’t send automatic email when creating gift card code’ is closed to new replies.