Advertisement
palsushobhan

Store-address-below-badge

Apr 29th, 2024
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. add_action('wcfmmp_sold_by_label_product_page_after', function($vendor_id) {
  2.     if(!is_product()) return;
  3.     $store_user = wcfmmp_get_store( $vendor_id );
  4.     $address  = $store_user->get_address_string();
  5.     $store_info = $store_user->get_shop_info();
  6.     $store_lat    = isset( $store_info['store_lat'] ) ? esc_attr( $store_info['store_lat'] ) : 0;
  7.     $store_lng    = isset( $store_info['store_lng'] ) ? esc_attr( $store_info['store_lng'] ) : 0;
  8.     if( $address && ( $store_info['store_hide_address'] == 'no' ) && wcfm_vendor_has_capability( $store_user->get_id(), 'vendor_address' ) ) { ?>
  9.         <p class="wcfmmp_store_header_address">
  10.           <i class="wcfmfa fa-map-marker" aria-hidden="true"></i>
  11.           <?php if( apply_filters( 'wcfmmp_is_allow_address_map_linked', true ) ) {
  12.               $map_search_link = 'https://google.com/maps/place/' . rawurlencode( $address ) . '/@' . $store_lat . ',' . $store_lng . '&z=16';
  13.               if( wcfm_is_mobile() || wcfm_is_tablet() ) {
  14.                   $map_search_link = 'https://maps.google.com/?q=' . rawurlencode( $address ) . '&z=16';
  15.               }
  16.               ?>
  17.             <a href="<?php echo esc_url($map_search_link); ?>" target="_blank"><span><?php echo esc_attr($address); ?></span></a>
  18.           <?php } else { ?>
  19.                 <?php echo esc_attr($address); ?>
  20.             <?php } ?>
  21.         </p>
  22.     <?php }
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement