remove vat field for one of the type of memberships

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Membership remove vat field for one of the type of memberships

  • This topic has 13 replies, 2 voices, and was last updated 4 years ago by HM.
Viewing 12 reply threads
  • Author
    Posts
    • #121643
      HM
      Participant

      Hello
      my website is a multi vendor marketplace
      For my membership’s plans I have “particular vendor” so they don’t have a vat number but it’s a Required Field for the inscription for the other plans and I was wondering if you can tell me how just for the “particular ones” I can remove the vat field ?
      You can see it here :

      https://beantic.wpcomstaging.com/my-account/

      you need to scroll down a little

      and it’s for the last one

      with price of 4,99

    • #121666

      Hello,

      Add this code in your theme’s functions.php

      add_filter('wcfmu_settings_fields_vendor_store_invoice', 'wcfmu_settings_fields_vendor_store_invoice2204', 50, 2 );
      function wcfmu_settings_fields_vendor_store_invoice2204($general_fields,$vendor_id) {
      	$wcfm_vendor_invoice_data = (array) wcfm_get_user_meta( $vendor_id, 'wcfm_vendor_invoice_options', true );
      	$wcfm_vendor_invoice_storevat = isset( $wcfm_vendor_invoice_data['wcfm_vendor_invoice_storevat'] ) ? $wcfm_vendor_invoice_data['wcfm_vendor_invoice_storevat'] : '';
      	$current_plan = wcfm_get_membership();	
      	if(isset($current_plan) &&  ($current_plan != 153) ) { //replace 153 with "“particular ones" membership plan id
      		$general_fields['wcfm_vendor_invoice_storevat']= array('label' => __('Vat Number', 'wc-frontend-manager') , 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele','custom_attributes' => array( 'required' => 1 ), 'value' => $wcfm_vendor_invoice_storevat );
      	}
      	return $general_fields;
      }
      add_action( 'wcfm_wcfmmp_settings_update','fn_wcfm_vendor_settings_storetype_update2204', 50, 2);
      add_action( 'wcfm_vendor_settings_update','fn_wcfm_vendor_settings_storetype_update2204', 50, 2);
      function fn_wcfm_vendor_settings_storetype_update2204($user_id, $wcfm_settings_form ){	
      	$wcfm_settings_form_data_new = array();
      	$wcfm_vendor_invoice_data = (array) wcfm_get_user_meta( $user_id, 'wcfm_vendor_invoice_options', true );
      	parse_str($_POST['wcfm_settings_form'], $wcfm_settings_form_data_new);	
      	
      	if( isset( $wcfm_settings_form_data_new['wcfm_vendor_invoice_storevat'] ) ) {
      		$wcfm_vendor_invoice_data['wcfm_vendor_invoice_storevat'] = $wcfm_settings_form_data_new['wcfm_vendor_invoice_storevat'];
      		wcfm_update_user_meta( $user_id, 'wcfm_vendor_invoice_options',  $wcfm_vendor_invoice_data );
      	}
      
      }

      Thanks

    • #121796
      HM
      Participant

      Hello
      I have added the code but it’s not working
      It still show the vat number field (“Numéro de TVA” in french)
      You can try to create an account whith the membership priced 4,99 euros “ABONNEMENT POUR VENDEUR PARTICULIER” (last one on the right ) to see that
      Chose the last option of payement who is “transfère bancaire” you will pay nothing and the account will be created for you

      Attachments:
      You must be logged in to view attached files.
    • #121798
      HM
      Participant

      and the id here : if(isset($current_plan) && ($current_plan != 153) ) { //replace 153 with ““particular ones” membership plan id
      was the right one already

    • #121799
      HM
      Participant

      Can you fix that please ?

    • #121859

      Hello,

      We just checked your site. Do you talking about “vat number” in this page https://beantic.wpcomstaging.com/vendor-membership/?vmstep=registration?
      The above code was regarding “Store invoice” Vat number?
      Can you share us the screenshot how/from where you add this “Vat number” in vendor registration page? any custom coding?
      Then we will guide you specifically.

      Thanks.

    • #121897
      HM
      Participant

      Yes that’s right I have added it from the marketplace

      here two screenshots

      Attachments:
      You must be logged in to view attached files.
    • #121954

      Hello,

      Remove the custom field(VAT Number) which you have created from WCFM-settings.
      Try this code in your theme’s functions.php

      add_filter('wcfm_membership_registration_fields_address', 'wcfmu_settings_fields_vendor_store_invoice2204', 50);
      function wcfmu_settings_fields_vendor_store_invoice2204($general_fields) { 
          
        if(WC()->session->get('wcfm_membership') != 153)  {
          $general_fields['wcfm_vendor_invoice_storevat']= array('label' => __('Vat Number', 'wc-frontend-manager') , 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele','custom_attributes' => array( 'required' => 1 ), 'value' => '' );
        }
        return $general_fields;
      }
      add_action('wcfm_membership_registration','save_custom_vat_wcfm_membership_registration',10,2);
      add_action('wcfm_profile_update','save_custom_vat_wcfm_membership_registration',10,2);
      function save_custom_vat_wcfm_membership_registration($member_id, $wcfm_membership_registration_form_data) {
        //print_r($wcfm_membership_registration_form_data);
        if( isset($wcfm_membership_registration_form_data['wcfm_vendor_invoice_storevat']) ) {
         
          update_user_meta($member_id,'wcfm_vendor_invoice_storevat',$wcfm_membership_registration_form_data['wcfm_vendor_invoice_storevat']);
        } 
      }
      
      add_filter('wcfm_profile_fields_general','custom_field_wcfm_profile_fields_general',10,2);
      function custom_field_wcfm_profile_fields_general($general_fields,$member_id){
        $wcfm_vendor_invoice_storevat = !empty( get_user_meta($member_id,'wcfm_vendor_invoice_storevat',true) ) ? get_user_meta($member_id,'wcfm_vendor_invoice_storevat',true) : '';
        $current_plan = wcfm_get_membership();  
        if(isset($current_plan) && ($current_plan != 153) ) {
          $general_fields['wcfm_vendor_invoice_storevat']= array('label' => __('Vat Number', 'wc-frontend-manager') , 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele','custom_attributes' => array( 'required' => 1 ), 'value' => $wcfm_vendor_invoice_storevat );
        }
        return $general_fields;
      }

      Thanks.

    • #122018
      HM
      Participant
      This reply has been marked as private.
    • #122019
      HM
      Participant
      This reply has been marked as private.
    • #122804
      HM
      Participant
      This reply has been marked as private.
    • #122879

      Hello,

      Sorry, we didn’t get you. As per your earlier post your concern was “remove vat field for one of the type of memberships”.
      And we have provided you the solution, did that work for you?
      And it seems that this is your new query, so please create a new thread for new requirement.

      Thanks.

    • #122918
      HM
      Participant
      This reply has been marked as private.
Viewing 12 reply threads
  • You must be logged in to reply to this topic.