Allow vendors to publish the products whichi have been published already.

WCMp Advanced Frontend Manager

Allow vendors to publish the products whichi have been published already. Open

Viewing 1 reply thread
  • Author
    Posts
    • #88373
      ryu
      Participant

      I don’t allow vendors to publish a new product without admin aprroval.
      But, I want to allow vendors to edit and publish a publishd product without being pending status.
      Can I do that?

      ↓This code is not working.

      function on_all_status_transitions( $new_status, $old_status, $post ) {
          if ( $new_status == 'ppending' && $old_status == 'publish' ) {
      		$my_post = array(
      			'ID' => $post_id,
      			'post_status' => 'publish',
      		);
      		wp_update_post( $my_post );
          }
           return $post;
      }
      add_action(  'transition_post_status',  'on_all_status_transitions', 10, 3 );
      copy
    • #88631

      @ryu, you need to use this code, to publish the edited product, if the Publish option is not given :

      /**************  product published after 1st time permission ****************************/
      add_action( 'wcmp_process_product_object', 'approved_vendor_action' , 10 , 2 );
      function approved_vendor_action( $product , $data ){
       if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
         if( metadata_exists( 'post', $product->get_id(), 'approved_manually_vendor' ) ){
           $product_value = get_post_meta( $product->get_id(), 'approved_manually_vendor', true );
             if( $product_value == 2 ){
             $post_data = array(
               'ID' => $product->get_id(),
               'post_status' => 'publish',
               );
             wp_update_post( $post_data );
           }
         } else{
           update_post_meta( $_POST['post_ID'], 'approved_manually_vendor', 1 );
         }
       }
      }
      
      function save_product_from_admin_end( $post_id ) {
       $product = wc_get_product( $post_id );
       $product->update_meta_data( 'approved_manually_vendor', 2 );
       $product->save();
      }
      add_action( 'woocommerce_process_product_meta', 'save_product_from_admin_end' );
      copy
Viewing 1 reply thread

Please LOGIN to reply to this topic

WCMp bundle is available at a slashed price

Grab It Now