Skip to content

Instantly share code, notes, and snippets.

@danichim
Created February 21, 2022 19:25
Show Gist options
  • Save danichim/f2891ad306481f0eec1233da8ab9729f to your computer and use it in GitHub Desktop.
Save danichim/f2891ad306481f0eec1233da8ab9729f to your computer and use it in GitHub Desktop.
date-estimate-delivery.php
add_action('woocommerce_after_add_to_cart_form', 'cjuk_estimated_delivery');
function cjuk_estimated_delivery(){
date_default_timezone_set( 'Europe/Bucharest' );
//$today = date_i18n("j F, Y"); //, strtotime('+2 days')
if ( date( 'N' ) <= 4 ) {
$today = date_i18n("j F, Y", strtotime('+1 day'));
$today2 = date_i18n("j F, Y", strtotime('+3 days'));
}
if (date('N') === 5 && date('H') < 16) {
$today = date_i18n("j F, Y", strtotime('+1 day'));
$today2 = date_i18n("j F, Y", strtotime('+3 days'));
}
if (date('N') === 5 && date('H') > 16 || date('N') >= 6) {
$today = date_i18n("j F, Y", strtotime('next tuesday'));
$today2 = date_i18n("j F, Y", strtotime('next thursday'));
}
echo '<div style="border:1px solid #16497A; border-radius: 5px; border-width: 1px; padding:10px 15px;">';
echo '<span class="svg-icon svg-baseline"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path d="M9 17a2 2 0 11-4 0 2 2 0 014 0zM19 17a2 2 0 11-4 0 2 2 0 014 0z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16V6a1 1 0 00-1-1H4a1 1 0 00-1 1v10a1 1 0 001 1h1m8-1a1 1 0 01-1 1H9m4-1V8a1 1 0 011-1h2.586a1 1 0 01.707.293l3.414 3.414a1 1 0 01.293.707V16a1 1 0 01-1 1h-1m-6-1a1 1 0 001 1h1M5 17a2 2 0 104 0m-4 0a2 2 0 114 0m6 0a2 2 0 104 0m-4 0a2 2 0 114 0" />
</svg></span><span> Dată estimată de livrare: <b>'.$today.'-'.$today2.'</b></span>';
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment