Created
November 26, 2020 12:03
-
-
Save trueqap/167265133ca2a92b4eb780fcc6cab615 to your computer and use it in GitHub Desktop.
woocommerce_checkout_nyitva_tartas -> Shortcode
This file contains 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 | |
// [woocommerce_checkout_nyitva_tartas] | |
function woocommerce_checkout_nyitva_tartas($atts) | |
{ | |
$jelenlegi_ido = date('h:i:s a'); | |
$nyitas = "10:00 am"; //am -> délelőtt | |
$zaras = "4:00 pm"; // pm -> délután | |
$date1 = DateTime::createFromFormat('h:i a', $jelenlegi_ido); | |
$date2 = DateTime::createFromFormat('h:i a', $nyitas); | |
$date3 = DateTime::createFromFormat('h:i a', $zaras); | |
if ($date1 > $date2 && $date1 < $date3) { | |
return do_shortcode('[woocommerce_checkout]'); | |
} else { | |
return 'Az üzlet XY idő között van nyitva.'; | |
} | |
} | |
add_shortcode('woocommerce_checkout_nyitva_tartas', 'woocommerce_checkout_nyitva_tartas'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment