Created
December 28, 2023 18:44
-
-
Save trueqap/1931f311fe2dd57c3f4f3def541621f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Custom Shipping Estimate for WooCommerce | |
* Description: Adds a shipping estimate notice on WooCommerce product pages. | |
* Version: 1.0 | |
* Author: trueqap | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
function add_custom_shipping_estimate() { | |
date_default_timezone_set('Europe/Budapest'); | |
$today = new DateTime(); | |
$today->setTime(0, 0, 0); | |
$shipping_date = clone $today; | |
$business_days_added = 0; | |
while ($business_days_added < 2) { | |
$shipping_date->modify('+1 day'); | |
if (!in_array($shipping_date->format('N'), [6, 7])) { | |
$business_days_added++; | |
} | |
} | |
echo 'A várható szállítási idő: ' . $shipping_date->format('Y-m-d'); | |
} | |
add_action('woocommerce_before_add_to_cart_form', 'add_custom_shipping_estimate'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment