add_action( 'mvx_after_shop_front', 'extra_delivery_express' );
function extra_delivery_express() {
global $MVX;
$vendor_id = get_current_vendor_id();
$vendor_delivery_express = '';
$vendor_delivery_express = get_user_meta($vendor_id, '_vendor_delivery_express', true) ? get_user_meta($vendor_id, '_vendor_delivery_express', true) : $vendor_delivery_express;
$express_delivery_hour_vendor = '';
$express_delivery_hour_vendor = get_user_meta($vendor_id,'global_ex_hour_vendor' );
?>
<div class="panel panel-default pannel-outer-heading">
<div class="panel-heading d-flex">
<h3><?php _e('', 'multivendorx'); ?></h3>
</div>
<div class="panel-body panel-content-padding form-horizontal">
<div class="mvx_media_block">
<div class="form-group">
<label class="control-label col-sm-3 col-md-3" for="_vendor_delivery_express"></label>
<div class="col-md-6 col-sm-9">
<input type="hidden" name="_vendor_delivery_express" value="no">
<input type="checkbox" id="myCheck" onclick="myFunction()" name="_vendor_delivery_express" value="yes" <?php echo ($vendor_delivery_express=='yes' ? 'checked' : '');?>>
</div>
</div>
<div class="form-group" id="text" style="" >
<label class="control-label col-sm-3 col-md-3"></label>
<div class="col-md-6 col-sm-9">
<select name="global_ex_hour_vendor" class="form-control" value="">
<option selected value=""> — выберите количество часов — </option>
<?php if($express_delivery_hour_vendor){?>
<option selected value="<?php echo $express_delivery_hour_vendor; ?>"><?php echo $express_delivery_hour_vendor; ?></option>
<?php }
?>
<option>1 час</option>
<option>2 часа</option>
<option>3 часа</option>
<option>4 часа</option>
<option>6 часов</option>
</select>
</div>
</div>
</div>
</div>
</div>
<script>
function myFunction() {
var checkBox = document.getElementById("myCheck");
var text = document.getElementById("text");
if (checkBox.checked == true){
text.style.display = "block";
text2.style.display = "block";
} else {
text.style.display = "none";
text2.style.display = "none";
}
}
</script>
<?php
}
//save the field in database
add_action('mvx_save_custom_store', 'save_field_delivery_express', 10, 1);
function save_field_delivery_express($user_id){
$vendor_delivery_express = $_POST['_vendor_delivery_express'];
update_user_meta($user_id, '_vendor_delivery_express', $vendor_delivery_express);
//?? как сохранить значение для $express_delivery_hour_vendor
}
//save the field in database
add_action('mvx_save_custom_store', 'save_field_delivery_express', 10, 1);
function save_field_delivery_express($user_id){
$vendor_delivery_express = $_POST['_vendor_delivery_express'];
update_user_meta($user_id, '_vendor_delivery_express', $vendor_delivery_express);
$express_delivery_hour_vendor = isset($_POST['global_ex_hour_vendor']) ? sanitize_text_field($_POST['global_ex_hour_vendor']) : '';
update_user_meta($user_id,'global_ex_hour_vendor', $express_delivery_hour_vendor);
}