• Resolved ezzmay007

    (@ezzmay007)


    Im using wcfm with woocommerce subscriptions. When a subscription is cancelled only admin receives the email but I also need the vendor to receive this email. What code can I use to add the “subscription cancelled” email to the list of vendor emails?

    I realise this will be complex, and I can edit the code within the subscriptions plugin to send an email to the buyer, but I’m not sure the correct code to say “send to the vendor”

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author WC Lovers

    (@wclovers)

    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”?

    Thread Starter ezzmay007

    (@ezzmay007)

    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.
    Plugin Author WC Lovers

    (@wclovers)

    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

    Thread Starter ezzmay007

    (@ezzmay007)

    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

    Plugin Author WC Lovers

    (@wclovers)

    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.

    Thread Starter ezzmay007

    (@ezzmay007)

    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

    Plugin Author WC Lovers

    (@wclovers)

    Where have you added this code?

    What is your WooCommerce Subscription plugin’s version?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Custom email’ is closed to new replies.