Advertisement
palsushobhan

wcfm-product-multivendor-notification.php

May 17th, 2022
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. add_action('after_wcfmmp_product_multivendor_clone', function($new_product_id, $original_product) {
  2.     $vendor_id = wcfm_get_vendor_id_by_post($original_product->get_id());
  3.     if($vendor_id) {
  4.         $vendor_user = new WP_User(absint($vendor_id));
  5.         $store_email = wcfm_get_vendor_store_email_by_vendor($vendor_id);
  6.         $new_vendor_id = wcfm_get_vendor_id_by_post($new_product_id);
  7.         $new_store_name = wcfm_get_vendor_store_name($new_vendor_id);
  8.         $store_url = wcfmmp_get_store_url( $new_vendor_id );
  9.  
  10.         if ( ! defined( 'DOING_WCFM_EMAIL' ) ) define( 'DOING_WCFM_EMAIL', true );
  11.    
  12.         $multivendor_message = sprintf( 'Product %s%s%s in your catalog is now sold by vendor %s%s%s', '<a href="'.get_permalink($original_product->get_id()).'">', $original_product->get_name(), '</a>', '<a href="'.$store_url.'">', $new_store_name, '</a>');
  13.         $notificaton_mail_subject = "{site_name}: " . __( "Product is offered by other sellers", "wc-frontend-manager-ultimate" );
  14.         $notification_mail_body = '<br/>' . __( 'Hi', 'wc-frontend-manager-ultimate' ) . ' {vendor_name}' .
  15.         ',<br/><br/>' .
  16.         '{multivendor_message}' .
  17.         '<br/><br/>' .
  18.         '<br /><br/>' . __( 'Thank You', 'wc-frontend-manager' ) .
  19.         '<br/><br/>';
  20.  
  21.         $subject = str_replace( '{site_name}', get_bloginfo( 'name' ), $notificaton_mail_subject );
  22.         $subject = apply_filters( 'wcfm_email_subject_wrapper', $subject );
  23.         $message = str_replace( '{multivendor_message}', $multivendor_message, $notification_mail_body );
  24.         $message = str_replace( '{vendor_name}', $vendor_user->first_name, $message );
  25.         $message = apply_filters( 'wcfm_email_content_wrapper', $message, __( "Product Multivendor Notification", "wc-frontend-manager-ultimate" ) );
  26.  
  27.         wp_mail( $store_email, $subject, $message );
  28.     }
  29. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement