Skip to content

Instantly share code, notes, and snippets.

@BrandonShutter
Last active March 22, 2016 15:22
Show Gist options
  • Save BrandonShutter/570f608486035d4da0cb to your computer and use it in GitHub Desktop.
Save BrandonShutter/570f608486035d4da0cb to your computer and use it in GitHub Desktop.
[Receiptful] - Don't send receipt for virtual products.
<?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