• Resolved assad1999

    (@assad1999)


    I want to show the coupon details too in the order email. How can I achieve this by using your plugin..

    Waiting for your response.
    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    Hi,

    Could you please let us know where you would like to display the coupon details in the emails whether it should be along with the order table or separately?

    Thank you!

    Thread Starter assad1999

    (@assad1999)

    Within the order table.

    Plugin Author ThemeHigh

    (@themehigh)

    Hi,

    You can achieve your requirement by adding the below code snippet in your child theme’s functions.php file.

    add_filter( 'woocommerce_get_order_item_totals', 'add_coupons_codes_to_emails', 10, 3 );
    function add_coupons_codes_to_emails( $total_rows, $order, $tax_display ) {
        if( sizeof( $order->get_coupon_codes() ) == 0 )
            return $total_rows;
        $new_total_rows = [];
        foreach($total_rows as $key => $total ){
            $new_total_rows[$key] = $total;
            if( ! isset($total_rows['discount']) && $key === 'shipping' ) {
                $new_total_rows['discount'] = array(
                    'label' => __( 'Discount:', 'woocommerce' ),
                    'value'    => wc_price(0),
                );
            }
            if( $key === 'discount' || isset($new_total_rows['discount']) ){
                $applied_coupons = $order->get_coupon_codes();
                $new_total_rows['coupon_codes'] = array(
                    'label' => __('Applied coupons:', 'woocommerce'),
                    'value' => implode( ', ', $applied_coupons ),
                );
            }
        }
        return $new_total_rows;
    }

    Thank you!

    Dina S.

    (@themehighsupport)

    We hope your issue is resolved. We are going to mark this thread as resolved.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show Coupon Details In The Email’ is closed to new replies.