zero price issue

This commit is contained in:
magepeopleteam 2021-02-09 05:57:05 +00:00
parent d689b10a69
commit efd24f7381
3 changed files with 77 additions and 3 deletions

View File

@ -441,7 +441,25 @@ if (!class_exists('MAGE_Events_Setting_Controls')) :
'type' => 'text',
'default' => 'Book Now',
'placeholder'=>'Book Now'
)
),
array(
'name' => 'mep_show_zero_as_free',
'label' => __( 'Show 0 Price as Free ?', 'mage-eventpress' ),
'desc' => __( 'If you want to show 0 Price as Free , Please select Yes.', 'mage-eventpress' ),
'type' => 'select',
'default' => 'yes',
'options' => array(
'yes' => 'Yes',
'no' => 'No'
)
),
)
),
@ -488,6 +506,14 @@ if (!class_exists('MAGE_Events_Setting_Controls')) :
),
'label_setting_sec' => apply_filters('mep_translation_string_arr',array(
array(
'name' => 'mep_free_price_text',
'label' => __( 'Free ?', 'mage-eventpress' ),
'desc' => __( 'Pleaase Type the text which you want to as 0 Price.', 'mage-eventpress' ),
'type' => 'text',
'default' => 'Free',
'placeholder'=>'Free'
),
array(
'name' => 'mep_event_ticket_type_text',
'label' => __('Ticket Type Table Label', 'mage-eventpress'),

View File

@ -135,6 +135,35 @@ class MP_Event_All_Info_In_One
<?php
}
public function is_gutenberg_active() {
$gutenberg = false;
$block_editor = false;
if ( has_filter( 'replace_editor', 'gutenberg_init' ) ) {
// Gutenberg is installed and activated.
$gutenberg = true;
}
if ( version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ) ) {
// Block editor.
$block_editor = true;
}
if ( ! $gutenberg && ! $block_editor ) {
return false;
}
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( ! is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
return true;
}
$use_block_editor = ( get_option( 'classic-editor-replace' ) === 'no-replace' );
return $use_block_editor;
}
public function mp_event_venue($post_id)
{
$event_label = mep_get_option('mep_event_label', 'general_setting_sec', 'Events');
@ -143,6 +172,11 @@ class MP_Event_All_Info_In_One
$map_type = mep_get_option('mep_google_map_type', 'general_setting_sec', 'iframe');
$mep_org_address = array_key_exists('mep_org_address', $values) ? $values['mep_org_address'][0] : 0;
$map_visible = array_key_exists('mep_sgm', $values) ? $values['mep_sgm'][0] : 0;
$author_id = get_post_field( 'post_author', $post_id );
if($this->is_gutenberg_active()) { ?>
<input type="hidden" name="post_author_gutenberg" value="<?php echo $author_id; ?>">
<?php }
?>
<table>
<tr>
@ -1163,6 +1197,8 @@ function mep_events_repeatable_meta_box_save($post_id)
add_action('save_post', 'mep_event_meta_save');
function mep_event_meta_save($post_id)
{
global $wpdb;
$table_name = $wpdb->prefix . "posts";
if (!isset($_POST['mep_event_ricn_text_nonce']) || !wp_verify_nonce($_POST['mep_event_ricn_text_nonce'], 'mep_event_ricn_text_nonce')) {
return;
@ -1189,6 +1225,10 @@ function mep_event_meta_save($post_id)
$more_end_time = isset($_POST['event_more_end_time']) ? $_POST['event_more_end_time'] : '';
$mdate = [];
if(isset($_POST['post_author_gutenberg'])) {
$wpdb->get_results( "UPDATE ".$table_name." SET post_author=".$_POST['post_author_gutenberg']." WHERE ID=".$pid );
}
$mcount = count($more_start_date);
for ($m = 0; $m < $mcount; $m++) {

View File

@ -3396,9 +3396,17 @@ function mep_get_price_including_tax( $event, $price, $args = array() ) {
}
add_filter( 'wc_price', 'mep_show_custom_text_for_zero_price', 10, 4 );
function mep_show_custom_text_for_zero_price( $return, $price, $args, $unformatted_price ){
$show_free_text = mep_get_option( 'mep_show_zero_as_free', 'general_setting_sec', 'yes');
if($unformatted_price == 0 && $show_free_text == 'yes'){
$return = mep_get_option( 'mep_free_price_text', 'label_setting_sec', __('Free','mage-eventpress'));
}
return $return;
}
function mep_check_ticket_type_availaility_before_checkout($event_id,$type,$date){
//echo $date;
function mep_check_ticket_type_availaility_before_checkout($event_id,$type,$date){
$args = array(
'post_type' => 'mep_events_attendees',
'posts_per_page' => -1,