Error in snippet code – php
-
Hello all,
I had created a snippet code with an php in order o display in the store list the opening and close hours of the store.It worked fine for several days but suddently I am getting the error below :
Warning: Invalid argument supplied for foreach() in /home/customer/www/m……com/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(484) : eval()’d code on line 1
I provide you also the php code that I have in the snippet :
add_action('wcfmmp_store_list_after_store_info','fn_wcfmmp_store_list_after_store_info',11,2); function fn_wcfmmp_store_list_after_store_info($store_id, $store_info) { global $WCFM, $WCFMmp, $wp, $WCFM_Query; $store_user = wcfmmp_get_store( $store_id ); $wcfm_vendor_store_hours = get_user_meta( $store_id, 'wcfm_vendor_store_hours', true ); if( !$wcfm_vendor_store_hours ) { return; } $wcfm_store_hours_enable = isset( $wcfm_vendor_store_hours['enable'] ) ? 'yes' : 'no'; if( $wcfm_store_hours_enable != 'yes' ) return; $wcfm_store_hours_off_days = isset( $wcfm_vendor_store_hours['off_days'] ) ? $wcfm_vendor_store_hours['off_days'] : array(); $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 ) ) return; $weekdays = array( 0 => __( 'Monday', 'wc-multivendor-marketplace' ), 1 => __( 'Tuesday', 'wc-multivendor-marketplace' ), 2 => __( 'Wednesday', 'wc-multivendor-marketplace' ), 3 => __( 'Thursday', 'wc-multivendor-marketplace' ), 4 => __( 'Friday', 'wc-multivendor-marketplace' ), 5 => __( 'Saturday', 'wc-multivendor-marketplace' ), 6 => __( 'Sunday', 'wc-multivendor-marketplace') ); ?> <div class="wcfmmp_store_hours"> <span class="wcfmmp-store-hours widget-title"><span class="wcfmfa fa-clock"></span>Store Hours</span><div class="wcfm_clearfix"></div> <?php $day_number = date('w', time()); if($day_number == 0) { $day = 6; } else { $day = $day_number-1; } if(in_array($day, $wcfm_store_hours_off_days)){ foreach( $wcfm_store_hours_day_times[$day+1] as $wcfm_store_hours_day => $wcfm_store_hours_day_time_slots ) { if( in_array( $wcfm_store_hours_day, $wcfm_store_hours_day_times[$day+1] ) ) continue; if( !isset( $wcfm_store_hours_day_time_slots['start'] ) ) return; if( empty( $wcfm_store_hours_day_time_slots['start'] ) || empty( $wcfm_store_hours_day_time_slots['end'] ) ) continue; echo '<span class="wcfmmp-store-hours-day">' . $weekdays[$day+1] . ':</span>'; echo "<br />" . date_i18n( wc_time_format(), strtotime( $wcfm_store_hours_day_time_slots['start'] ) ) . " - " . date_i18n( wc_time_format(), strtotime( $wcfm_store_hours_day_time_slots['end'] ) ); echo '<br /><br />'; } } else { foreach( $wcfm_store_hours_day_times[$day] as $wcfm_store_hours_day => $wcfm_store_hours_day_time_slots ) { if( in_array( $wcfm_store_hours_day, $wcfm_store_hours_day_times[$day] ) ) continue; if( !isset( $wcfm_store_hours_day_time_slots['start'] ) ) return; if( empty( $wcfm_store_hours_day_time_slots['start'] ) || empty( $wcfm_store_hours_day_time_slots['end'] ) ) continue; echo '<span class="wcfmmp-store-hours-day">Today:</span>'; echo "<br />" . date_i18n( wc_time_format(), strtotime( $wcfm_store_hours_day_time_slots['start'] ) ) . " - " . date_i18n( wc_time_format(), strtotime( $wcfm_store_hours_day_time_slots['end'] ) ); echo '<br /><br />'; } } ?> </div> <?php }
Do you know how I could fix it ?
Thank you
- The topic ‘Error in snippet code – php’ is closed to new replies.