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.

Please note that this is aimed at developers and if you don't know how to add it to your functions.php file in your theme or child theme then you should ask your developer, or post a job on Codeable to find an expert to do it for you.

We've partnered with Codeable to provide our customers with expert help if required.

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.