Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › How to get vendor location by code?
Tagged: marketplace, wcfm
- This topic has 1 reply, 2 voices, and was last updated 5 years, 3 months ago by WCFM Forum.
Viewing 1 reply thread
- AuthorPosts
- August 9, 2019 at 10:45 am #75913simon.steklerParticipant
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.
- August 12, 2019 at 9:06 am #76216WCFM ForumMember
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
- AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.