Skip to content

Instantly share code, notes, and snippets.

@trueqap
Created December 28, 2023 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trueqap/1931f311fe2dd57c3f4f3def541621f3 to your computer and use it in GitHub Desktop.
Save trueqap/1931f311fe2dd57c3f4f3def541621f3 to your computer and use it in GitHub Desktop.
<?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