Pokud je potřeba vložit nějaký obsah do Woocommerce emailů:
- vlastní šablona
- vložit obsah pomocí hooku
Woocommerce email hooks
woocommerce_email_header ($email_heading, $email) woocommerce_email_order_details ($order, $sent_to_admin, $plain_text, $email) woocommerce_email_before_order_table ($order, $sent_to_admin, $plain_text, $email) woocommerce_order_item_meta_start($item_id, $item, $order, $plain_text) woocommerce_order_item_meta_end ($item_id, $item, $order, $plain_text) woocommerce_email_after_order_table ($order, $sent_to_admin, $plain_text, $email) woocommerce_email_order_meta ($order, $sent_to_admin, $plain_text, $email) woocommerce_email_customer_details ($order, $sent_to_admin, $plain_text, $email) woocommerce_email_footer($email)
Příklad 1
<?php
add_action( 'woocommerce_email_header', 'mm_email_header', 10, 2 );
function mm_email_header( $email_heading, $email ) {
echo "<p> Thanks for shopping with us. We appreciate you and your business!</p>";
}
Příklad 2
<?php
add_action( 'woocommerce_email_after_order_table', 'mm_email_after_order_table', 10, 4 );
function mm_email_after_order_table( $order, $sent_to_admin, $plain_text, $email ) {
echo "<p>Hey! Thanks for shopping with us. As a way of saying thanks, here’s a coupon code for your next purchase: FRESH15</p>";
}
Příklad 3
<?php
add_action( 'woocommerce_email_footer', 'mm_email_footer', 10, 1 );
function mm_email_footer( $email ) { ?>
<p><?php printf( __( 'Thank you for shopping! Shop for more items using this link: %s', 'woocommerce' ), '<a href="' . get_permalink( wc_get_page_id( 'shop' ) ) . '">' . __( 'Shop', 'woocommerce' ) . '</a>' ); ?></p>
<?php
}
Může se hodit…
Pokud je potřeba vložit obsah jen do některých e-mailů, je třeba dát podmínku
if( 'customer_processing_order' == $email->id ){
...
}
kde
$email-id
může být:
new_order customer_on_hold_order customer_processing_order customer_completed_order customer_refunded_order customer_partially_refunded_order cancelled_order failed_order customer_reset_password customer_invoice customer_new_account customer_note