Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode('wcfm_store_distance', function() {
- global $product, $WCFMmp;
- if( !$product || !method_exists( $product, 'get_id' ) ) return;
- $store_id = wcfm_get_vendor_id_by_post($product->get_id());
- if(!$store_id) return;
- if ( apply_filters( 'wcfmmp_is_allow_checkout_user_location', true ) && apply_filters( 'wcfm_is_allow_store_list_distance', true ) ) {
- $distance = wcfmmp_get_user_vendor_distance( $store_id );
- $radius_unit = isset( $WCFMmp->wcfmmp_marketplace_options['radius_unit'] ) ? $WCFMmp->wcfmmp_marketplace_options['radius_unit'] : 'km';
- if( $distance ) {
- ?>
- <span class="store-distance">
- <i class="wcfmfa fa-map-marker-alt" aria-hidden="true"></i> <?php echo $distance . ' ' . $radius_unit . ' ' . __( 'away', 'wc-multivendor-marketplace' ); ?>
- </span>
- <?php
- }
- }
- });
- add_shortcode('wcfm_store_operating_hours', function() {
- global $product;
- if( !$product || !method_exists( $product, 'get_id' ) ) return;
- $store_id = wcfm_get_vendor_id_by_post($product->get_id());
- if(!$store_id) return;
- if( apply_filters( 'wcfm_is_pref_store_hours', true ) && $store_id && wcfm_is_vendor( $store_id ) ) {
- $wcfm_vendor_store_hours = get_user_meta( $store_id, 'wcfm_vendor_store_hours', true );
- if( !$wcfm_vendor_store_hours || !isset($wcfm_vendor_store_hours['enable']) || $wcfm_vendor_store_hours['enable']!=='yes') {
- return;
- }
- $todays_number = date('N') - 1;
- $wcfm_store_hours_off_days = isset( $wcfm_vendor_store_hours['off_days'] ) ? $wcfm_vendor_store_hours['off_days'] : array();
- if(!empty($wcfm_store_hours_off_days) && in_array($todays_number, $wcfm_store_hours_off_days)) {
- return;
- }
- $wcfm_store_hours_day_times = isset( $wcfm_vendor_store_hours['day_times'] ) ? $wcfm_vendor_store_hours['day_times'] : array();
- if( empty( $wcfm_store_hours_day_times[$todays_number] )) return;
- $todays_slots = $wcfm_store_hours_day_times[$todays_number];
- $time_html = '';
- foreach( $todays_slots as $time_slot ) {
- if( empty( $time_slot['start'] ) || empty( $time_slot['end'] ) ) continue;
- $time_html .= '<br />'. date_i18n( wc_time_format(), strtotime( $time_slot['start'] ) ) . " - " . date_i18n( wc_time_format(), strtotime( $time_slot['end'] ) );
- }
- if($time_html) {
- ?>
- <div class="wcfmmp_store_hours">
- <span class="wcfmmp-store-hours widget-title"><span class="wcfmfa fa-clock"></span> <?php echo date('l'); ?>:</span>
- <?php echo $time_html; ?>
- </div>
- <?php
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement