Send function to Complete order e-mail in woocommerce

72 views Asked by At

I've made some function to check, what is total cart, and show how much discount have.

For example: If customer add to cart minimum $300, i will show "You have 10% discount". And i have 3 steps for this. Discount i have made 3rd party plugin.

How to add this function to e-mail, when customer make order? And How to add this function to order details in backed Admin?

function rabaty() {

    global $woocommerce;
    $rabat = $woocommerce->cart->cart_contents_total+$woocommerce->cart->tax_total;



if ( $rabat >= 1500 ) {
    echo '<h3>Masz 20% rabatu!</h3>';
    }
elseif ($rabat >= 700) {
    echo '<h3 style="margin:0px;">Masz 15% rabatu!</h3>
    <strong><span style="margin-bottom:10px;font-size:16px;">Zrób zakupy za minimum 1500 zł, aby otrzymać 20% zniżki</span></strong>';
}
elseif ($rabat >=300) {
    echo '<h3 style="margin:0px;">Masz 10% rabatu!</h3>
    <strong><span style="margin-bottom:10px;font-size:16px;">Zrób zakupy za minimum 700 zł, aby otrzymać 15% zniżki</span></strong>';
}
else {
    echo '<h3 style="margin:0px;">Nie masz żadnych rabatów</h3>
    <strong><span style="margin-bottom:10px;font-size:16px;">Zrób zakupy za minimum 300 zł, aby otrzymać 10% zniżki</span></strong>';
}

}

add_action( 'woocommerce_cart_totals_after_order_total', 'rabaty');
add_action( 'woocommerce_review_order_after_order_total', 'rabaty');
0

There are 0 answers