latest update

This commit is contained in:
magepeopleteam 2018-02-27 11:35:08 +00:00
parent 70a609db15
commit fd3dfce0e5
3 changed files with 142 additions and 7 deletions

View File

@ -1,17 +1,19 @@
<?php
if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
add_action( 'add_meta_boxes', 'mep_event_meta_box_add' );
function mep_event_meta_box_add(){
add_meta_box( 'mep-event-meta', 'Event Venue', 'mep_event_venue_meta_box_cb', 'mep_events', 'normal', 'high' );
add_meta_box( 'mep-event-price', 'Event Price', 'mep_event_price_meta_box_cb', 'mep_events', 'normal', 'high' );
add_meta_box( 'mep-event-extra-price', 'Event Extra Option Price', 'mep_event_extra_price_option', 'mep_events', 'normal', 'high' );
add_meta_box( 'mep-event-date', 'Event Date & Time', 'mep_event_date_meta_box_cb', 'mep_events', 'normal', 'high' );
}
function mep_event_venue_meta_box_cb($post){
$values = get_post_custom( $post->ID );
$user_api = mep_get_option( 'google-map-api', 'general_setting_sec', '');
@ -219,11 +221,73 @@ $values = get_post_custom( $post->ID );
function mep_event_extra_price_option() {
global $post;
$mep_events_extra_prices = get_post_meta($post->ID, 'mep_events_extra_prices', true);
wp_nonce_field( 'mep_events_extra_price_nonce', 'mep_events_extra_price_nonce' );
?>
<script type="text/javascript">
jQuery(document).ready(function( $ ){
$( '#add-row' ).on('click', function() {
var row = $( '.empty-row.screen-reader-text' ).clone(true);
row.removeClass( 'empty-row screen-reader-text' );
row.insertBefore( '#repeatable-fieldset-one tbody>tr:last' );
return false;
});
$( '.remove-row' ).on('click', function() {
$(this).parents('tr').remove();
return false;
});
});
</script>
<table id="repeatable-fieldset-one" width="100%">
<thead>
<tr>
<th width="40%">Extra Option Name</th>
<th width="40%">Amount</th>
<th width="8%"></th>
</tr>
</thead>
<tbody>
<?php
if ( $mep_events_extra_prices ) :
foreach ( $mep_events_extra_prices as $field ) {
?>
<tr>
<td><input type="text" class="widefat" name="option_name[]" value="<?php if($field['option_name'] != '') echo esc_attr( $field['option_name'] ); ?>" /></td>
<td><input type="number" class="widefat" name="option_price[]" value="<?php if ($field['option_price'] != '') echo esc_attr( $field['option_price'] ); else echo ''; ?>" /></td>
<td><a class="button remove-row" href="#">Remove</a></td>
</tr>
<?php
}
else :
// show a blank one
endif;
?>
<!-- empty hidden one for jQuery -->
<tr class="empty-row screen-reader-text">
<td><input type="text" class="widefat" name="option_name[]" /></td>
<td><input type="number" class="widefat" name="option_price[]" value="" /></td>
<td><a class="button remove-row" href="#">Remove</a></td>
</tr>
</tbody>
</table>
<p><a id="add-row" class="button" href="#">Add Extra Price</a></p>
<?php
}
function mep_event_date_meta_box_cb($post){
$values = get_post_custom( $post->ID );
?>
<div class='sec'>
<label for="event_start_date"> Start Date & Time: </label>
<span><input class='event_start' id='event_start_date' type="text" name='mep_event_start_date' value='<?php echo $values['mep_event_start_date'][0]; ?>'> </span>
@ -236,13 +300,48 @@ $values = get_post_custom( $post->ID );
</div>
<?php
}
add_action('save_post', 'mep_events_repeatable_meta_box_save');
function mep_events_repeatable_meta_box_save($post_id) {
if ( ! isset( $_POST['mep_events_extra_price_nonce'] ) ||
! wp_verify_nonce( $_POST['mep_events_extra_price_nonce'], 'mep_events_extra_price_nonce' ) )
return;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
if (!current_user_can('edit_post', $post_id))
return;
$old = get_post_meta($post_id, 'mep_events_extra_prices', true);
$new = array();
// $options = hhs_get_sample_options();
$names = $_POST['option_name'];
// $selects = $_POST['select'];
$urls = $_POST['option_price'];
$count = count( $names );
for ( $i = 0; $i < $count; $i++ ) {
if ( $names[$i] != '' ) :
$new[$i]['option_name'] = stripslashes( strip_tags( $names[$i] ) );
endif;
if ( $urls[$i] != '' ) :
$new[$i]['option_price'] = stripslashes( strip_tags( $urls[$i] ) );
endif;
}
if ( !empty( $new ) && $new != $old )
update_post_meta( $post_id, 'mep_events_extra_prices', $new );
elseif ( empty($new) && $old )
delete_post_meta( $post_id, 'mep_events_extra_prices', $old );
}
add_action('save_post','mep_events_meta_save');
function mep_events_meta_save($post_id){
global $post;

View File

@ -112,4 +112,22 @@ if($book_count){ $total_book = $book_count; }else{ $total_book = 0; }
</div>
</div>
</div>
<script>
jQuery('input[type=checkbox]').click(function() {
var $form = jQuery('form'); //on a real app it would be better to have a class or ID
var $totalQuant = jQuery('#quantity_5a7abbd1bff73', $form);
jQuery('#quantity_5a7abbd1bff73, input[type=checkbox]', $form).change(calculateTotal);
function calculateTotal() {
var sum = <?php echo $event_meta['_price'][0]; ?>;
jQuery('input[type=checkbox]:checked').each(function() {
sum += jQuery(this).data('price');
})
jQuery('#usertotal').html('<span class=eventtotal>Total:</span> <?php echo get_woocommerce_currency_symbol(); ?>' + sum * parseInt( $totalQuant.val() || 0, 10));
}
});
</script>
<?php get_footer(); ?>

View File

@ -3,7 +3,7 @@
* Plugin Name: Mage WooCommerce Event Booking Manager
* Plugin URI: http://mage-people.com
* Description: A Complete Event Solution for WordPress by MagePeople..
* Version: 1.0.5
* Version: 1.0.6
* Author: MagePeople Team
* Author URI: http://www.mage-people.com/
*/
@ -17,6 +17,7 @@ require_once(dirname(__FILE__) . "/inc/class/mep_settings_api.php");
require_once(dirname(__FILE__) . "/inc/mep_cpt.php");
require_once(dirname(__FILE__) . "/inc/mep_tax.php");
require_once(dirname(__FILE__) . "/inc/mep_event_meta.php");
require_once(dirname(__FILE__) . "/inc/mep_extra_price.php");
require_once(dirname(__FILE__) . "/inc/mep_shortcode.php");
require_once(dirname(__FILE__) . "/inc/admin_setting_panel.php");
@ -509,7 +510,7 @@ if($book_count){ $total_book = $book_count; }else{ $total_book = 0; }
?>
<form action="" method='post'>
<?php //do_action('event_kaku_before_reg_btn'); ?>
<?php do_action('event_kaku_before_reg_btn'); ?>
<?php if($event_sqi==1){ ?>
@ -704,4 +705,21 @@ target="_blank" class='mep-add-calender' rel="nofollow"> <i class="fa fa-calenda
<?php
$content = ob_get_clean();
echo $content;
}
function mep_get_item_name($name){
$explode_name = explode('_', $name, 2);
$the_item_name = str_replace('-', ' ', $explode_name[0]);
return $the_item_name;
}
function mep_get_item_price($name){
$explode_name = explode('_', $name, 2);
$the_item_name = str_replace('-', ' ', $explode_name[1]);
return $the_item_name;
}