Browse Source

* Fix - Fixed events not fetched if your database prefix was not exactly "wp_"

* Fix - Flush rewrite rules on activate to avoid error 500
* Fix - "Create or import activity" dialog is closed before opening a new one. This prevent undesirable display and behavior.
* Fix - Cron error in log/error.log appeared even if bookings were correctly deactivated hourly
* Fix - Check booking id before sync booking state in woocommerce meta to avoid errors
master 1.0.8
Yoan Cutillas 4 years ago
parent
commit
74e30912ac
  1. 7
      booking-activities.php
  2. 31
      controller/controller-woocommerce-bookings.php
  3. 13
      js/templates-dialogs.js
  4. 1
      log/error.log
  5. 2
      model/model-booking-system.php
  6. 4
      model/model-woocommerce.php
  7. 9
      readme.txt

7
booking-activities.php

@ -3,7 +3,7 @@
* Plugin Name: Booking Activities
* Plugin URI: http://booking-activities.fr/en
* Description: Create your activity calendars with drag and drop and book scheduled events with one click. Enable online payments of reservations with WooCommerce.
* Version: 1.0.7
* Version: 1.0.8
* Author: Booking Activities Team
* Author URI: http://booking-activities.fr/en
* Text Domain: booking-activities
@ -38,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
// GLOBALS AND CONSTANTS
if( ! defined( 'BOOKACTI_VERSION' ) ) { define( 'BOOKACTI_VERSION', '1.0.7' ); }
if( ! defined( 'BOOKACTI_VERSION' ) ) { define( 'BOOKACTI_VERSION', '1.0.8' ); }
if( ! defined( 'BOOKACTI_PLUGIN_NAME' ) ) { define( 'BOOKACTI_PLUGIN_NAME', 'booking-activities' ); }
if( ! defined( 'BOOKACTI_PLUGIN_BASENAME' ) ) { define( 'BOOKACTI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); }
@ -226,6 +226,9 @@ function bookacti_activate() {
}
do_action( 'bookacti_activate' );
// Flush rules after install
flush_rewrite_rules();
}

31
controller/controller-woocommerce-bookings.php

@ -50,6 +50,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
* Deactivate expired bookings
*
* @since 1.0.6
* @version 1.0.8
*/
function bookacti_controller_deactivate_expired_bookings() {
@ -59,7 +60,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
/* translators: 'cron' is a robot that execute scripts every X hours. Don't try to translate it. */
$log = esc_html__( 'The expired bookings were not correctly deactivated by cron.', BOOKACTI_PLUGIN_NAME );
bookacti_log( $log, 'error' );
} else {
} else if ( is_array( $deactivated_ids ) ) {
// Yell the booking state change
// (important for consistancy between WooCommerce order items and Booking Activities bookings)
foreach( $deactivated_ids as $booking_id ) {
@ -326,17 +327,28 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
}
// Turn meta state to new status
add_action( 'bookacti_booking_state_changed', 'bookacti_woocommerce_turn_booking_meta_state_to_new_state', 10 , 3 );
/**
* Turn meta state to new status
*
* @since 1.0.0
* @version 1.0.8
*/
function bookacti_woocommerce_turn_booking_meta_state_to_new_state( $booking_id, $new_state, $args = array() ) {
if( empty( $booking_id ) ) {
return;
}
$item = bookacti_get_order_item_by_booking_id( $booking_id );
// Turn meta state to new state
$old_booking_state = wc_get_order_item_meta( $item[ 'id' ], 'bookacti_state', true );
wc_update_order_item_meta( $item[ 'id' ], 'bookacti_state', $new_state );
if( in_array( $new_state, array( 'refunded', 'refund_requested' ) ) ) {
$refund_action = $args[ 'refund_action' ] ? $args[ 'refund_action' ] : 'manual';
wc_update_order_item_meta( $item[ 'id' ], '_bookacti_refund_method', $refund_action );
if( $item ) {
// Turn meta state to new state
$old_booking_state = wc_get_order_item_meta( $item[ 'id' ], 'bookacti_state', true );
wc_update_order_item_meta( $item[ 'id' ], 'bookacti_state', $new_state );
if( in_array( $new_state, array( 'refunded', 'refund_requested' ) ) ) {
$refund_action = $args[ 'refund_action' ] ? $args[ 'refund_action' ] : 'manual';
wc_update_order_item_meta( $item[ 'id' ], '_bookacti_refund_method', $refund_action );
}
}
@ -403,6 +415,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
}
}
}
add_action( 'bookacti_booking_state_changed', 'bookacti_woocommerce_turn_booking_meta_state_to_new_state', 10 , 3 );
// Add refund action process

13
js/templates-dialogs.js

@ -11,7 +11,7 @@ function bookacti_init_template_dialogs() {
show: true,
hide: true,
closeText: '✖',
close: function() { bookacti_empty_all_dialog_forms(); }
beforeClose: function() { bookacti_empty_all_dialog_forms(); }
});
$j
@ -870,6 +870,9 @@ function bookacti_dialog_choose_activity_creation_type() {
var create_activity_button = {
text: bookacti_localized.dialog_button_create_activity,
click: function() {
//Close the modal dialog
$j( this ).dialog( 'close' );
// Open create activity dialog
bookacti_dialog_create_activity();
}
@ -877,6 +880,9 @@ function bookacti_dialog_choose_activity_creation_type() {
var import_activity_button = {
text: bookacti_localized.dialog_button_import_activity,
click: function() {
//Close the modal dialog
$j( this ).dialog( 'close' );
// Open import activity dialog
bookacti_dialog_import_activity();
}
@ -1042,8 +1048,9 @@ function bookacti_dialog_create_activity() {
$j( '#bookacti-activity-old-title' ).val( '' );
// Add current template in activity bound template select box if it isn't yet
if( $j.inArray( template_id, $j( '#bookacti-activity-templates-select-box' ).val() ) < 0
&& $j( '#bookacti-add-new-activity-templates-select-box' ).find( 'option[value="' + template_id + '"]' ).length ) {
if( ( ! $j( '#bookacti-activity-templates-select-box' ).val()
|| $j.inArray( template_id, $j( '#bookacti-activity-templates-select-box' ).val() ) < 0 )
&& $j( '#bookacti-add-new-activity-templates-select-box option[value="' + template_id + '"]' ).length ) {
$j( '#bookacti-add-new-activity-templates-select-box' ).val( template_id );
$j( '#bookacti-activity-templates-container .bookacti-add-items' ).trigger( 'click' );
}

1
log/error.log

@ -1 +0,0 @@
2017-05-24T03:32:48+00:00 - Les réservations expirées n&#039;ont pas été correctement désactivées par le cron.

2
model/model-booking-system.php

@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
$query = 'SELECT DISTINCT E.id as event_id, E.template_id, E.title, E.start, E.end, E.repeat_freq, E.repeat_from, E.repeat_to, E.availability, A.color, A.id as activity_id, IFNULL( B.bookings, 0 ) as bookings '
. ' FROM ' . BOOKACTI_TABLE_ACTIVITIES . ' as A, ' . BOOKACTI_TABLE_TEMPLATES . ' as T, ' . BOOKACTI_TABLE_EVENTS . ' as E '
. ' LEFT JOIN (
SELECT SUM(quantity) as bookings, event_id FROM wp_bookacti_bookings WHERE active = 1 GROUP BY event_id
SELECT SUM(quantity) as bookings, event_id FROM ' . BOOKACTI_TABLE_BOOKINGS . ' WHERE active = 1 GROUP BY event_id
) as B ON B.event_id = E.id'
. ' WHERE E.activity_id = A.id '
. ' AND E.template_id = T.id ';

4
model/model-woocommerce.php

@ -336,7 +336,7 @@ function bookacti_update_bookings_user_id( $user_id, $customer_id ) {
* Deactivate expired bookings
*
* @since 1.0.0
* @version 1.0.6
* @version 1.0.8
*/
function bookacti_deactivate_expired_bookings() {
global $wpdb;
@ -355,7 +355,7 @@ function bookacti_deactivate_expired_bookings() {
. ' AND active = 1';
$deactivated = $wpdb->query( $query_deactivate_expired );
$return = false;
$return = $deactivated;
if( $deactivated ){
foreach( $deactivated_ids as $deactivated_id ) {
$return[] = $deactivated_id->id;

9
readme.txt

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: booking activities, booking form, manage reservations, activity planning, events calendar, booking sport, booking system, booking, reservations, appointments, woocommerce
Requires at least: 4.0
Tested up to: 4.7
Stable tag: 1.0.7
Stable tag: 1.0.8
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -239,6 +239,13 @@ If you don't find the answer you need, please [contact us](http://booking-activi
== Changelog ==
= 1.0.8 - 2017/05/31 =
* Fix - Fixed events not fetched if your database prefix was not exactly "wp_"
* Fix - Flush rewrite rules on activate to avoid error 500
* Fix - "Create or import activity" dialog is closed before opening a new one. This prevent undesirable display and behavior.
* Fix - Cron error in log/error.log appeared even if bookings were correctly deactivated hourly
* Fix - Check booking id before sync booking state in woocommerce meta to avoid errors
= 1.0.7 - 2017/05/27 =
* Fix - Fixed non-repeting events not fetched

Loading…
Cancel
Save