mailer(); if ( $subscription->has_status( array( 'pending-cancel', 'cancelled' ) ) && 'true' !== get_post_meta( $subscription->id, '_cancelled_email_sent', true ) ) { do_action( 'cancelled_subscription_notification', $subscription ); } } /** * Init the mailer and call the notifications for the renewal orders. * * @param int $user_id The ID of the user who the subscription belongs to * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key() * @return void */ public static function send_renewal_order_email( $order_id ) { WC()->mailer(); if ( wcs_order_contains_renewal( $order_id ) ) { do_action( current_filter() . '_renewal_notification', $order_id ); } } /** * If the order is a renewal order, don't send core emails. * * @param int $user_id The ID of the user who the subscription belongs to * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key() * @return void */ public static function maybe_remove_woocommerce_email( $order_id ) { if ( wcs_order_contains_renewal( $order_id ) || wcs_order_contains_switch( $order_id ) ) { remove_action( current_filter(), array( 'WC_Emails', 'send_transactional_email' ) ); } } /** * If the order is a renewal order, don't send core emails. * * @param int $user_id The ID of the user who the subscription belongs to * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key() * @return void */ public static function maybe_reattach_woocommerce_email( $order_id ) { if ( wcs_order_contains_renewal( $order_id ) || wcs_order_contains_switch( $order_id ) ) { add_action( current_filter(), array( 'WC_Emails', 'send_transactional_email' ) ); } } /** * If viewing a renewal order on the the Edit Order screen, set the available email actions for the order to use * renewal order emails, not core WooCommerce order emails. * * @param int $user_id The ID of the user who the subscription belongs to * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key() * @return void */ public static function renewal_order_emails_available( $available_emails ) { global $theorder; if ( wcs_order_contains_renewal( $theorder->id ) ) { $available_emails = array( 'new_renewal_order', 'customer_processing_renewal_order', 'customer_completed_renewal_order', ); if ( $theorder->needs_payment() ) { array_push( $available_emails, 'customer_renewal_invoice' ); } } return $available_emails; } /** * Init the mailer and call the notifications for subscription switch orders. * * @param int $user_id The ID of the user who the subscription belongs to * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key() * @return void */ public static function send_switch_order_email( $order_id ) { WC()->mailer(); if ( wcs_order_contains_switch( $order_id ) ) { do_action( current_filter() . '_switch_notification', $order_id ); } } /** * Generate an order items table using a WC compatible version of the function. * * @param object $order * @param array $args { * @type bool 'show_download_links' * @type bool 'show_sku' * @type bool 'show_purchase_note' * @type array 'image_size' * @type bool 'plain_text' * } * @return string email order items table html */ public static function email_order_items_table( $order, $args = array() ) { $items_table = ''; if ( is_numeric( $order ) ) { $order = wc_get_order( $order ); } if ( is_a( $order, 'WC_Abstract_Order' ) ) { if ( WC_Subscriptions::is_woocommerce_pre( '2.5' ) ) { $items_table = call_user_func_array( array( $order, 'email_order_items_table' ), $args ); } else { // 2.5 doesn't support both the show_download_links or show_purchase_note parameters but uses $order->is_download_permitted and $order->is_paid instead $show_download_links_callback = ( isset( $args['show_download_links'] ) && $args['show_download_links'] ) ? '__return_true' : '__return_false'; $show_purchase_note_callback = ( isset( $args['show_purchase_note'] ) && $args['show_purchase_note'] ) ? '__return_true' : '__return_false'; unset( $args['show_download_links'] ); unset( $args['show_purchase_note'] ); add_filter( 'woocommerce_order_is_download_permitted', $show_download_links_callback ); add_filter( 'woocommerce_order_is_paid', $show_purchase_note_callback ); $items_table = $order->email_order_items_table( $args ); remove_filter( 'woocommerce_order_is_download_permitted', $show_download_links_callback ); remove_filter( 'woocommerce_order_is_paid', $show_purchase_note_callback ); } } return $items_table; } /** * Init the mailer and call the notifications for the current filter. * * @param int $user_id The ID of the user who the subscription belongs to * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key() * @return void * @deprecated 2.0 */ public static function send_subscription_email( $user_id, $subscription_key ) { _deprecated_function( __FUNCTION__, '2.0' ); } } WC_Subscriptions_Email::init();