9 Replies Latest reply on May 24, 2010 7:43 AM by Cathy Thompson

    Help Calculating shipping and handling costs from numerous subtotal fields?

    SpitfireGT6

      I'm creating a form for our car club to sell club memorabelia. We are a not for profit club.   I'm not familiar with Adobe LiveCycle Designer, but have been able to get most of the fields to work as designed. 

      I've been able to achieve a "Grand Total" box from several other fields.  But, in trying to determine Shipping and Handling, I need to: 1) have the buyer select one of four different regions from a drop down list box. 2) Each region will have a different amount for S&H based on values from five different subtotal boxes. 3. The S&H total is dependant on values from five different items for sale.

       

      I've written a "If - then" statement describing the calculations I want to perform, but I don't know how to script it or where to place the script in LiveCycle ES.  I've put the script and the pdf form on my website.  The link to the form is: http://mikeross-dds.com/NASS_REGALIA/REGALIA.pdf

       

      The link to the proposed script is:  http://mikeross-dds.com/NASS_REGALIA/RegaliaPDFscriptExample.doc

      I would appreciate any help in scriping this properly.  I would be willing to pay someone to provide the correct scripting format.

       

      Thanks,

       

      Mike

        • 1. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
          Kevin Cavallo Level 4

          Mike - wow!

           

          First, in your PaymentAmount::calculate event, add:

               GrandTotal + PostageSH

           

          That will display the check amount total.

           

           

          The grunt work will be done in the PostageSH::calculate event.  For starters, you need to get the value of the location selection box.  You can do this using the drop down list's getDisplayItem method:

           

          var location = DropDownListCountry.getDisplayItem(DropDownListCountry.selectedIndex)

           

          Then you can make decisions based on the location:

               if ( location == "USA" ) then

                   USA-based calculations

               elseif (location == "CANADA") then

                    Canadian calculations

               endif

           

          The problem is your calculation logic.  Can you make it any more complicated?  Seriously, I wouldn't know how to code that since it doesn't make logical sense.  The "and/or" rules are not possible: "SubTotalTShirts > $4.99 and SubtotalHatPins > $2.49" means something completely different than "SubTotalTShirts > $4.99 or SubtotalHatPins > $2.49".  Your rules will have to be cleaned up.

           

          If you can come up with clearer rules, I can help you some more.

           

           

          Kevin

          (TR3-B owner in CT)

          • 2. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
            SpitfireGT6 Level 1

            Hi Kevin,

             

            I didn't expect to get a response from another Triumph driver.  I'll keep

            working on this to try to get it simpler.  My problem is knowing just what

            rules are available.

             

            Thanks for the suggestions,

             

            Mike Ross

            President North American Spitfire Squadron

            '68 Triumph Spitfire

            '70 Triumph GT6+

            numerous project cars

            http://pages.prodigy.net/mikeross/

            • 3. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
              Kevin Cavallo Level 4

              Mike, it totally has to do with how you do business and who your shipping carrier is, but usually shipping charges are based on a percentage of the total order cost, or total cost ranges, or the weight of the package.  That being said, scripting will allow an almost limitless number of "if (condition) then (calculation 1) else (other calculations).  However the conditions must be explicit; the script must have a definite set of rules to follow with no 'gray areas'.

               

              Also, I noticed that under the Dash Plaques section the Numeric fields that hold the cost do not match up with the associated dropdown on the same line.  For example, for NASS LOGO - Color on white, you have:

                   DropDownList1[21]*NumericField1[11] 

              It should be:

                   DropDownList1[20]

               

               

               

              *NumericField1[11]

               

               

              Regards,

              Kevin

               

              • 4. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
                SpitfireGT6 Level 1

                Kevin,

                I’ve redone the form and everything works now except the dropdown list for calculating postage for different countries. 
                I didn’t understand your reference to the getDisplayItem method.  I’ve used the various form examples and the help
                menu for LiveCycle, but I’m still stumpted.  The link to the improved form is
                http://mikeross-dds.com/NASS_REGALIA/REGALIA-2.pdf

                Here are the SPECIFICATIONS FOR the DROPDOWN LIST “DropDownListCountry” ON MY CAR CLUB REGALIA STORE ORDER FORM:

                USA:

                default.  No additional script needed

                Canada:

                If ( SubTotalTShirts = =  $5.00 ) then
                  $3.00
                If ( SubTotalTShirts ==   $10.00 ) then
                  $4.00
                If (SubTotalTShirts == $15.00 ) then
                  $5.50
                If (SubTotalTShirts == $20.00 ) then
                  $6.50
                If (SubTotalTShirts > $24.00 ) then
                  $7.50

                Mexico:

                If  ( SubTotalTShirts  = =  $5.00 )  then
                   $4.00
                If  ( SubTotalTShirts  ==   $10.00 )  then
                   $6.00
                If  (SubTotalTShirts  ==  $15.00 ) then
                   $8.50
                If  (SubTotalTShirts  ==  $20.00 ) then
                  $9.75
                If  (SubTotalTShirts  >  $24.00 ) then
                  $11.50

                Other:

                If  ( SubTotalTShirts  = =  $5.00 )  then
                   $5.00
                If  ( SubTotalTShirts  ==   $10.00 )  then
                   $8.00
                If  (SubTotalTShirts  ==  $15.00 ) then
                   $10.00
                If  (SubTotalTShirts  ==  $20.00 ) then
                  $12.00
                If  (SubTotalTShirts  >  $24.00 ) then
                  $14.00

                I've looked at the samples from Adobe LifCycleDesigner, but can't figure out where or how to script the dropdown list.  I’ve managed to clear up the other problems.   Any help coming up with a script would be greatly appreciated.

                Mike R.

                • 5. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
                  Kevin Cavallo Level 4

                  Mike, see attached form.  All of my changes are in the PostageSH::calculate event.  It's very basic since your rules only involve the T-shirt subtotal, but you should be able to see how it can be extended.

                   

                  Note that this is sort of a "brute-force" method; the whole "if-then-else" scheme is not super efficient if you start adding a lot of additional rules, and it can be very hard to read/maintain.  A more sophisticated approach might be to use tables that contain the postage amounts associated with dollar ranges.  However this is more complicated to program and would require a lot of thought depending on how many item types you want to include in your calculations. Hopefully the current method is fine for your purposes.

                   

                  If you need additional help, let me know.

                   

                  Weather here in the Northeast is finally warming up enough to enjoy some top-down driving!

                   

                  Cheers,

                  Kevin

                  1 person found this helpful
                  • 6. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
                    SpitfireGT6 Level 1

                    Kevin,

                     

                    Your solution sounds like it will work with the small inventory we have.  Unfortunately, I see the attachment note at the bottom of your message, but it won't highlight to open.  Am I missing something as to how to open the file, or is it not attached?

                     

                    Mike

                    • 7. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
                      Kevin Cavallo Level 4

                      Mike, uploaded attachments are automatically processed through a virus scanner before they're made available to the forum.  Right now the link says "QUEUED", which means it's waiting for the scan to be completed.  I don't know how often the scanner runs, but if you check back a little later and the QUEUED message is gone the link should be active.

                      • 8. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
                        SpitfireGT6 Level 1

                        Thanks, Kevin.  I appreciate your patience with this newbie.  I try to help out new Triumph owners with their questions on our message boards.  I know how hard it is sometimes to explain what is an easy fix for me but a major operation for them.

                         

                        Mike

                        • 9. Re: Help Calculating shipping and handling costs from numerous subtotal fields?
                          Cathy Thompson

                          Kevin,

                           

                          Are you still there?  I could really use some help.  Some of my calculations work and some don't.  So I don't know why.  If you could help me, I could send my script as an attachment.

                           

                          Please help,

                           

                          Cathy

                          cthompson@firstflightinsurance.com