Advertisement
Guest User

Untitled

a guest
May 25th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. # reduce stock filter
  2. function stock_change_email_log( $order ) {
  3. $email = 'youemail@domain';
  4. $subject = 'Stock is changed - Log';
  5. $product_details = array('<h4>Product changed details:</h4>');
  6. $order_items = $order->get_items();
  7. foreach( $order_items as $product ) {
  8. $product_details[] = 'UN: ' . $product['qty'] . ' | (' . $product['product_id'] . ') ' . $product['name'];
  9. }
  10. $product_list = implode( '<br>', $product_details );
  11. wp_mail($email, $subject, $product_list);
  12. }
  13.  
  14. add_action( 'woocommerce_reduce_order_stock', 'stock_change_email_log' );
  15.  
  16. # enable html content
  17. function email_log_content_type(){
  18. return "text/html";
  19. }
  20. add_filter( 'wp_mail_content_type','email_log_content_type' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement