Last active
October 15, 2018 12:49
-
-
Save btribouillet/0aa2607f7ad9b8465b4c4c215c14a0cd to your computer and use it in GitHub Desktop.
Set timeslot in checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ALTERNATIVE | |
/** | |
* Force timeslot in checkout | |
*/ | |
$('#jckwds-delivery-time').on('change', function() { | |
if(php_vars.selected_timeslot !== typeof undefined) { | |
$(this).val(php_vars.selected_timeslot); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set timeslot in checkout | |
* | |
* @param $field_data | |
* @return mixed | |
*/ | |
public static function set_timeslot( $field_data ) { | |
$location = Vmm_Helpers::get_location(); | |
if( isset( $location['date'] ) && isset( $location['timeslot'] ) ) { | |
if ( isset( $field_data['field_args']['class'] ) && in_array( 'jckwds-delivery-date', $field_data['field_args']['class'] ) ) { | |
$date = date( 'd/m/Y', strtotime( $location['date'] ) ); | |
$field_data['value'] = $date; | |
} | |
if( $field_data['field_args']['type'] === 'hidden' && $field_data['field_args']['label'] === 'Date de livraison' ) { | |
$field_data['value'] = $location['date']; | |
} | |
if ( isset( $field_data['field_args']['class'] ) && in_array( 'jckwds-delivery-time', $field_data['field_args']['class'] ) ) { | |
$field_data['value'] = $location['timeslot']; | |
} | |
} | |
return $field_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment