Remove vendor location fields and reorder

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 – Ultimate Remove vendor location fields and reorder

Viewing 16 reply threads
  • Author
    Posts
    • #123192
      Henriette
      Participant

      Hi,
      I would like to remove Street 2 and Country from vendor dashboard > Location.
      Also I would like to have Postcode first and than City/Town. Is this possible?

      Also I can not reply to another topic on this forum.

      Please see attachments.
      Thank you.

      Attachments:
      You must be logged in to view attached files.
    • #123204
      Sushobhan
      Keymaster

      Hello,
      Try the following snippet-

      add_filter( 'wcfm_marketplace_settings_fields_address', function( $fields ) {
          if ( ! current_user_can( 'administrator' ) ) {
              $shuffled_fields = array();
              if ( isset( $fields['street_1'] ) ) $shuffled_fields['street_1'] = $fields['street_1'];
              if ( isset( $fields['zip'] ) ) $shuffled_fields['zip'] = $fields['zip'];
              if ( isset( $fields['city'] ) ) $shuffled_fields['city'] = $fields['city'];
              if ( isset( $fields['state'] ) ) $shuffled_fields['state'] = $fields['state'];
              if ( isset( $fields['country'] ) ) {
                  $shuffled_fields['country'] = $fields['country'];
                  $shuffled_fields['country']['type'] = 'hidden';
              }
              return $shuffled_fields;
          }
          return $fields;
      }, 10 );

      Add this code to your child theme’s functions.php
      In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
      Let me know how this goes.
      Thanks!

    • #123247
      SebastianFloKa
      Participant

      Hi Sushobhan,

      do you also know how to move the postal code upfront the town on the store page of a vendor?
      https://wclovers.com/forums/topic/move-position-of-postal-code/
      Thank you.

      • #123652
        Sushobhan
        Keymaster

        Hi,
        You can try using the following snippet-

        add_filter( 'wcfmmp_store_address_string', function( $store_address, $vendor_data ) {
            $address = array();
            if ( ! empty( $vendor_data['address'] ) ) {
                if ( isset( $vendor_data['address']['street_1'] ) ) $address[] = $vendor_data['address']['street_1'];
                if ( isset( $vendor_data['address']['street_2'] ) ) $address[] = $vendor_data['address']['street_2'];
                if ( isset( $vendor_data['address']['zip'] ) ) $address[] = $vendor_data['address']['zip'];
                if ( isset( $vendor_data['address']['city'] ) ) $address[] = $vendor_data['address']['city'];
                if ( isset( $vendor_data['address']['state'] ) ) $address[] = $vendor_data['address']['state'];
                if ( isset( $vendor_data['address']['country'] ) ) $address[] = $vendor_data['address']['country'];
            }
            return implode( ', ', array_filter( $address ) );
        }, 10, 2 );

        Add this code to your child theme’s functions.php
        In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
        Let me know how this goes.
        Thanks!

    • #123269
      Henriette
      Participant

      Unfortunately that does not work. It doesn’t change anything in Vendor Dashboard.
      Also I don’t need State. Only:

      Street 1
      Postcode
      City

    • #123272
      SebastianFloKa
      Participant

      I checked and it changes only on the page during the registration process of a vendor.
      Why do you want to have the postal code etc. changed on the dahboard and not on the store page of a vendor or on the invoices etc., where it’s much more visible to many more people (customers)? As my request is…

    • #123274
      Henriette
      Participant

      Why do you want to have the postal code etc. changed on the dahsboard and not on the store page of a vendor or on the invoices etc

      Everything that Vendor fills in in his dashboard > Location is visible on his store page when you activate widget in the side bar.
      If he doesn’t fill a field than that field is not visible on his storefront except for Country. But vendor doesn’t know that so the street 2 field is confusing.
      Also I don’t need Country visible at storefront because I will be having only vendors from my own country.

      Plus the order of address in my country is:
      Street
      Postcode
      City

      Other info you can create with Store Invoice.

    • #123650
      Sushobhan
      Keymaster

      @Henriette, the purpose of the last snippet was-

      1. remove Street 2 and Country from vendor dashboard > Location.

      2. bring Postcode first and than City/Town

      And it does just that. But as you mentioned in your last message that you want to hide state field as well from Vendor settings >> location and make it consistent with the store page; so here is the updated snippet (kindly remove the older one)-

      add_filter( 'wcfm_marketplace_settings_fields_address', function( $fields ) {
          if ( ! current_user_can( 'administrator' ) ) {
              $shuffled_fields = array();
              if ( isset( $fields['street_1'] ) )
                  $shuffled_fields['street_1'] = $fields['street_1'];
              if ( isset( $fields['zip'] ) )
                  $shuffled_fields['zip'] = $fields['zip'];
              if ( isset( $fields['city'] ) )
                  $shuffled_fields['city'] = $fields['city'];
              if ( isset( $fields['state'] ) ) {
                  $shuffled_fields['state'] = $fields['state'];
                  $shuffled_fields['state']['type'] = 'hidden';
              }
              if ( isset( $fields['country'] ) ) {
                  $shuffled_fields['country'] = $fields['country'];
                  $shuffled_fields['country']['type'] = 'hidden';
              }
              return $shuffled_fields;
          }
          return $fields;
      }, 10 );
      
      add_filter( 'wcfmmp_store_address_string', function( $store_address, $vendor_data ) {
          $address = array();
          if ( ! empty( $vendor_data['address'] ) ) {
              if ( isset( $vendor_data['address']['street_1'] ) ) $address[] = $vendor_data['address']['street_1'];
              if ( isset( $vendor_data['address']['zip'] ) ) $address[] = $vendor_data['address']['zip'];
              if ( isset( $vendor_data['address']['city'] ) ) $address[] = $vendor_data['address']['city'];
          }
          return implode( ', ', array_filter( $address ) );
      }, 10, 2 );

      Add this code to your child theme’s functions.php
      In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/ (more preferred option)
      Let me know how this goes.
      Thanks!

    • #123688
      SebastianFloKa
      Participant

      Hi,

      thank you, that’s almost exactly what I was looking for. Now it works also on the store page. Thanks.

      Only question: I tried to eliminate the “,” comma between ZIP and Town, because then it would be perfect. But I tried so much but doesn’t work – time for me to learn programming.

      If it’s simple, could you give a hint, please? If difficult, leafe it.
      Thanks again.

      • #123728
        Sushobhan
        Keymaster

        Hi SebastianFloka,
        No need to worry, I just made the modifications for you. Kindly use the following snippet instead-

        add_filter( 'wcfmmp_store_address_string', function( $store_address, $vendor_data ) {
            $address = array();
            if ( ! empty( $vendor_data['address'] ) ) {
                if ( isset( $vendor_data['address']['street_1'] ) ) $address[] = $vendor_data['address']['street_1'];
                if ( isset( $vendor_data['address']['street_2'] ) ) $address[] = $vendor_data['address']['street_2'];
                $postcode_city = '';
                if ( isset( $vendor_data['address']['zip'] ) ) $postcode_city = $vendor_data['address']['zip'];
                if ( isset( $vendor_data['address']['city'] ) ) $postcode_city .= " " . $vendor_data['address']['city'];
                if($postcode_city) $address[] = trim( $postcode_city );
                if ( isset( $vendor_data['address']['state'] ) ) $address[] = $vendor_data['address']['state'];
                if ( isset( $vendor_data['address']['country'] ) ) $address[] = $vendor_data['address']['country'];
            }
            return implode( ', ', array_filter( $address ) );
        }, 10, 2 );

        I can see the full smile now! πŸ™‚

    • #123699
      Henriette
      Participant

      Thank you Sushobhan, this is exactly what I meant. You Rock! πŸ˜€

      SebastianFloka it’s easy to replace the comma between address, zip, etc.
      Please look where you can change it in my attachments.

      Attachments:
      You must be logged in to view attached files.
    • #123704
      Henriette
      Participant

      @SebastianFloka you can even have it on separate lines.
      Please see attachment.

      Attachments:
      You must be logged in to view attached files.
    • #123727
      SebastianFloKa
      Participant

      thank you, but comma is great everywhere except between zip and town, if you know what I mean. Your modification changes everything, not only between zip and town.

    • #123730
      Henriette
      Participant

      Yes I know what you mean.
      Normally when you write in on one line in my country it is:
      Street, Postcode City

      or:

      Street
      Postcode City

      But having it on separate lines I don’t mind so much that postcode is also on a separate line πŸ™‚

      Street
      Postcode
      City

    • #123737
      Henriette
      Participant

      Hi SebastianFloka,
      No need to worry, I just made the modifications for you. Kindly use the following snippet instead-

      Oh my gosh Sushobhan you’re the best!

      I was already happy with the snippet you gave me and personally I would not have dare to ask for the function that Sebastian did hahaha.
      But now I’m completely happy πŸ™‚
      Thanks to you too Sebastian πŸ˜›

    • #123764
      Henriette
      Participant

      One more question please Sushobhan…

      I use Vendor address in store side bar for vendors who have a Local Pickup option.
      I would like to give them the option to not show the address when they don’t want Local Pickup.
      Vendor can choose not to enter the address fields in his dashboard so nothing shows op in the sidebar.
      But than still the Address header is visible.

      When I remove this with CSS all the other headers in the sidebar disappear too.
      Is it possible to hide the Address header when vendor doesn’t fill in anything in the Location fields in his dashboard and that it only pops up when vendor does fill in his location?

      Hiding only the total address header will be fine too.
      Customers can see that this is the store address without the header anyway.

      Attachments:
      You must be logged in to view attached files.
    • #123777
      Sushobhan
      Keymaster

      I use Vendor address in store side bar for vendors who have a Local Pickup option.

      Please tell me, how are you doing this? Is this a widget? Or via some custom code?
      Thank You!

    • #124030
      Henriette
      Participant

      Please tell me, how are you doing this? Is this a widget? Or via some custom code?

      Yes I do. In a widget with wcfm short code.
      But never mind.
      I thought the widget title was required but it turns out you just can leave it blank and save.
      Than the header is not showing.

      Thank you

      Attachments:
      You must be logged in to view attached files.
    • #124258
      Sushobhan
      Keymaster

      Great.. Thanks for the update! πŸ™‚

Viewing 16 reply threads
  • You must be logged in to reply to this topic.