Support

Account

Home Forums Front-end Issues How to register taxonomy for multi vendor

Solving

How to register taxonomy for multi vendor

  • Hello,
    Need help with some problem,

    Cannot get custom fields group in the frontend of the vendor if I use Location Rules
    Post type = Product and
    Post Taxonomy = product_cat “Cars”

    On plugin, settings have the option to show but just if I use
    Post type = Product
    if I add another rule they won’t show files.

    I find on the plugin front end page some code and need to add this taxonomy (what i don’t know make)

    public function set_props( $id ) {
    	$this->id = $id;
    	$this->product = wc_get_product( $this->id );
            $this->post_type = get_post_type( $this->id );
    	$this->post_taxonomy = get_post_taxonomy( $this->id ); //add a ‘Post Taxonomy’ filter
            $this->field_groups = acf_get_field_groups(array(
            	'post_id' => $this->id, 
            	'post_type' => $this->post_type,
    			'post_taxonomy' => $this->post_taxonomy
    			));
        }

    and I get an error on get_post_taxonomy well…
    I have no clue how to register or write this get_post_taxonomy and will really appreciate if anyone can help, if not well thank you anyway 🙂

    Thank you

  • Here is the whole code that expects to show ACF fields, but they do not filter Product Category,

    Anyone please help me to get work this THANK YOU

    defined( 'ABSPATH' ) || exit;
    
    class WCMp_AFM_Advanced_Custom_Fields_Pro_Integration {
    	
    	protected $id = null;
    	protected $product = null;
    	protected $field_groups = null;
        protected $plugin = 'advanced-custom-fields-pro';
    
        public function __construct() {
            /*************************  product and coupon template for acf    ***************************************/
        	add_action( 'wcmp_afm_after_product_excerpt_metabox_panel', array($this, 'Advance_custom_fields_panel_for_vendor' ) );
    		
            add_action( 'wcmp_afm_add_coupon_form_end', array($this, 'Advance_custom_fields_panel_for_vendor' ) );
        	/****************************** Save Coupon and product field data *********************************************************************************/  
    		add_action( 'wcmp_process_product_object', array($this, 'advance_custom_fields_save'), 20 );
            add_action( 'wcmp_afm_before_coupon_post_update', array($this, 'advance_custom_fields_save') );
    
        }
    
        public function set_props( $id ) {
    		$this->id = $id;
    		//after setting id get the WC product object
            $this->product = wc_get_product( $this->id );
            $this->post_type = get_post_type( $this->id );
    		$this->field_groups = acf_get_field_groups(array(
            	'post_id' => $this->id, 
            	'post_type' => $this->post_type
    		
    			));
    			
        }
       /*************************  product  and coupon template for acf    ******************************************/
        public function Advance_custom_fields_panel_for_vendor(){
        	if ( ! empty( $this->field_groups ) && ! empty( $this->id ) && apply_filters( 'wcmp_support_advance_custom_fields', true ) ) {
        		foreach ( $this->field_groups as $field_group_index => $field_group ) {
        			if ( ! empty( acf_get_fields( $field_group['ID'] ) ) ) {
                        afm()->template->get_template( 'products/acf/html-acf-fields.php', array( 'id' => $this->id, 'self' => $this, 'product' => $this->product, 'field_group' => $field_group ) );
                    }
        		}
        	}
        }
    
        /****************************** Save Coupon and product field data *********************************************************************************/  
        public function advance_custom_fields_save(){
            if( isset( $_POST['acf'] ) ){
                foreach ($_POST['acf'] as $key => $value) {
                    $google_map_address = json_decode( wp_unslash($value), true );
                    $get_field_key = get_field_object($key, $_POST['post_ID'] );
                    update_post_meta( $_POST['post_ID'], $get_field_key['_name'] , $value );
                    if( $google_map_address ){
                        update_post_meta( $_POST['post_ID'], $get_field_key['_name'] , $google_map_address);
                    }
                }
            }
        }
    
    }

    I hope someone have time to look this and help me to solve this problem 🙂

  • Sorry this is code where need hook for custom product category

    if ( ! empty( acf_get_fields( $field_group['ID'] ) && ! empty( $id ) ) ) {
    	foreach ( acf_get_fields( $field_group['ID'] ) as $field_group_field ) {
    		acf_form_head();
    		$display_fields_post = apply_filters( 'acf_fields_display_wcmp_post', array(
    			'post_id' => $id, // Unique identifier for the form
    			'field_groups' => array( $field_group['ID'] ) ,  // Create post field group ID(s)
    			'form' => false,
    			'return' => '%post_url%' , // Redirect to new post url
    			'fields' => array( $field_group_field['ID'] ),
    			'uploader' => 'wp',
    			), $field_group['ID'] , $field_group_field['ID'] );
    		// Display acf fields at vendor dashboard
    		acf_form( $display_fields_post);	
    	}
    }

    Need to can get different Fields on different Product Category

    Thank you

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.