Last active
March 22, 2016 15:22
-
-
Save BrandonShutter/570f608486035d4da0cb to your computer and use it in GitHub Desktop.
[Receiptful] - Don't send receipt for virtual products.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( function_exists( 'Receiptful' ) ) : | |
add_action('receiptful_order_status_processing_notification', 'receiptful_no_receipt_virtual_orders', 5, 1); | |
function receiptful_no_receipt_virtual_orders($order_id) | |
{ | |
$order = new WC_Order($order_id); | |
if (count($order->get_items()) > 0) { | |
foreach ($order->get_items() as $item) { | |
if ('line_item' == $item['type']) { | |
$_product = $order->get_product_from_item($item); | |
if ($_product->is_virtual()) : | |
remove_action('receiptful_order_status_processing_notification', array(WC()->mailer->emails['WC_Email_Customer_Completed_Order'], 'trigger')); | |
endif; | |
} | |
} | |
} | |
} | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment