What code can I use to add the “subscription cancelled” email to the list of vendor emails?
– What do you mean by “list of vendor emails”?
I Meant on the notification manager page, In wcfm admin.
So here is some code I can use to send this email to the customer, just help me out with the changes that need to be made to send this to the vendor instead? i think $vendor_email is what we need to use, just not sure exactly how to edit this code for the vendor instead of the customer
/* Send email to a customer on cancelled subscription in WooCommerce */
add_action( ‘woocommerce_subscription_status_pending-cancel’, ‘sendCustomerCancellationEmail’ );
/**
* @param WC_Subscription $subscription
*/
function sendCustomerCancellationEmail( $subscription ) {
$customer_email = $subscription->get_billing_email();
$wc_emails = WC()->mailer()->get_emails();
$wc_emails[‘WCS_Email_Cancelled_Subscription’]->recipient = $customer_email;
$wc_emails[‘WCS_Email_Cancelled_Subscription’]->trigger( $subscription );
-
This reply was modified 5 years, 11 months ago by
ezzmay007.
Well, for the purpose ode will be this –
add_filter( 'woocommerce_email_recipient_cancelled_subscription', function( $recipients, $this_email ) {
global $WCFM, $WCFMu;
if ( ! empty( $this_email ) ) {
if( $WCFMu->is_marketplace ) {
$subscription = $this_email->object;
if ( is_object( $subscription ) ) {
$line_items = $subscription->get_items();
foreach ( $line_items as $item_id => $item ) {
$product_id = $item->get_product_id();
$vendor_email = wcfm_get_vendor_store_email_by_post( $product_id );
if ( !empty( $recipients ) ) {
$recipients .= ',' . $vendor_email;
} else {
$recipients = $vendor_email;
}
}
}
}
}
return $recipients;
}, 50, 2 );
Thank You
Great thanks, i will test this code.
Also id there any way to send a vendor a reminder email each week if their order has not been shipped/marked as complete?
Spending time chasing up vendors is time-consuming, surely the plugin is able to send a reminder email?
Thanks
Also id there any way to send a vendor a reminder email each week if their order has not been shipped/marked as complete?
– No, by default there is no such notification for vendors.
Hi the above code does not wor, any other ideas please?
Thanks
*recap the admin gets an email saying when a subscripton has been cancelled, but the vendor does not, need some code to notify the vendor that the subscription has been cancelled.
Thanks
Where have you added this code?
What is your WooCommerce Subscription plugin’s version?