Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards!

Send Order Cancelled Email to Vendor

WCMp Core

Resolved
Viewing 14 reply threads
  • Author
    Posts
    • #132157
      raoul
      Participant

      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

    • #132194
      aleksandramopzaz
      Participant

      Can you give me an example to use the action : wcmp_commission_after_save_commission_total ?

    • #132225

      Hi, thank you for getting in touch with us.
      Our developer will get back to you.

    • #132236
      Anonymous
      Inactive

      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

    • #132286
      aleksandramopzaz
      Participant

      Can you give me an example to use the action : wcmp_commission_after_save_commission_total ? indigocard

    • #132298
      Anonymous
      Inactive

      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.

    • #132311
      raoul
      Participant

      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.

    • #132324

      Hi,

      @raoul

      Kindly create a separate thread for your issue from here- https://multivendorx.com/support-forum/
      Our team will get back to you.

    • #132334
      raoul
      Participant

      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!

    • #132340

      Sure.
      Our team will get back to you.

    • #132380
      Anonymous
      Inactive

      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.php

      Vendor 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 part

      add_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 );
          } 
      }
      
      Copy

      Hope this might solve your issue
      Thanks

    • #132382
      raoul
      Participant

      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?

    • #132385
      Anonymous
      Inactive

      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

    • #132387
      raoul
      Participant

      Thank you so much Ritik and Tithi!

    • #132398

      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.

Viewing 14 reply threads

The topic ‘Send Order Cancelled Email to Vendor’ is closed to new replies.