[ic] shipping.asc not working right

kerry blalock kerry at basicq.com
Mon Jun 24 16:05:28 UTC 2013


On 06/24/2013 11:46 AM, Paul Jordan wrote:
>> 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

I did get it working with this:
truckbig:       Truck Shipping
        criteria <<EOC
[calcn]
        foreach my $item (@$Items) {
                if ($item->{width} >= 160) {
                        # We have to use truckbigger shipping method
                        return 2;
               }
               if ($item->{width} >= 108) {
                        # We have to use truckbig shipping method
                        return 1;
               }
       }
       return 0;
[/calcn]
EOC
        min     1
        max     1
        cost    85.00

        min     2
        max     2
        cost    170.00

I am still getting the error, but it has tested ok for the two truck
prices which is what I wanted. Have to look at the other methods to see
if something is wrong with them. And, like you said, once it is working,
I shutter as changing more stuff. Did not seem to need the second
foreach you had with your suggestion. I first tried with the redirect,
but that failed, so I changed cost to 170.00 and that is working. Will
have to test more to be sure I did not break something else as it is live.

Thanks Paul

>
> _______________________________________________
> interchange-users mailing list
> interchange-users at icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users




More information about the interchange-users mailing list