Skip to content

Commit

Permalink
Release 1.3.5 #54 #53
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRiera committed Dec 10, 2023
1 parent 65d408e commit f24ce3c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 ==

Expand All @@ -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)
Expand All @@ -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

Expand Down
41 changes: 33 additions & 8 deletions estimated-delivery-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}

Expand Down Expand Up @@ -350,7 +375,7 @@ function edw_show_message($productParam = false, $separed = false){


if(!$mode) {
return;
return '';
}
/**
* Hide for out stock products
Expand Down
12 changes: 11 additions & 1 deletion views/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -133,7 +134,7 @@
</div>
<input type="hidden" name="n" value="<?=bloginfo('name')?>" />
<input type="hidden" name="w" value="<?=bloginfo('url')?>" />
<input type="hidden" name="g" value="1" />
<input type="hidden" name="g" value="1,5" />
<input type="text" name="anotheremail" id="anotheremail" style="position: absolute; left: -5000px" tabindex="-1" autocomplete="off" />
<div class="submit-wrapper">
<input type="submit" name="commit" value="<?=__('Submit', 'estimated-delivery-for-woocommerce')?>" class="button" data-disable-with="<?=__('Processing', 'estimated-delivery-for-woocommerce')?>" />
Expand Down Expand Up @@ -334,6 +335,15 @@
</label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?=__('Holidays Dates', 'estimated-delivery-for-woocommerce')?>
<p class="description"><?=__('Dates with comma separated, YYYY/MM/DD, on YEAR use XXXX for dynamic year. Example: XXXX/31/12','estimated-delivery-for-woocommerce')?></p>
</th>
<td>
<label>
<textarea name="_edw_holidays_dates" cols="70" rows="20" /><?=get_option('_edw_holidays_dates', '')?></textarea></label>
</td>
</tr>
</table>
<input class="button" type="submit" value="<?=__('Save','estimated-delivery-for-woocommerce');?>">
</form>
Expand Down

0 comments on commit f24ce3c

Please sign in to comment.