[ic] shipping.asc not working right

Paul Jordan paul at gishnetwork.com
Mon Jun 24 15:46:48 UTC 2013


> On 06/24/2013 10:32 AM, Paul Jordan wrote:
> >> From: interchange-users-bounces at icdevgroup.org
> >> [mailto:interchange-users-bounces at icdevgroup.org] On Behalf Of kerry
> >> blalock
> >> Sent: Sunday, June 23, 2013 7:19 AM
> >> To: interchange-users at icdevgroup.org
> >> Subject: [ic] shipping.asc not working right
> >>
> >> I am trying to add an additions shipping method to my site and seem
> >> to be having a problem with the logic. Here is the code that is
> >> giving me an
> > error on
> >> the truckbig method:
> >>
> >>
> >> truckbigger:      Oversize Truck Shipping
> >>         criteria <<EOC
> >> [calcn]
> >>         foreach my $item (@$Items) {
> >>                 if ($item->{width} >= 160) {
> >>                         # We have to use this shipping method
> >>                         return 1;
> >>                 }
> >>         }
> >>         return 0;
> >> [/calcn]
> >> EOC
> >>         min     1
> >>         max     1
> >>         cost    170.00
> >>
> >> truckbig:	Truck Shipping
> >> 	criteria <<EOC
> >> [calcn]
> >> 	foreach my $item (@$Items) {
> >> 		if (($item->{width} >= 108 and ($item->{width} <=160)) {
> >> 			# We have to use truckbigger shipping method
> >> 			return 1;
> >> 		}
> >>        }
> >>        return 0;
> >> [/calcn]
> >> EOC
> >>         min     1
> >>         max     1
> >>         cost    85.00
> >>
> >> Truckbigger works as is. But when I want to charge less for rods
> >> between
> > 108
> >> and 160, I get an error,
> >>
> >> Note: No match found for mode 'ground', quantity '', returning 0.
> >> Shipping defaults to the shippin method just below truckbig method.
> >> Need fresh eyes to help me figure out why this is not working.
> >
> > I know this might sound crazy, but try putting the truckbig above the
> > truckbigger method. I have found oddities in the past that lead me to
> > believe (at times), the system does a substring match on shipping
> > methods. I think your truckbig is never getting found because of it. I
> > am most likely wrong, but try it for giggles.
> >
> > If all you are doing is raising the price on these (assuming these are
> > not simplified for your question), you can combine them, just return a
> > '2' for above 160 and have 2 cost 170. You can also explicitly call
> > truckbigger from inside of truckbig like this:
> >
> >     min         2
> >     max         2
> >     cost        >>truckbigger
> >
> > Your #comment in truckbig is incorrect BTW.
> >
> > Oh, one other thing (that I am probably also wrong about). At times, I
> > have noticed that things don't work as I expect if they don't have
> > one-more-final cost above my maximum. IIRC I may have reported this
> > and it may have been an actual bug (and fixed) but I have a habit of
adding
> just one more anyways.
> > So for you, you can add a...
> >
> >    min 3
> >    max 3
> >    cost 200
> >
> > It will never be invoked, but things have led me to believe it is
necessary.
> >
> > As you can see, my shipping.asc is by habit built upon folklore and
> > wives-tales, but probably like you, once I get it working, I don't
> > dare question anything I have done.
> >
> >
> > Paul
> >
> Tried switching and truckbig works but I get same error when I add one
that
> should be truckbigger. Where would I insert the
> 
>     min         2
>     max         2
>     cost        >>truckbigger
> ?? And should I use two if statements instead of the two conditions?
> I missed the comment as I have tried using two if statements and some
other
> attempts to get it to work.
> 
> Also found missing ), but adding it did not help.
> 
> I do have other shipping methods in shipping.asc it is just these two that
are
> not playing nice together.


So we've determined that they both work, but only the top one works when
invoked. That's normally what I would run into. At this stage, I would try
adding in a final range on both methods...

       min     1
       max     1
       cost    170.00

       min     2
       max     2
       cost    200.00

and similar for truckbig. I have found that if the range I want to use is
the last range listed, sometimes it does not work. But again, that might be
fixed (or have been folklore).

But, if you just want to adjust price only, then couldn't you just do:

       criteria <<EOC
 [calcn]
         foreach my $item (@$Items) {
                 if ($item->{width} >= 160) {
                         return 2;
                }
         foreach my $item (@$Items) {
                 if ($item->{width} >= 108) {
	        return 1;
                }
         }
         return 0;
[/calcn]
EOC

       min     1
       max    1
       cost    85.00

       min     2
       max    2
       cost    170.00

       min     3
       max    3
       cost    200.00

(the last one thrown in to ward off bad spirits). Untested.

Paul




More information about the interchange-users mailing list