Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › DISPLAY VENDOR CITY, PROVINCE AND COUNTRY
Tagged: DISPLAY VENDOR CITY, PROVINCE AND COUNTRY
- This topic has 1 reply, 2 voices, and was last updated 5 years ago by WCFM Forum.
Viewing 1 reply thread
- AuthorPosts
- October 25, 2019 at 6:53 am #88992karl.deligeroParticipant
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
- November 5, 2019 at 7:49 pm #90865WCFM ForumMember
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
- AuthorPosts
Viewing 1 reply thread
- The topic ‘DISPLAY VENDOR CITY, PROVINCE AND COUNTRY’ is closed to new replies.