diff --git a/README.md b/README.md index de449bb..da5e5ed 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -=== Estimated Delivery for Woocomerce === +=== Estimated Delivery for WooCommerce === Contributors: DanielRiera Donate link: https://www.paypal.com/donate/?hosted_button_id=EZ67DG78KMXWQ Tags: estimated delivery, delivery woocommerce Requires at least: 4.3 -Tested up to: 6.2 +Tested up to: 6.4.2 Requires PHP: 5.0 -Stable tag: 1.3.4 +Stable tag: 1.3.5 == Description == @@ -18,6 +18,14 @@ Shows the estimated or guaranteed delivery date on each product, select the days **🎉 [Dokan Multivendor](https://wedevs.com/dokan?utm_source=estimated-delivery-for-woocommerce) | [WC Marketplace](https://multivendorx.com?utm_source=estimated-delivery-for-woocommerce) | [WCFM](https://wclovers.com?utm_source=estimated-delivery-for-woocommerce) support is ready 🎉** Here it is! Now Estimate Delivery for Woocommerce is compatible with Dokan Multivendor, WC Marketplace and WCFM, you asked us for compatibility with these plugins and here it is. ðŸĪŠ +### Holidays dates support (From 1.3.5 version)! + +You can add holidays dates with next format, comma separated: +(Use XXXX for dynamic year) + +XXXX/12/31,XXXX/01/01,2024/10/02 + + Do you need more options? [Click here Github](https://github.com/DanielRiera/estimated-delivery-woocommerce/issues) @@ -35,6 +43,11 @@ If you need support open a new ticket on [Github](https://github.com/DanielRiera == Changelog == += 1.3.5 = +* Compatibility with High-Performance order storage (COT) +* Add new option with Holidays dates, see description for more information +* Minor fixes + = 1.3.4 = * Fix memory PHP diff --git a/estimated-delivery-woocommerce.php b/estimated-delivery-woocommerce.php index 020ef60..b7dab1a 100644 --- a/estimated-delivery-woocommerce.php +++ b/estimated-delivery-woocommerce.php @@ -4,20 +4,20 @@ * Description: Show estimated / guaranteed delivery, simple and easy * Author: Daniel Riera * Author URI: https://danielriera.net - * Version: 1.3.4 + * Version: 1.3.5 * Text Domain: estimated-delivery-for-woocommerce * Domain Path: /languages * WC requires at least: 3.0 - * WC tested up to: 7.6.1 + * WC tested up to: 8.3.1 * Required WP: 5.0 - * Tested WP: 6.2 + * Tested WP: 6.4.2 */ if(!defined('ABSPATH')) { exit; } define('EDW_PATH', dirname(__FILE__).'/'); define('EDW_POSITION_SHOW', get_option('_edw_position', 'woocommerce_after_add_to_cart_button')); define('EDW_USE_JS', get_option('_edw_cache', '0')); -define('EDW_Version', '1.3.4'); +define('EDW_Version', '1.3.5'); require_once EDW_PATH . 'class.api.php'; @@ -67,6 +67,12 @@ function __construct(){ add_filter( 'woocommerce_get_item_data', array(&$this,'edw_display_cart_item'), 10, 2); add_action('woocommerce_checkout_create_order_line_item', array(&$this, 'edw_save_custom_order_item_meta_data'), 10, 4 ); add_action('woocommerce_after_shop_loop_item_title', array(&$this, 'edw_show_date_list')); + + add_action( 'before_woocommerce_init', function() { + if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); + } + } ); } function edw_wcmf_save_data($product_id, $wcfm_products_form_data) { @@ -269,6 +275,24 @@ function edw_view_page_options() { require_once(EDW_PATH . 'views/options.php'); } + + private function get_holidays_dates() { + $holidays = get_option('_edw_holidays_dates', false); + if($holidays) { + $holidays = str_replace("XXXX", strval(date('Y')), $holidays); + $holidays = str_replace("/", "-", $holidays); + return explode(",", $holidays); + } + return array(); + } + + private function check_holidays_date($date) { + $holidays = $this->get_holidays_dates(); + if($date and $holidays) { + return in_array($date, $holidays); + } + return false; + } private function edw_get_working_day_date($disabledDays, $daysToAdd, $dateCheck, $iteration = 0) { if(count($disabledDays) == 7) { @@ -279,11 +303,12 @@ private function edw_get_working_day_date($disabledDays, $daysToAdd, $dateCheck, } $dateCheck = wp_date('Y-m-d', strtotime($dateCheck . " + 1 days")); - + $is_holiday = $this->check_holidays_date($dateCheck); $filterDisabled = date('D', strtotime($dateCheck)); - if(is_array($disabledDays) and !in_array($filterDisabled, $disabledDays)) { - $iteration += 1; + if(!$is_holiday and is_array($disabledDays) and !in_array($filterDisabled, $disabledDays)) { + $iteration += 1; } + return $this->edw_get_working_day_date($disabledDays, $daysToAdd, $dateCheck, $iteration); } @@ -350,7 +375,7 @@ function edw_show_message($productParam = false, $separed = false){ if(!$mode) { - return; + return ''; } /** * Hide for out stock products diff --git a/views/options.php b/views/options.php index 2ff4717..4caf596 100644 --- a/views/options.php +++ b/views/options.php @@ -21,6 +21,7 @@ update_option('_edw_days_backorders',sanitize_text_field( $_POST['_edw_days_backorders'] )); update_option('_edw_max_days_backorders',sanitize_text_field( $_POST['_edw_max_days_backorders'] )); update_option('_edw_max_hour', sanitize_text_field($_POST['_edw_max_hour'])); + update_option('_edw_holidays_dates', sanitize_textarea_field($_POST['_edw_holidays_dates'])); if(isset($_POST['_edw_relative_dates'])) { update_option('_edw_relative_dates', '1'); }else{ @@ -133,7 +134,7 @@ - +
@@ -334,6 +335,15 @@ + + +

+ + + + +