Created
December 10, 2019 12:55
-
-
Save AshlinRejo/232ebb181e4d5e5578d1a1ed6e07e217 to your computer and use it in GitHub Desktop.
J2Store Booking: For Pre-fill the person fields from URL data
This file contains 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
<?php | |
/** | |
* For preload the person value from the request URL | |
* Copy this and do an override in the path [SITE_TEMPLATE_PATH]/html/plugins/j2store/app_booking/number.php | |
* */ | |
defined('_JEXEC') or die; | |
if(is_array($vars->field)){ | |
$vars->field = \Joomla\Utilities\ArrayHelper::toObject($vars->field); | |
} | |
if(in_array('bookings_field_duration', (array)$vars->field->class)){ | |
$vars->field->class[] = 'j2store_booking_hide'; | |
} | |
$app = JFactory::getApplication(); | |
$field_value = ( ! empty( $vars->field->min ) ) ? $vars->field->min : 0; | |
$field_value_from_url = $app->input->get($vars->field->name, ''); | |
if(!empty($field_value_from_url)){ | |
$field_value = $field_value_from_url; | |
} | |
?> | |
<p class="form-field form-field-wide booking_fields <?php echo implode( ' ', (array)$vars->field->class ); ?>"> | |
<label for="<?php echo $vars->field->name; ?>"><?php echo isset($vars->field->label) ? $vars->field->label: ''; ?>:</label> | |
<input class="booking_fields_number" | |
type="number" | |
value="<?php echo $field_value; ?>" | |
step="<?php echo ( isset( $vars->field->step ) ) ? $vars->field->step : ''; ?>" | |
min="<?php echo ( isset( $vars->field->min ) ) ? $vars->field->min : ''; ?>" | |
max="<?php echo ( isset( $vars->field->max ) ) ? $vars->field->max : ''; ?>" | |
name="<?php echo $vars->field->name; ?>" | |
id="<?php echo $vars->field->name; ?>" | |
/> <?php echo ( ! empty( $vars->field->after ) ) ? $vars->field->after : ''; ?> | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment