1. Home
  2. Knowledge Base
  3. WooCommerce Multiple Email Recipients
  4. Advanced Usage

Sending YITH Request a Quote emails to additional recipients

When you use the WooCommerce Multiple Email Recipients plugin with YITH Request a Quote to create the quotes in the admin side, the additional email recipients are not automatically included in the quote-related emails. You can use the following code snippet to achieve this.

The code snippets are aimed at developers. If you feel comfortable using them, our article on how to use code snippets can serve as a helpful guide. However, if you don't feel comfortable using them, then you should ask your developer, or use our plugin customization service.

Code snippet

<?php

add_action( 'woocommerce_after_order_object_save', 'barn2_save_additional_emails' );
function barn2_save_additional_emails( $order ) {
if ( ! function_exists( 'Barn2\Plugin\WC_Multiple_Email_Recipients\wmer' ) ) {
// Bail out if WMER is not installed
return;
}

$status = $order->get_status();

if ( 0 !== strpos( $status, 'ywraq' ) ) {
// Bail out if the status of the order is not related to YWRAQ
return;
}

// Get the WMER service responsible for adding the additional emails to each order
$fields_service = Barn2\Plugin\WC_Multiple_Email_Recipients\wmer()->get_service( 'fields_service' );

if ( is_a( $fields_service, 'Barn2\Plugin\WC_Multiple_Email_Recipients\Fields_Service' ) ) {
// If the service is found and an object of the appropriate class, save the user additional emails as metadata of the order
$fields_service->save_fields_from_order_post( $order );
}
}

Please note that when you have a quote form on the front end, you don't need this code.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.