How to get vendor location by code?

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!

Tagged: ,

Viewing 1 reply thread
  • Author
    Posts
    • #75913
      simon.stekler
      Participant

      I want to do some customization and would need to echo the city, but get_address_string(); gives the whole address. I just need the city.

      I want to do this in wcfmmp-view-store-lists-card.php

      Thanks.

    • #76216
      WCFM Forum
      Member

      hi,

      Please check this function. There is a filter, so you may modify this returned address string –

      public function get_address_string() {
      		$vendor_data = $this->shop_data;
      		$address = isset( $vendor_data['address'] ) ? $vendor_data['address'] : '';
      		$addr_1  = isset( $vendor_data['address']['street_1'] ) ? $vendor_data['address']['street_1'] : '';
      		$addr_2  = isset( $vendor_data['address']['street_2'] ) ? $vendor_data['address']['street_2'] : '';
      		$city    = isset( $vendor_data['address']['city'] ) ? $vendor_data['address']['city'] : '';
      		$zip     = isset( $vendor_data['address']['zip'] ) ? $vendor_data['address']['zip'] : '';
      		$country = isset( $vendor_data['address']['country'] ) ? $vendor_data['address']['country'] : '';
      		$state   = isset( $vendor_data['address']['state'] ) ? $vendor_data['address']['state'] : '';
      		
      		// Country -> States
      		$country_obj   = new WC_Countries();
      		$countries     = $country_obj->countries;
      		$states        = $country_obj->states;
      		$country_name  = '';
      		$state_name    = '';
      		if( $country ) $country_name = $country;
      		if( $state ) $state_name = $state;
      		if( $country && isset( $countries[$country] ) ) {
      			$country_name = $countries[$country];
      		}
      		if( $state && isset( $states[$country] ) && is_array( $states[$country] ) ) {
      			$state_name = isset($states[$country][$state]) ? $states[$country][$state] : '';
      		}
      		
      		$store_address = '';
      		if( $addr_1 ) $store_address .= $addr_1 . ", ";
      		if( $addr_2 ) $store_address .= $addr_2 . ", ";
      		if( $city ) $store_address .= $city . ", ";
      		if( $state_name ) $store_address .= $state_name;
      		if( $country_name ) $store_address .= " " . $country_name;
      		if( $zip ) $store_address .= " - " . $zip;
      	
      		return apply_filters( 'wcfmmp_store_address_string', $store_address, $vendor_data );
      		
      	}

      Thank You

Viewing 1 reply thread
  • You must be logged in to reply to this topic.