DISPLAY VENDOR CITY, PROVINCE AND COUNTRY

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 WC Marketplace DISPLAY VENDOR CITY, PROVINCE AND COUNTRY

Viewing 1 reply thread
  • Author
    Posts
    • #88992
      karl.deligero
      Participant

      Hi,

      I see this code in the forum.

      add_filter( ‘wcfmmp_store_address_string’, function( $store_address, $vendor_data ) {
      $city = isset( $vendor_data[‘address’][‘city’] ) ? $vendor_data[‘address’][‘city’] : ”;
      return $city;
      }, 50, 2 );

      It’s working, but I want to show the City, Province and the country of the vendor. For example Makati City, Metro Manila Philippines.

      Thanks

    • #90865
      WCFM Forum
      Member

      HI,

      Please use this code –

      add_filter( 'wcfmmp_store_address_string', function( $store_address, $vendor_data ) {
        $address = isset( $vendor_data['address'] ) ? $vendor_data['address'] : '';
      	$city    = isset( $vendor_data['address']['city'] ) ? $vendor_data['address']['city'] : '';
      	$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( $city ) $store_address .= $city . ", ";
      	if( $state_name ) $store_address .= $state_name;
      	if( $country_name ) $store_address .= " " . $country_name;
      	
      	$store_address = str_replace( '"', '"', $store_address );
      
      	return $store_address;
      }, 50, 2 );

      Thank You

Viewing 1 reply thread
  • The topic ‘DISPLAY VENDOR CITY, PROVINCE AND COUNTRY’ is closed to new replies.