WCMp Core
-
AuthorPosts
-
-
December 18, 2021 at 4:14 PM #132157raoulParticipant
Hi, when an Order Status is changed to “Cancelled” or “Failed” the admin is notified via email. However, I wish for the Customer and the Vendor to also receive confirmation of the cancelled or failed order.
I copied the code taken from this previous support ticket: https://multivendorx.com/support-forum/topic/send-order-cancelled-email-to-vendor/. However when I do this I get a critical error on my website – I’ve copied the stack trace below. Please could you update the code snippet in the previous support ticket? That would be extremely helpful, thank you!
CRITICAL Uncaught Error: Call to a member function get_billing_email() on null in /home/customer/www/histreetdelivery.com/public_html/wp-content/themes/rigid/functions.php:2134
Stack trace:
#0 /home/customer/www/histreetdelivery.com/public_html/wp-includes/class-wp-hook.php(305): send_custom_email_notifications(‘raoul@histreetd…’, NULL)
#1 /home/customer/www/histreetdelivery.com/public_html/wp-includes/plugin.php(189): WP_Hook->apply_filters(‘raoul@histreetd…’, Array)
#2 /home/customer/www/histreetdelivery.com/public_html/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(399): apply_filters(‘woocommerce_ema…’, ‘raoul@histreetd…’, NULL, Object(WC_Email_Cancelled_Order))
#3 /home/customer/www/histreetdelivery.com/public_html/wp-content/plugins/woocommerce/includes/admin/settings/class-wc-settings-emails.php(328): WC_Email->get_recipient()
#4 /home/customer/www/histreetdelivery.com/public_html/wp-includes/class-wp-hook.php(303): WC_Settings_Emails->email_notification_setting(Array)
#5 /home/custom in /home/customer/www/histreetdelivery.com/public_html/wp-content/themes/rigid/functions.php on line 2134 -
December 20, 2021 at 2:53 PM #132194aleksandramopzazParticipant
Can you give me an example to use the action : wcmp_commission_after_save_commission_total ?
-
December 20, 2021 at 9:57 PM #132225MVX Support NinjaKeymaster
Hi, thank you for getting in touch with us.
Our developer will get back to you. -
December 21, 2021 at 12:27 PM #132236AnonymousInactive
Hi,
I have gone through the problem but in my end the code is working fine
as it is able to send the email to the admin as well as to the customer and vendor.
please check your code once in your functions.php if again there is error
send me screenshot of the problem.
Thanks -
December 22, 2021 at 10:11 AM #132286aleksandramopzazParticipant
Can you give me an example to use the action : wcmp_commission_after_save_commission_total ? indigocard
-
December 22, 2021 at 3:43 PM #132298AnonymousInactive
Hi,
This is a do_action. you have to use add action to modify commission totals. You can get a reference for do_action from here https://developer.wordpress.org/reference/functions/do_action/. We have to save commission on a particular meta. So you have to modify it as per your requirement. -
December 22, 2021 at 4:58 PM #132311raoulParticipant
Here is the code I put into functions.php copied from this ticket https://multivendorx.com/support-forum/topic/send-order-cancelled-email-to-vendor/
add_filter( ‘woocommerce_email_recipient_cancelled_order’,’send_custom_email_notifications’,10,2);
add_filter( ‘woocommerce_email_recipient_failed_order’,’send_custom_email_notifications’,10,2);
function send_custom_email_notifications( $recipient, $object ){
$vendor_term = get_vendor_from_an_order($object);
$vendor_email = array();
foreach ($vendor_term as $key => $value) {
$vendor_setails = get_wcmp_vendor_by_term($value);
$vendor_email[] = $vendor_setails->user_data->data->user_email;
}
$vendor_email_convert = implode(” , “,$vendor_email);
$customer_email = $object->get_billing_email();
$recipient .= ‘, ‘ . $vendor_email_convert.’, ‘ . $customer_email;
return $recipient;
}When I add this code, I can only see two emails on the WooCommerce > Settings > Emails page. I’ve attached a screenshot that shows that I only see two emails and that there has been a critical error on the website.
When I don’t add this code, I can see all my emails showing correctly. I’ve attached a second screenshot showing this.
-
December 22, 2021 at 8:15 PM #132324MVX Support NinjaKeymaster
Hi,
@raoul
Kindly create a separate thread for your issue from here- https://multivendorx.com/support-forum/
Our team will get back to you. -
December 22, 2021 at 9:23 PM #132334raoulParticipant
Hi @Tithi, the support forum won’t let me create another ticket with a similar topic title. Can this issue be resolved in this ticket (as it was the original topic)?
Thank you!
-
December 22, 2021 at 9:41 PM #132340MVX Support NinjaKeymaster
Sure.
Our team will get back to you. -
December 23, 2021 at 6:30 PM #132380AnonymousInactive
Hi, I have checked your issue regarding the email settings in woocommerce
Below is the code can you please check on your side in your active theme functions.phpVendor Cancelled order email part
add_filter( 'woocommerce_email_recipient_cancelled_order','send_custom_email_notifications',10,2); add_filter( 'woocommerce_email_recipient_failed_order','send_custom_email_notifications',10,2); function send_custom_email_notifications( $recipient, $object ){ $vendor_term = get_vendor_from_an_order($object); $vendor_email = array(); foreach ($vendor_term as $key => $value) { $vendor_setails = get_wcmp_vendor_by_term($value); $vendor_email[] = $vendor_setails->user_data->data->user_email; } $vendor_email_convert = implode(" , ",$vendor_email); $recipient .= ', ' . $vendor_email_convert; return $recipient; }
Copy—————————————————————————————————————————————————
Customer Cancelled order Email partadd_action('woocommerce_order_status_changed', 'custom_send_email_notifications', 10, 4 ); function custom_send_email_notifications( $order_id, $old_status, $new_status, $order ){ if ( $new_status == 'cancelled' || $new_status == 'failed' ){ $wc_emails = WC()->mailer()->get_emails(); // Get all WC_emails objects instances $customer_email = $order->get_billing_email(); // The customer email } if ( $new_status == 'cancelled' ) { // change the recipient of this instance $wc_emails['WC_Email_Cancelled_Order']->recipient = $customer_email; // Sending the email from this instance $wc_emails['WC_Email_Cancelled_Order']->trigger( $order_id ); } elseif ( $new_status == 'failed' ) { // change the recipient of this instance $wc_emails['WC_Email_failed_Order']->recipient = $customer_email; // Sending the email from this instance $wc_emails['WC_Email_failed_Order']->trigger( $order_id ); } }
CopyHope this might solve your issue
Thanks -
December 23, 2021 at 7:10 PM #132382raoulParticipant
Thanks Ritik, yes this works, thanks so much.
Is there a way to send different emails to customers and vendors when the order is cancelled? Currently the emails are identical which means the email copy doesn’t make much sense to customers. I assume the only way to do this is to create a new template?
-
December 23, 2021 at 7:19 PM #132385AnonymousInactive
Hi,
happy to see that your issue has been solved.
Yes you are right it is only possible by creating a new template for customer -
December 23, 2021 at 7:25 PM #132387raoulParticipant
Thank you so much Ritik and Tithi!
-
December 23, 2021 at 10:01 PM #132398MVX Support NinjaKeymaster
You are welcome @raoul
we are happy to help you
We would love it if you shared your experience by giving us 5/5 review here :
https://wordpress.org/support/plugin/dc-woocommerce-multi-vendor/reviews/#new-post
Seeing glowing reviews from existing customers makes others more comfortable knowing they’ll get the support they need with an issue with our services when arise.
-
-
AuthorPosts
The topic ‘Send Order Cancelled Email to Vendor’ is closed to new replies.