Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6698451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:34:47+00:00 2026-05-26T06:34:47+00:00

I have 2 shipping zones, A & B. Orders for zone A are delivered

  • 0

I have 2 shipping zones, A & B. Orders for zone A are delivered each Monday, Wednesday & Friday, whereas zone B is on Tuesday, Thursday, Saturday. For each order, the delivery day is scheduled for the NEXT AVAILABLE day, depending on the zone. Please consider that if someone places an order on Monday the goods will be delivered on the NEXT available date, that would be Tuesday for zone B and Wednesday for zone A.

BUT: If an order is placed later than 18:00 (6pm) and the customer’s area is within the tomorrow’s delivery zone, then we have to advance the delivery date to the next available day for that zone (because the order won’t be ready yet, too short notice).

Here’s the code and it works fine except for the last part where I need to check time, get the regular delivery date and compare it with tomorrow’s date.

<? 
$date = array(date("d"), date("m"), date("Y"));

$zones = array("A" => array(1 => "Monday",    
                            3 => "Wednesday", 
                            5 => "Friday")     

              ,"B" => array(2 => "Tuesday",    
                            4 => "Thursday",   
                            6 => "Saturday")); 

$found = false;
$days_plus = 1; // always begin from next day

// Retrieve last day from the zone
end($zones[$zone]); //Friday or Saturday
$last_day = key($zones[$zone]); //5 or 6

do {
    $mk = mktime(0, 0, 0, $date[1], ($date[0] + $days_plus), $date[2]);
    $week = date("w", $mk); // current day of week 

    if ($week <= $last_day) // if weekday not passed last day of zone
    {
        if (!isset($zones[$zone][$week]))
        {
            $days_plus++;
        }
        else
        {
            $found = true;
            $day = $last_day;
        }
    }
    else
    {
        $days_plus++;
    }
} while (!$found);

$deliverydate = date("d/m/Y", $mk); // regular delivery date
$tomorrow = date('d/m/Y', strtotime('tomorrow')); 

//Now, check if order is placed after 6pm 
if ((date("d/m/Y", $mk)==$tomorrow) && (date('G') > 18)) {
    // HERE'S my problem, how do I advance the
    //delivery date to next day in the same zone?
}
echo $deliverydate; 
?>

Note: I tried converting the loop into a function findNextDay($days_plus, $date, $last_day, $zone) so that I could call it again with a different $days_plus value (increased by x days) but I couldn’t get it to work. For anyone interested here is the modified version

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:34:47+00:00Added an answer on May 26, 2026 at 6:34 am

    This is how I would do it.

    NOTE
    I didn’t give a whole lot of time to figuring out the best way to handle all of the business rules, but all of my tests seemed to work.

    <?php
    
    
    error_reporting(E_ALL);
    ini_set('display_errors','On');
    
    date_default_timezone_set('America/Los_Angeles');
    
    $zones = array('A', 'B');
    $zone_key = array_rand($zones);
    $zone = $zones[$zone_key];
    
    
    function getDeliveryDate($zone, $d = NULL, $time = NULL) {
        if ($time === NULL) 
            $time = date('G');
        if ($d === NULL)
            $now = strtotime('now');
        else
            $now = strtotime($d);
        $d = date('w', $now);
        $days = 1;
        if ($zone == 'A') {
            if ($d % 2) $days += 1;
            else if ($time > 18) $days += 2;
    
            if ($d + $days == 7) $days += 1;
            elseif ($d + $days > 7) $days -= 1;
        } else {
            if (! ($d % 2)) $days += 1;
            else if ($time > 18) $days += 2;
            if ($d + $days > 7) $days += 1;
        }
    
        $delivery_date = strtotime("+${days}days", $now);
    
        echo "For zone $zone, schedule on " . date('D', $now) . ", at $time, will deliver on " . date('m-d-Y', $delivery_date) . " which is a " . date('D', $delivery_date) . "\n";
    }
    
    $days = array('10/16/2011', '10/17/2011', '10/18/2011', '10/19/2011', '10/20/2011', '10/21/2011', '10/22/2011');
    $times = array(17, 20);
    
    foreach ($zones as $zone) {
        foreach ($days as $d) {
            foreach ($times as $t) {
                getDeliveryDate($zone, $d, $t);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shipping/billing input form and I'm having trouble styling the input fields
I have a client who is using OpenCart v.1.5.2.1 and they have one shipping
I have a free shipping price rule which is configured like this: All customer
I have created a custom shipping method to show depo-names from which customers will
We have a Magento Shop and the shipping settings are already set and everything
i have this html: <span class=price> $61.00 <span class=detailFreeShipping>With Free Shipping</span> </span> How to
I have two instances of an Address.ascx control in an ASP.NET MVC page. <h1>Shipping
I have a shipping form. Three input fields surround the shipping address. Below are
in magento configuration i have set shipping to be £5. Is there a way
I have enabled free shipping for all the states under US and configured table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.