Announcement

Collapse
No announcement yet.

calculate estimated delivery date in SMT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    calculate estimated delivery date in SMT

    Looking for a SMT script to calculate the estimated shipping date (today + 10 days but weekends excluded). I don't want to reinvent the wheel so asking the community if anybody has a SMT script ready which excludes weekends else I'll have to do it myself and you know ...

    below Brennan's script just adding 10 days to today. Thought it may help somebody else in case this comes up in a search or as base :)

    <mvt:assign name="g.days_in_future" value="10" />

    <mvt:assign name="g.days_in_seconds" value="(60*60*24) * g.days_in_future" />

    <mvt:assign name = "l.settings:month" value = "padl( time_t_month( s.time_t + g.days_in_seconds, 'local' ), 2, '0' )" />
    <mvt:assign name = "l.settings:day" value = "padl( time_t_dayofmonth( s.time_t + g.days_in_seconds, 'local' ), 2, '0' )" />
    <mvt:assign name = "l.settings:year" value = "time_t_year( s.time_t + g.days_in_seconds, 'local' )" />

    <mvt:assign name="g.future_date" value="l.settings:year $ '-' $ l.settings:month $ '-' $ l.settings:day" />

    &mvt:global:future_date;
    Andreas Toman
    PCINET, LLC

    Miva Merchant Design, Development, Integration & Support
    We built over 200 Miva Merchant stores!
    Miva shopping cart design & integration service and see our Portfolio!


    e-mail: [email protected]
    web: www.pcinet.com
    LinkedIn: Andreas Toman
    phone: (786) 250-2056 (Miami, FL)

    #2
    Here's one in JS
    Code:
     
     // Expects start date to be before end date // start and end are Date objects function dateDifference(start, end) {    // Copy date objects so don't modify originals   var s = new Date(+start);   var e = new Date(+end);    // Set time to midday to avoid dalight saving and browser quirks   s.setHours(12,0,0,0);   e.setHours(12,0,0,0);    // Get the difference in whole days   var totalDays = Math.round((e - s) / 8.64e7);    // Get the difference in whole weeks   var wholeWeeks = totalDays / 7 | 0;    // Estimate business days as number of whole weeks * 5   var days = wholeWeeks * 5;    // If not even number of weeks, calc remaining weekend days   if (totalDays % 7) {     s.setDate(s.getDate() + wholeWeeks * 7);      while (s < e) {       s.setDate(s.getDate() + 1);        // If day isn't a Sunday or Saturday, add to business days       if (s.getDay() != 0 && s.getDay() != 6) {         ++days;       }     }   }   return days; }
    That's all I got...
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      I have a module that computes delivery dates. It has server hookups for UPS, FedEx, and Canada Post, so it can get actual arrival dates and numbers-of-days from the carriers. It can be used with any shipping modules. I wrote it as a custom project, but it's expanded in function over the years, and I'm about ready to publish it. If you'd like a copy, you can email me for details.
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment


        #4
        script ready which excludes weekends
        My integration Smartdate handles this scenario as well as allowing assignment of blackout days like holidays and can exclude the current day if the time is past a set time. Very handy with the next-day delivery. There is even a way to configure your time zone -- especially when the time zone is offset by the half-hour.

        *********************************************

        Just leaving this here because I have a solution also. It's probably overkill for this project.

        SmartDate Integration

        Use the coupon code memorial until the end of the month and save $100.00.

        Scott
        Last edited by ids; 05-25-18, 03:11 PM.
        Need to offer Shipping Insurance?
        Interactive Design Solutions https://www.myids.net
        MivaMerchant Business Partner | Certified MivaMerchant Web Developer
        Competitive Rates, Custom Modules and Integrations, Store Integration
        AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
        My T-shirt Collection is mostly MivaCon T-shirts!!

        Comment


          #5
          I believe the following will work:


          Code:
          <mvt:assign name="l.settings:one_day_in_seconds" value="24 * 60 * 60" />
          <mvt:assign name="l.settings:position_in_time" value="dyn_time_t" />
          <mvt:assign name="l.settings:estimated_delivery_timestamp" value="dyn_time_t + (10 * l.settings:one_day_in_seconds)" />
          <mvt:while expr="l.settings:position_in_time LT l.settings:estimated_delivery_timestamp">
              <mvt:assign name="l.settings:current_day_of_week" value="time_t_dayofweek(l.settings:position_in_time, 'local')" />
              <mvt:if expr="l.settings:current_day_of_week EQ 1 OR l.settings:current_day_of_week EQ 7">
                  <mvt:assign name="l.settings:estimated_delivery_timestamp" value="l.settings:estimated_delivery_timestamp + l.settings:one_day_in_seconds" />
              </mvt:if>
              <mvt:assign name="l.settings:position_in_time" value="l.settings:position_in_time + l.settings:one_day_in_seconds" />
          </mvt:while>
          <mvt:assign name="l.settings:estimated_delivery_human_readable" value="padl(time_t_month(l.settings:estimated_delivery_timestamp, 'local'), 2, '0') $ '/' $ padl(time_t_dayofmonth(l.settings:estimated_delivery_timestamp, 'local'), 2, '0') $ '/' $ time_t_year(l.settings:estimated_delivery_timestamp, 'local')" />
          
          &mvt:estimated_delivery_human_readable;
          Justin Sims
          216digital
          Cleveland Area - Code and Design
          https://216digital.com/

          Comment


            #6
            Guys a module is a bit overkill but may suite somebody else. Thanks Justin for the SMT code!
            Andreas Toman
            PCINET, LLC

            Miva Merchant Design, Development, Integration & Support
            We built over 200 Miva Merchant stores!
            Miva shopping cart design & integration service and see our Portfolio!


            e-mail: [email protected]
            web: www.pcinet.com
            LinkedIn: Andreas Toman
            phone: (786) 250-2056 (Miami, FL)

            Comment


              #7
              No problem at all
              Justin Sims
              216digital
              Cleveland Area - Code and Design
              https://216digital.com/

              Comment


                #8
                Is there script that I can use to add this to the email confirmation page?

                Comment

                Working...
                X