Changeset 1028129
- Timestamp:
- 11/18/2014 05:59:44 PM (11 years ago)
- Location:
- woocommerce-local-pickup-time-select/trunk
- Files:
-
- 4 edited
-
admin/class-local-pickup-time-admin.php (modified) (1 diff)
-
public/class-local-pickup-time.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
woocommerce-local-pickup-time.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-local-pickup-time-select/trunk/admin/class-local-pickup-time-admin.php
r963946 r1028129 240 240 'desc_tip' => true, 241 241 'options' => array( 242 '5' => __( '5 minutes', $this->plugin_slug ), 243 '10' => __( '10 minutes', $this->plugin_slug ), 242 244 '15' => __( '15 minutes', $this->plugin_slug ), 245 '20' => __( '20 minutes', $this->plugin_slug ), 243 246 '30' => __( '30 minutes', $this->plugin_slug ), 247 '45' => __( '45 minutes', $this->plugin_slug ), 244 248 '60' => __( '1 hour', $this->plugin_slug ), 249 '120' => __( '2 hours', $this->plugin_slug ), 250 ) 251 ), 252 array( 253 'title' => __( 'Pickup Time Delay', $this->plugin_slug ), 254 'desc' => __( 'Choose the time delay from the time of ordering for allowing local pickup orders.', $this->plugin_slug ), 255 'id' => 'local_pickup_delay_minutes', 256 'css' => 'width:100px;', 257 'default' => '60', 258 'type' => 'select', 259 'class' => 'chosen_select', 260 'desc_tip' => true, 261 'options' => array( 262 '5' => __( '5 minutes', $this->plugin_slug ), 263 '10' => __( '10 minutes', $this->plugin_slug ), 264 '15' => __( '15 minutes', $this->plugin_slug ), 265 '20' => __( '20 minutes', $this->plugin_slug ), 266 '30' => __( '30 minutes', $this->plugin_slug ), 267 '45' => __( '45 minutes', $this->plugin_slug ), 268 '60' => __( '1 hour', $this->plugin_slug ), 269 '120' => __( '2 hours', $this->plugin_slug ), 270 ) 271 ), 272 array( 273 'title' => __( 'Pickup Time Days Ahead', $this->plugin_slug ), 274 'desc' => __( 'Choose the number of days ahead for allowing local pickup orders.', $this->plugin_slug ), 275 'id' => 'local_pickup_days_ahead', 276 'css' => 'width:100px;', 277 'default' => '1', 278 'type' => 'select', 279 'class' => 'chosen_select', 280 'desc_tip' => true, 281 'options' => array( 282 '1' => __( '1 day', $this->plugin_slug ), 283 '2' => __( '2 days', $this->plugin_slug ), 284 '3' => __( '3 days', $this->plugin_slug ), 285 '4' => __( '4 days', $this->plugin_slug ), 286 '5' => __( '5 days', $this->plugin_slug ), 287 '6' => __( '6 days', $this->plugin_slug ), 288 '7' => __( '7 days', $this->plugin_slug ), 289 '8' => __( '8 days', $this->plugin_slug ), 290 '9' => __( '9 days', $this->plugin_slug ), 291 '10' => __( '10 days', $this->plugin_slug ), 245 292 ) 246 293 ), -
woocommerce-local-pickup-time-select/trunk/public/class-local-pickup-time.php
r963946 r1028129 26 26 * @var string 27 27 */ 28 const VERSION = '1. 0.3';28 const VERSION = '1.2.0'; 29 29 30 30 /** … … 272 272 } 273 273 274 // Setup time variables for calculations275 $one_hour_later_hour = date( 'H', strtotime( "+1 hour" ) );276 $one_hour_later_minute = date( 'i', strtotime( "+1 hour" ) );277 $two_hour_later_hour = date( 'H', strtotime( "+2 hours" ) );278 $today_name = strtolower( date( 'l' ) );279 $today_date = date( 'm/d/Y' );280 281 274 // Get days closed textarea from settings, explode into an array 282 275 $closing_days_raw = trim( get_option( 'local_pickup_hours_closings' ) ); … … 284 277 $closing_days = array_filter( $closing_days, 'trim' ); 285 278 286 // Get today's opening and closing times 287 $open_time = get_option( 'local_pickup_hours_' . $today_name . '_start', '10:00' ); 288 $close_time = get_option( 'local_pickup_hours_' . $today_name . '_end', '19:00' ); 289 290 // Get pickup interval 279 // Get delay, interval, and number of days ahead settings 280 $delay_minutes = get_option( 'local_pickup_delay_minutes', 60 ); 291 281 $interval = get_option( 'local_pickup_hours_interval', 30 ); 292 293 // Setup start and end times for pickup options 294 $pickup_time_begin = ( $one_hour_later_minute < $interval ) ? $one_hour_later_hour . ":$interval" : $two_hour_later_hour . ":00"; 295 296 $start_time = ( strtotime( $pickup_time_begin ) < strtotime( $open_time ) ) ? $open_time : $pickup_time_begin; 297 298 // Today 299 $tStart = strtotime( $start_time ); 300 $tEnd = strtotime( $close_time ); 301 $tNow = $tStart; 302 $current_time = time(); 303 304 $pickup_options = ''; 305 306 // If Closed today or today's pickup times are over, don't allow a pickup option 307 if ( in_array( $today_date, $closing_days ) || $current_time >= $tEnd ) { 308 // Set drop down text to let user know store is closed 309 $pickup_options['closed_today'] = __( 'Closed today, please check back tomorrow!', $this->plugin_slug ); 310 311 // Hide Order Review so user doesn't order anything today 312 remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); 313 } 314 else { 315 // Create array of time options to return to woocommerce_form_field 316 while( $tNow <= $tEnd ){ 317 $option_key = date( "l_h_i", $tNow ); 318 $option_value = 'Today ' . date( "g:i", $tNow ); 319 320 $pickup_options[$option_key] = $option_value; 321 322 $tNow = strtotime( "+$interval minutes", $tNow ); 282 $num_days_allowed = get_option( 'local_pickup_days_ahead', 1 ); 283 284 // Setup time variables for calculations 285 $delay_ahead_hour = date( 'H', strtotime( "+$delay_minutes minutes" ) ); 286 $delay_ahead_minute = date( 'i', strtotime( "+$delay_minutes minutes" ) ); 287 $double_delay_ahead_hour = date( 'H', strtotime( "+2 hours" ) ); 288 $today_name = strtolower( date( 'l' ) ); 289 $today_date = date( 'm/d/Y' ); 290 291 // Create an empty array for our dates 292 $pickup_options = array(); 293 294 // Loop through all days ahead and add the pickup time options to the array 295 for ( $i = 0; $i < $num_days_allowed; $i++ ) { 296 297 // Get the date of current iteration 298 $current_day_name = date( 'l', strtotime( "+$i days" ) ); 299 $current_day_name_lower = strtolower( $current_day_name ); 300 301 // Get the day's opening and closing times 302 $open_time = get_option( 'local_pickup_hours_' . $current_day_name_lower . '_start', '10:00' ); 303 $close_time = get_option( 'local_pickup_hours_' . $current_day_name_lower . '_end', '19:00' ); 304 305 // Setup start and end times for pickup options 306 $pickup_time_begin = ( $delay_ahead_minute < $interval ) ? $delay_ahead_hour . ":$interval" : $double_delay_ahead_hour . ":00"; 307 308 $start_time = ( strtotime( $pickup_time_begin ) < strtotime( $open_time ) ) ? $open_time : $pickup_time_begin; 309 310 // Today 311 $tStart = strtotime( $start_time ); 312 $tEnd = strtotime( $close_time ); 313 $tNow = $tStart; 314 $current_time = time(); 315 316 // If Closed today or today's pickup times are over, don't allow a pickup option 317 if ( in_array( $today_date, $closing_days ) || $current_time >= $tEnd ) { 318 // Set drop down text to let user know store is closed 319 $pickup_options['closed_today'] = __( 'Closed today, please check back tomorrow!', $this->plugin_slug ); 320 321 // Hide Order Review so user doesn't order anything today 322 remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); 323 323 } 324 } 324 else { 325 // Create array of time options to return to woocommerce_form_field 326 while ( $tNow <= $tEnd ) { 327 328 $day_name = ( $i === 0 ) ? 'Today' : $current_day_name; 329 330 $option_key = $current_day_name . date( "_h_i", $tNow ); 331 $option_value = $day_name . ' ' . date( "g:i", $tNow ); 332 333 $pickup_options[$option_key] = $option_value; 334 335 $tNow = strtotime( "+$interval minutes", $tNow ); 336 } 337 } 338 339 } // end for loop 325 340 326 341 return $pickup_options; -
woocommerce-local-pickup-time-select/trunk/readme.txt
r979476 r1028129 5 5 Requires at least: 3.8 6 6 Tested up to: 4.0 7 Stable tag: 1. 1.07 Stable tag: 1.2.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 71 71 == Changelog == 72 72 73 = 1.2.0 = 74 * added option to select the delay from the current time until the order can be picked up 75 * added option to select the number of days ahead for allowing orders to be picked up 76 73 77 = 1.1.0 = 74 78 * added `local_pickup_time_select_location` filter to customize location of pickup time select during checkout -
woocommerce-local-pickup-time-select/trunk/woocommerce-local-pickup-time.php
r963946 r1028129 17 17 * Plugin URI: http://mattbanks.me 18 18 * Description: Add an an option to WooCommerce checkout pages for Local Pickup that allows the user to choose a pickup time. 19 * Version: 1. 1.019 * Version: 1.2.0 20 20 * Author: Matt Banks 21 21 * Author URI: http://mattbanks.me
Note: See TracChangeset
for help on using the changeset viewer.