I have the following code below that creates a line of text under all products on the home, category and related products pages, that says "GREATER CAPE TOWN AREA"…
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_products_loop', 20 );
function woocommerce_products_loop(){
global $product;
echo '<p class="deliveryline">' . __("GREATER CAPE TOWN AREA", "woocommerce") . '</p>';
}
I'd like to have a line of text above this that says "NEXT DELIVERY: " and then uses the following logic:
- If it's a weekday BEFORE 12pm, it should say "TOMORROW"
- If it's a weekday AFTER 12pm, it should say the name of the business day after tomorrow.
- if it's a friday BEFORE 12pm it should say "MONDAY"
- if it's a friday AFTER 12pm it should say "TUESDAY"
Basically, we offer next day delivery on weekdays, for orders placed before 12pm.
I have code for something similar that may work..
$now = new Zend_Date();
if (($now->get(Zend_Date::WEEKDAY_DIGIT) % 6 == 0)
|| ($now->isLater('17:00:00', Zend_Date::TIMES))
) {
$now->set(
strtotime('+1 weekday', $now->toString(Zend_Date::TIMESTAMP)),
Zend_Date::TIMESTAMP
);
}
echo $now->toString(Zend_Date::W3C);
I just need help please figuring out the correct maths for what I need (this code is based on same day if before 5pm), and then where do I place it within the original code?
Could someone please help with this complete code snippet? Ideally I want it to look like the attached image.
Desired result:

