Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wcfmmp_local_pickup_shipping_option_label', function($label, $vendor_id) {
- if(!$vendor_id) return $label;
- $store_user = wcfmmp_get_store( $vendor_id );
- $store_address = $store_user->get_address();
- $addr_1 = isset( $store_address['street_1'] ) ? $store_address['street_1'] : '';
- $city = isset( $store_address['city'] ) ? $store_address['city'] : '';
- $state = isset( $store_address['state'] ) ? $store_address['state'] : '';
- $country = isset( $store_address['country'] ) ? $store_address['country'] : '';
- $country_obj = new WC_Countries();
- $countries = $country_obj->countries;
- $states = $country_obj->states;
- $country_name = '';
- $state_name = '';
- if( $state ) $state_name = $state;
- if( $country ) $country_name = $country;
- if( $state && isset( $states[$country] ) && is_array( $states[$country] ) ) {
- $state_name = isset($states[$country][$state]) ? $states[$country][$state] : '';
- }
- if( $country && isset( $countries[$country] ) ) {
- $country_name = $countries[$country];
- }
- $address = '';
- if( $addr_1 ) $address .= $addr_1 . ", ";
- if( $city ) $address .= $city . ", ";
- if( $state_name ) $address .= $state_name . ", ";
- if( $country_name ) $address .= $country_name;
- return preg_replace('/\((.+?)\)$/', "({$address})", $label);
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment