• Resolved sous.studio

    (@sousstudio)


    Hey! I also get “range(): step exceeds the specified range reopen: like Nigel here. My question is how do you expect range function to correctly return distance between XXam and XXpm? It’s not like one of them comes first, programmatically speaking.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP Scripts

    (@wpscripts)

    Hello,

    This is one of the issues users face sometimes, but we were absolutely unable to recreate the issue or the scenario under which this issue is happening.

    Sometimes, just updating the store times fix it for users, sometimes, it never happens automatically.

    An idle condition will be both the store open and close time should belong to the same day, stating from 00:00 to 23:59. And Close time should always be greater to open time. Try updating the setting page as well as the timezone once or twice and do let us know if that fixes for you. Otherwise please create a ticket at support.wpscripts.in.

    Thanks & Regards,
    Team WP Scripts

    Thread Starter sous.studio

    (@sousstudio)

    Hi,

    Well, your answer with inability to recreate the issue has motivated me to try. I have discovered the problem. Suppose user intentionally removed “Delivery Time Interval” (could happen for one reason or another). Then, this function in wfs-core-functions.php:

    673:function wfs_get_service_time_interval( $service ) {
    
      $service_interval = get_option( '_wfs_'.$service.'_time_interval', 0 );
      $service_interval  = intval( $service_interval ) * 60;
      
      return $service_interval;
    }

    Doesn’t return the proper value – intval(null) * 60 = 0. This in turn causes range() in this function:

    function wfs_get_store_timing( $service_type ) {
      ..  
      $pickup_interval    = wfs_get_service_time_interval( 'pickup' );
      $delivery_interval  = wfs_get_service_time_interval( 'delivery' );
      ..
      if ( $service_type == 'delivery' ) {
        if( ( $close_time - $open_time ) > $delivery_interval )
          $store_timings = range( $open_time, $close_time, $delivery_interval );
      } else {
        if( ( $close_time - $open_time ) > $pickup_interval )
          $store_timings = range( $open_time, $close_time, $pickup_interval );
      }

    to turns into $store_timings = range(“11:00”, “12:00”, 0), and since step cannot be 0, we get the aforementioned error.

    Suggested fix
    Our proposal is to add simple check to wfs_get_service_time_interval() function, that would insure the value is never 0:

    675:  $service_interval = get_option( '_wfs_'.$service.'_time_interval', 0 );
      if (!is_numeric($service_interval)) $service_interval = 30; // set it to 30
      $service_interval  = intval( $service_interval ) * 60;

    We set it 30, because 0 would cause an error, and 1 would turn times into 1 minute-stepped intervals, instead of showing “Slots unavailable for selected Date!”, when such situation occurs.

    Another way to fix it would be some sort of javascript/jQuery code that would check and/or adjust the value, if it goes blank.

    Third way would be to check the value upon updating the database, but it seems like it requires substantial code modifications.

    NOTE: Similar problem must probably take place when using pickup_interval instead of delivery, though I haven’t tested it.

    Hope it helps!

    Plugin Author WP Scripts

    (@wpscripts)

    Hello,

    Thanks for your suggestion. We are looking into the issue and if possible we will release a hotfix for this issue.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘range(): step exceeds the specified range reopen’ is closed to new replies.