• Resolved Saurabh Jain

    (@saurabhj91)


    Hi Team,

    If the vendor product is approved then no email comes with confirmation. Is there any hook to do that?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @saurabhj91 Yoy may refer to this code :

    add_action('transition_post_status', 'wpse_110037_new_posts', 10, 3); function wpse_110037_new_posts($new_status, $old_status, $post) { if( $old_status != 'publish' && $new_status == 'publish' && !empty($post->ID) && in_array( $post->post_type, array( 'product') ) ) { //add your code here } }

    Thread Starter Saurabh Jain

    (@saurabhj91)

    Hi Team,

    Thanks for the response.

    Here the code to make it work, hope it will help someone else.

    <?php 
    
    add_action('transition_post_status', 'send_mail_vendor', 10, 3); 
    function send_mail_vendor($new_status, $old_status, $post) { 
    	if( $old_status != 'publish' && $new_status == 'publish' && !empty($post->ID) && in_array( $post->post_type, array( 'product') ) ) {  
    		$vendor_id = get_post_field( 'post_author', $post->ID );
    		$vendor_data = get_userdata($vendor_id);
    		$mailbody = "Hi Vendor, \n\n Your product ".esc_html($post->post_title)." is approved and listed on Eventfully. \n\n";
    		wp_mail($vendor_data->user_email,'Eventfully - Product Approved', $mailbody);
    	} 
    }
    
    ?>

    @saurabhj91 Thanks for helping out other users also ??

    Thread Starter Saurabh Jain

    (@saurabhj91)

    My Pleasure.

    Below is the updated code to send the approved product mail only when the product is approved 1st time.

    add_action('transition_post_status', 'send_mail_vendor', 10, 3); 
    function send_mail_vendor($new_status, $old_status, $post) {
    	$already_published = get_post_meta($post->ID,'already_published',true);
    	if($already_published != 'yes') {
    		if( $old_status != 'publish' && $new_status == 'publish' && !empty($post->ID) && in_array( $post->post_type, array( 'product') ) ) {  
    			$vendor_id = get_post_field( 'post_author', $post->ID );
    			$vendor_data = get_userdata($vendor_id);
    			$mailbody = "Hi Vendor, \n\n Your product ".esc_html($post->post_title)." is approved and listed on Eventfully. \n\n";
    			wp_mail($vendor_data->user_email,'Eventfully - Product Approved', $mailbody);
    			update_post_meta($post->ID,'already_published','yes');
    		} 
    	}
    }

    Hello.
    Please tell me where to add this code. im facing the same problem. but i have not installed wc marketplace. i have only vendor pro, wc vendors and woo commerce.

    Thank you
    Iresh

    Thread Starter Saurabh Jain

    (@saurabhj91)

    @ireshdilshan you have to add the code in functions.php file. Just change the subject and body of mail accordingly.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Vendor product approved email’ is closed to new replies.