Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Interchange: users

shipping.asc not working right

 

 

Interchange users RSS feed   Index | Next | Previous | View Threaded


kerry at basicq

Jun 23, 2013, 7:18 AM

Post #1 of 18 (169 views)
Permalink
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.

Kerry


arogerso at uwaterloo

Jun 24, 2013, 3:46 AM

Post #2 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 2013-06-23, at 10:18 AM, kerry blalock wrote:

> 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.
>
> Kerry
> _______________________________________________
> interchange-users mailing list
> interchange-users [at] icdevgroup
> http://www.icdevgroup.org/mailman/listinfo/interchange-users



> if (($item->{width} >= 108 and ($item->{width} <=160)) {


Looks like you are missing a closing bracket between "108" and "and".
HTH
Angus


---
Angus Rogerson, BMath, BScN, RN

Duct Tape Programmer
University of Waterloo | Retail Services | Information Systems

Visit Us Online & Right On Campus www.retailservices.uwaterloo.ca


paul at gishnetwork

Jun 24, 2013, 7:32 AM

Post #3 of 18 (164 views)
Permalink
Re: shipping.asc not working right [In reply to]

> From: interchange-users-bounces [at] icdevgroup
> [mailto:interchange-users-bounces [at] icdevgroup] On Behalf Of kerry
> blalock
> Sent: Sunday, June 23, 2013 7:19 AM
> To: interchange-users [at] icdevgroup
> 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



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


kerry at basicq

Jun 24, 2013, 8:06 AM

Post #4 of 18 (164 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 06/24/2013 10:32 AM, Paul Jordan wrote:
>> From: interchange-users-bounces [at] icdevgroup
>> [mailto:interchange-users-bounces [at] icdevgroup] On Behalf Of kerry
>> blalock
>> Sent: Sunday, June 23, 2013 7:19 AM
>> To: interchange-users [at] icdevgroup
>> 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.

Kerry





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


paul at gishnetwork

Jun 24, 2013, 8:46 AM

Post #5 of 18 (165 views)
Permalink
Re: shipping.asc not working right [In reply to]

> On 06/24/2013 10:32 AM, Paul Jordan wrote:
> >> From: interchange-users-bounces [at] icdevgroup
> >> [mailto:interchange-users-bounces [at] icdevgroup] On Behalf Of kerry
> >> blalock
> >> Sent: Sunday, June 23, 2013 7:19 AM
> >> To: interchange-users [at] icdevgroup
> >> 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


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


kerry at basicq

Jun 24, 2013, 9:05 AM

Post #6 of 18 (164 views)
Permalink
Re: shipping.asc not working right [In reply to]

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
>>>> [mailto:interchange-users-bounces [at] icdevgroup] On Behalf Of kerry
>>>> blalock
>>>> Sent: Sunday, June 23, 2013 7:19 AM
>>>> To: interchange-users [at] icdevgroup
>>>> 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
> http://www.icdevgroup.org/mailman/listinfo/interchange-users


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


paul at gishnetwork

Jun 24, 2013, 9:32 AM

Post #7 of 18 (165 views)
Permalink
Re: shipping.asc not working right [In reply to]

> 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
> >>>> [mailto:interchange-users-bounces [at] icdevgroup] On Behalf Of
> >>>> kerry blalock
> >>>> Sent: Sunday, June 23, 2013 7:19 AM
> >>>> To: interchange-users [at] icdevgroup
> >>>> 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.


I had the second foreach because your cart has unordered widths, you don't
know when your foreach will encounter long items. Yours above can
incorrectly return for a 108" item even though a 160" item is in the cart
somewhere.

You can do it like you have if you remove the returns in your foreach and
track which are being triggers somehow.

Paul

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


kerry at basicq

Jun 24, 2013, 9:49 AM

Post #8 of 18 (166 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 06/24/2013 12:32 PM, Paul Jordan wrote:
>> 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
>>>>>> [mailto:interchange-users-bounces [at] icdevgroup] On Behalf Of
>>>>>> kerry blalock
>>>>>> Sent: Sunday, June 23, 2013 7:19 AM
>>>>>> To: interchange-users [at] icdevgroup
>>>>>> 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.
>
> I had the second foreach because your cart has unordered widths, you don't
> know when your foreach will encounter long items. Yours above can
> incorrectly return for a 108" item even though a 160" item is in the cart
> somewhere.
>
> You can do it like you have if you remove the returns in your foreach and
> track which are being triggers somehow.
>
> Paul
>
> _______________________________________________
> interchange-users mailing list
> interchange-users [at] icdevgroup
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
I just found that out just as you are explaining it, so I will add the
foreach and hope that takes care of the last little detail.

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


kerry at basicq

Jun 24, 2013, 10:25 AM

Post #9 of 18 (162 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 06/24/2013 12:49 PM, kerry blalock wrote:
> On 06/24/2013 12:32 PM, Paul Jordan wrote:
>>> 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
>>>>>>> [mailto:interchange-users-bounces [at] icdevgroup] On Behalf Of
>>>>>>> kerry blalock
>>>>>>> Sent: Sunday, June 23, 2013 7:19 AM
>>>>>>> To: interchange-users [at] icdevgroup
>>>>>>> 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.
>> I had the second foreach because your cart has unordered widths, you don't
>> know when your foreach will encounter long items. Yours above can
>> incorrectly return for a 108" item even though a 160" item is in the cart
>> somewhere.
>>
>> You can do it like you have if you remove the returns in your foreach and
>> track which are being triggers somehow.
>>
>> Paul
>>
>> _______________________________________________
>> interchange-users mailing list
>> interchange-users [at] icdevgroup
>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
> I just found that out just as you are explaining it, so I will add the
> foreach and hope that takes care of the last little detail.
>
>
OK, ITT not happy with the second foreach, even after I added the
missing }. It just bypasses to the next method.

I tried

criteria <<EOC
[calcn]
foreach my $item (@$Items) {
if ($item->{width} >= 160) {
return 2;
}
} <<<<<------added here
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


and

criteria <<EOC
[calcn]
foreach my $item (@$Items) {
if ($item->{width} >= 160) {
return 2;
}
foreach my $item (@$Items) {
if ($item->{width} >= 108) {
return 1;
}
}
} <<<------added here
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




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


kerry at basicq

Jun 25, 2013, 3:26 AM

Post #10 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 06/24/2013 06:46 AM, Angus Rogerson wrote:
> On 2013-06-23, at 10:18 AM, kerry blalock wrote:
>
>> 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.
>>
>> Kerry
>> _______________________________________________
>> interchange-users mailing list
>> interchange-users [at] icdevgroup
>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>
>
>> if (($item->{width} >= 108 and ($item->{width} <=160)) {
>
> Looks like you are missing a closing bracket between "108" and "and".
> HTH
> Angus
>
>
> ---
> Angus Rogerson, BMath, BScN, RN
>
> Duct Tape Programmer
> University of Waterloo | Retail Services | Information Systems
>
> Visit Us Online & Right On Campus www.retailservices.uwaterloo.ca
>
Thanks Angus,

I did find the missing bracket and added, but it still did not work.

I finally have it kinda 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

min 3
max 3
cost 200.00

The problem I have now is if a customer adds a item that is 144" and
then adds another that is 192", to the same cart, it does not pick up
the higher shipping cost. That was why I was trying to use the
conditional statement and two different methods.

Not sure why the one above is not picking up the higher cost, but itt
seems to hold the first if statement used by each method. If I add a
192" and then add a 144", it retains the higher cost for the 192" which
is fine, but the other way around is not.

Odds are that most customers will not order the combination so I am
leaving it active for now until I can come up with the correct solution.

Thanks,

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


kerry at basicq

Jun 25, 2013, 5:09 AM

Post #11 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

>
> On 2013-06-23, at 10:18 AM, kerry blalock wrote:
>
>> 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.
>>
>> Kerry
>> _______________________________________________
>> interchange-users mailing list
>> interchange-users [at] icdevgroup
>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>
>
>
>> if (($item->{width} >= 108 and ($item->{width} <=160)) {
>
>
> Looks like you are missing a closing bracket between "108" and "and".
> HTH
> Angus
>
>
> ---
> Angus Rogerson, BMath, BScN, RN
>
> Duct Tape Programmer
> University of Waterloo | Retail Services | Information Systems
>
> Visit Us Online & Right On Campus www.retailservices.uwaterloo.ca
>
>
>
>
>
> _______________________________________________
> interchange-users mailing list
> interchange-users [at] icdevgroup
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>
Thanks Angus,

I did find the missing bracket and added, but it still did not work.

I finally have it kinda 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

min 3
max 3
cost 200.00

The problem I have now is if a customer adds a item that is 144" and
then adds another that is 192", to the same cart, it does not pick up
the higher shipping cost. That was why I was trying to use the
conditional statement and two different methods.

Not sure why the one above is not picking up the higher cost, but itt
seems to hold the first if statement used by each method. If I add a
192" and then add a 144", it retains the higher cost for the 192" which
is fine, but the other way around is not.

Odds are that most customers will not order the combination so I am
leaving it active for now until I can come up with the correct solution.

Thanks,

Kerry
>
>


BasicQ Inc
http://decor.basicq.com
800-448-0655


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


lmacielj at terra

Jun 25, 2013, 6:13 AM

Post #12 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

Le 25/06/2013 09:09, Kerry Blalock a écrit :
>> On 2013-06-23, at 10:18 AM, kerry blalock wrote:
>>
>>> 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.
>>>
>>> Kerry
>>> _______________________________________________
>>> interchange-users mailing list
>>> interchange-users [at] icdevgroup
>>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>>
>>
>>> if (($item->{width} >= 108 and ($item->{width} <=160)) {
>>
>> Looks like you are missing a closing bracket between "108" and "and".
>> HTH
>> Angus
>>
>>
>> ---
>> Angus Rogerson, BMath, BScN, RN
>>
>> Duct Tape Programmer
>> University of Waterloo | Retail Services | Information Systems
>>
>> Visit Us Online & Right On Campus www.retailservices.uwaterloo.ca
>>
>>
>>
>>
>>
>> _______________________________________________
>> interchange-users mailing list
>> interchange-users [at] icdevgroup
>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>>
> Thanks Angus,
>
> I did find the missing bracket and added, but it still did not work.
>
> I finally have it kinda 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
>
> min 3
> max 3
> cost 200.00
>
> The problem I have now is if a customer adds a item that is 144" and
> then adds another that is 192", to the same cart, it does not pick up
> the higher shipping cost. That was why I was trying to use the
> conditional statement and two different methods.
>
> Not sure why the one above is not picking up the higher cost, but itt
> seems to hold the first if statement used by each method. If I add a
> 192" and then add a 144", it retains the higher cost for the 192" which
> is fine, but the other way around is not.
>
> Odds are that most customers will not order the combination so I am
> leaving it active for now until I can come up with the correct solution.
>
> Thanks,
>
> Kerry
>>
>
> BasicQ Inc
> http://decor.basicq.com
> 800-448-0655
>
>
> _______________________________________________
> interchange-users mailing list
> interchange-users [at] icdevgroup
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>
>
>
Hi Kerry,

I am not a Perl expert but in your situation I think that you should try
like:

[calcn]
foreach my $item (@$Items) {
if ($item->{width} >= 160) {
# We have to use truckbigger shipping method
return 2;
}

if ($item->{width} >= 108_and <= 159_) {
# We have to use truckbig shipping method
return 1;
}
}
return 0;
[/calcn]


I will explain.

If width is 192 as you said, the first and the second "if" is true. So
you will end with 1 when you want "2".

Limiting the second "if" between 108 and 159 will make the second "if"
not work anymore with values above 159 and you will end with a "2".

I hope this help you.

Luiz


paul at gishnetwork

Jun 25, 2013, 7:40 AM

Post #13 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

> > On 2013-06-23, at 10:18 AM, kerry blalock wrote:
> >
> >> 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.
> >>
> >> Kerry
> >> _______________________________________________
> >> interchange-users mailing list
> >> interchange-users [at] icdevgroup
> >> http://www.icdevgroup.org/mailman/listinfo/interchange-users
> >
> >
> >
> >> if (($item->{width} >= 108 and ($item->{width} <=160)) {
> >
> >
> > Looks like you are missing a closing bracket between "108" and "and".
> > HTH
> > Angus
> >
> Thanks Angus,
>
> I did find the missing bracket and added, but it still did not work.
>
> I finally have it kinda 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
>
> min 3
> max 3
> cost 200.00
>
> The problem I have now is if a customer adds a item that is 144" and then
> adds another that is 192", to the same cart, it does not pick up the
higher
> shipping cost. That was why I was trying to use the conditional statement
and
> two different methods.
>
> Not sure why the one above is not picking up the higher cost, but itt
seems
> to hold the first if statement used by each method. If I add a 192" and
then
> add a 144", it retains the higher cost for the 192" which is fine, but the
other
> way around is not.

Because you have return's inside your if's, so it pretty much guarantee's
the logic will cease once it encounters its first item that is longer than
108".

You need to try and sort the widths before looping through them, or have two
foreach's, or leave it as you have it and instead of returning inside the
foreach, track a value to help you determine what the longest item your
foreach encounters.

Paul



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


kerry at basicq

Jun 25, 2013, 8:30 AM

Post #14 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 06/25/2013 10:40 AM, Paul Jordan wrote:
>>> On 2013-06-23, at 10:18 AM, kerry blalock wrote:
>>>
>>>> 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.
>>>>
>>>> Kerry
>>>> _______________________________________________
>>>> interchange-users mailing list
>>>> interchange-users [at] icdevgroup
>>>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>>>
>>>
>>>> if (($item->{width} >= 108 and ($item->{width} <=160)) {
>>>
>>> Looks like you are missing a closing bracket between "108" and "and".
>>> HTH
>>> Angus
>>>
>> Thanks Angus,
>>
>> I did find the missing bracket and added, but it still did not work.
>>
>> I finally have it kinda 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
>>
>> min 3
>> max 3
>> cost 200.00
>>
>> The problem I have now is if a customer adds a item that is 144" and then
>> adds another that is 192", to the same cart, it does not pick up the
> higher
>> shipping cost. That was why I was trying to use the conditional statement
> and
>> two different methods.
>>
>> Not sure why the one above is not picking up the higher cost, but itt
> seems
>> to hold the first if statement used by each method. If I add a 192" and
> then
>> add a 144", it retains the higher cost for the 192" which is fine, but the
> other
>> way around is not.
> Because you have return's inside your if's, so it pretty much guarantee's
> the logic will cease once it encounters its first item that is longer than
> 108".
>
> You need to try and sort the widths before looping through them, or have two
> foreach's, or leave it as you have it and instead of returning inside the
> foreach, track a value to help you determine what the longest item your
> foreach encounters.
>
> Paul
>
>
>
> _______________________________________________
> interchange-users mailing list
> interchange-users [at] icdevgroup
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
I have not tried this as I am not sure if it is even close to right and
do not want to blowup the program.
Am I on the right track? A little info on me: I am not a
programmer, just a hacker. :-)
truckbig: Truck Shipping
criteria <<EOC
[calcn]
$big=0;
$bigger=0;
foreach my $item (@$Items) {
if ($item->{width} >= 160) {
# We have to use oversize shipping
$bigger = 2;

}

if ($item->{width} >= 108) {
# We have to use base truck shipping

$big = 1;
}
}
return 0;
[/calcn]
EOC
min 1
max 2
cost f if ($bigger > $big) {return 170.00} elseif ($big =1)
{return 85.00}

min 3
max 3
cost 200.00

Kerry


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


paul at gishnetwork

Jun 25, 2013, 8:55 AM

Post #15 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

> On 06/25/2013 10:40 AM, Paul Jordan wrote:
> >>> On 2013-06-23, at 10:18 AM, kerry blalock wrote:
> >>>
> >>>> 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.
> >>>>
> >>>> Kerry
> >>>> _______________________________________________
> >>>> interchange-users mailing list
> >>>> interchange-users [at] icdevgroup
> >>>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
> >>>
> >>>
> >>>> if (($item->{width} >= 108 and ($item->{width} <=160)) {
> >>>
> >>> Looks like you are missing a closing bracket between "108" and "and".
> >>> HTH
> >>> Angus
> >>>
> >> Thanks Angus,
> >>
> >> I did find the missing bracket and added, but it still did not work.
> >>
> >> I finally have it kinda 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
> >>
> >> min 3
> >> max 3
> >> cost 200.00
> >>
> >> The problem I have now is if a customer adds a item that is 144" and
> >> then adds another that is 192", to the same cart, it does not pick up
> >> the
> > higher
> >> shipping cost. That was why I was trying to use the conditional
> >> statement
> > and
> >> two different methods.
> >>
> >> Not sure why the one above is not picking up the higher cost, but itt
> > seems
> >> to hold the first if statement used by each method. If I add a 192"
> >> and
> > then
> >> add a 144", it retains the higher cost for the 192" which is fine,
> >> but the
> > other
> >> way around is not.
> > Because you have return's inside your if's, so it pretty much
> > guarantee's the logic will cease once it encounters its first item
> > that is longer than 108".
> >
> > You need to try and sort the widths before looping through them, or
> > have two foreach's, or leave it as you have it and instead of
> > returning inside the foreach, track a value to help you determine what
> > the longest item your foreach encounters.
> >
> > Paul
> >
> >
> >
> > _______________________________________________
> > interchange-users mailing list
> > interchange-users [at] icdevgroup
> > http://www.icdevgroup.org/mailman/listinfo/interchange-users
> I have not tried this as I am not sure if it is even close to right and do
not want
> to blowup the program.
> Am I on the right track? A little info on me: I am not a
> programmer, just a hacker. :-)
> truckbig: Truck Shipping
> criteria <<EOC
> [calcn]
> $big=0;
> $bigger=0;
> foreach my $item (@$Items) {
> if ($item->{width} >= 160) {
> # We have to use oversize shipping
> $bigger = 2;
>
> }
>
> if ($item->{width} >= 108) {
> # We have to use base truck shipping
>
> $big = 1;
> }
> }
> return 0;
> [/calcn]
> EOC
> min 1
> max 2
> cost f if ($bigger > $big) {return 170.00} elseif ($big =1)
> {return 85.00}
>
> min 3
> max 3
> cost 200.00
>

What about something like this (untested):

[calcn]
my $big=0;
foreach my $item (@$Items) {
if ($item->{width} >= 160) {
# We have to use the largest shipping available, no
need to check anymore
return 2;
} elsif ($item->{width} >= 108) {
# We have to use base truck shipping
$big = 1;
}
}
return $big;
[/calcn]
EOC
min 1
max 1
cost 85

min 2
max 2
cost 170

min 3
max 3
cost 200.00

Paul

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


kerry at basicq

Jun 25, 2013, 9:41 AM

Post #16 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 06/25/2013 11:55 AM, Paul Jordan wrote:
>> On 06/25/2013 10:40 AM, Paul Jordan wrote:
>>>>> On 2013-06-23, at 10:18 AM, kerry blalock wrote:
>>>>>
>>>>>> 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.
>>>>>>
>>>>>> Kerry
>>>>>> _______________________________________________
>>>>>> interchange-users mailing list
>>>>>> interchange-users [at] icdevgroup
>>>>>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>>>>>
>>>>>> if (($item->{width} >= 108 and ($item->{width} <=160)) {
>>>>> Looks like you are missing a closing bracket between "108" and "and".
>>>>> HTH
>>>>> Angus
>>>>>
>>>> Thanks Angus,
>>>>
>>>> I did find the missing bracket and added, but it still did not work.
>>>>
>>>> I finally have it kinda 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
>>>>
>>>> min 3
>>>> max 3
>>>> cost 200.00
>>>>
>>>> The problem I have now is if a customer adds a item that is 144" and
>>>> then adds another that is 192", to the same cart, it does not pick up
>>>> the
>>> higher
>>>> shipping cost. That was why I was trying to use the conditional
>>>> statement
>>> and
>>>> two different methods.
>>>>
>>>> Not sure why the one above is not picking up the higher cost, but itt
>>> seems
>>>> to hold the first if statement used by each method. If I add a 192"
>>>> and
>>> then
>>>> add a 144", it retains the higher cost for the 192" which is fine,
>>>> but the
>>> other
>>>> way around is not.
>>> Because you have return's inside your if's, so it pretty much
>>> guarantee's the logic will cease once it encounters its first item
>>> that is longer than 108".
>>>
>>> You need to try and sort the widths before looping through them, or
>>> have two foreach's, or leave it as you have it and instead of
>>> returning inside the foreach, track a value to help you determine what
>>> the longest item your foreach encounters.
>>>
>>> Paul
>>>
>>>
>>>
>>> _______________________________________________
>>> interchange-users mailing list
>>> interchange-users [at] icdevgroup
>>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>> I have not tried this as I am not sure if it is even close to right and do
> not want
>> to blowup the program.
>> Am I on the right track? A little info on me: I am not a
>> programmer, just a hacker. :-)
>> truckbig: Truck Shipping
>> criteria <<EOC
>> [calcn]
>> $big=0;
>> $bigger=0;
>> foreach my $item (@$Items) {
>> if ($item->{width} >= 160) {
>> # We have to use oversize shipping
>> $bigger = 2;
>>
>> }
>>
>> if ($item->{width} >= 108) {
>> # We have to use base truck shipping
>>
>> $big = 1;
>> }
>> }
>> return 0;
>> [/calcn]
>> EOC
>> min 1
>> max 2
>> cost f if ($bigger > $big) {return 170.00} elseif ($big =1)
>> {return 85.00}
>>
>> min 3
>> max 3
>> cost 200.00
>>
> What about something like this (untested):
>
> [calcn]
> my $big=0;
> foreach my $item (@$Items) {
> if ($item->{width} >= 160) {
> # We have to use the largest shipping available, no
> need to check anymore
> return 2;
> } elsif ($item->{width} >= 108) {
> # We have to use base truck shipping
> $big = 1;
> }
> }
> return $big;
> [/calcn]
> EOC
> min 1
> max 1
> cost 85
>
> min 2
> max 2
> cost 170
>
> min 3
> max 3
> cost 200.00
>
> Paul
>
This looks much better than mine. It did not work with elseif, but looks
like it does with just an if statement. Will test more and confirm.

Thanks

Kerry


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


kerry at basicq

Jun 25, 2013, 10:05 AM

Post #17 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

On 06/25/2013 11:55 AM, Paul Jordan wrote:
> [calcn]
> my $big=0;
> foreach my $item (@$Items) {
> if ($item->{width} >= 160) {
> # We have to use the largest shipping available, no
> need to check anymore
> return 2;
> } elsif ($item->{width} >= 108) {
> # We have to use base truck shipping
> $big = 1;
> }
> }
> return $big;
> [/calcn]
> EOC
> min 1
> max 1
> cost 85
>
> min 2
> max 2
> cost 170
>
> min 3
> max 3
> cost 200.00
After several tests with different combinations, this looks like it
solves this problem.
Not sure why it did not work with elseif, but time to go to the next
project.

Thanks for the help.

truckbig: Truck Shipping
criteria <<EOC
[calcn]
my $big=0;
foreach my $item (@$Items) {
if ($item->{width} >= 160) {
# We have to use largest shipping
return 2;
}

if ($item->{width} >= 108) {
# We have to use base truck shipping
$big = 1;
}
}
return $big;
[/calcn]
EOC
min 1
max 1
cost 85.00

min 2
max 2
cost 170.00

min 3
max 3
cost 200.00


kerry at basicq

Jun 25, 2013, 10:17 AM

Post #18 of 18 (153 views)
Permalink
Re: shipping.asc not working right [In reply to]

>
>> On 06/25/2013 10:40 AM, Paul Jordan wrote:
>> >>> On 2013-06-23, at 10:18 AM, kerry blalock wrote:
>> >>>
>> >>>> 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.
>> >>>>
>> >>>> Kerry
>> >>>> _______________________________________________
>> >>>> interchange-users mailing list
>> >>>> interchange-users [at] icdevgroup
>> >>>> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>> >>>
>> >>>
>> >>>> if (($item->{width} >= 108 and ($item->{width} <=160)) {
>> >>>
>> >>> Looks like you are missing a closing bracket between "108" and
>> "and".
>> >>> HTH
>> >>> Angus
>> >>>
>> >> Thanks Angus,
>> >>
>> >> I did find the missing bracket and added, but it still did not work.
>> >>
>> >> I finally have it kinda 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
>> >>
>> >> min 3
>> >> max 3
>> >> cost 200.00
>> >>
>> >> The problem I have now is if a customer adds a item that is 144" and
>> >> then adds another that is 192", to the same cart, it does not pick up
>> >> the
>> > higher
>> >> shipping cost. That was why I was trying to use the conditional
>> >> statement
>> > and
>> >> two different methods.
>> >>
>> >> Not sure why the one above is not picking up the higher cost, but itt
>> > seems
>> >> to hold the first if statement used by each method. If I add a 192"
>> >> and
>> > then
>> >> add a 144", it retains the higher cost for the 192" which is fine,
>> >> but the
>> > other
>> >> way around is not.
>> > Because you have return's inside your if's, so it pretty much
>> > guarantee's the logic will cease once it encounters its first item
>> > that is longer than 108".
>> >
>> > You need to try and sort the widths before looping through them, or
>> > have two foreach's, or leave it as you have it and instead of
>> > returning inside the foreach, track a value to help you determine what
>> > the longest item your foreach encounters.
>> >
>> > Paul
>> >
>> >
>> >
>> > _______________________________________________
>> > interchange-users mailing list
>> > interchange-users [at] icdevgroup
>> > http://www.icdevgroup.org/mailman/listinfo/interchange-users
>> I have not tried this as I am not sure if it is even close to right and
>> do
> not want
>> to blowup the program.
>> Am I on the right track? A little info on me: I am not a
>> programmer, just a hacker. :-)
>> truckbig: Truck Shipping
>> criteria <<EOC
>> [calcn]
>> $big=0;
>> $bigger=0;
>> foreach my $item (@$Items) {
>> if ($item->{width} >= 160) {
>> # We have to use oversize shipping
>> $bigger = 2;
>>
>> }
>>
>> if ($item->{width} >= 108) {
>> # We have to use base truck shipping
>>
>> $big = 1;
>> }
>> }
>> return 0;
>> [/calcn]
>> EOC
>> min 1
>> max 2
>> cost f if ($bigger > $big) {return 170.00} elseif ($big =1)
>> {return 85.00}
>>
>> min 3
>> max 3
>> cost 200.00
>>
>
> What about something like this (untested):
>
> [calcn]
> my $big=0;
> foreach my $item (@$Items) {
> if ($item->{width} >= 160) {
> # We have to use the largest shipping available,
> no
> need to check anymore
> return 2;
> } elsif ($item->{width} >= 108) {
> # We have to use base truck shipping
> $big = 1;
> }
> }
> return $big;
> [/calcn]
> EOC
> min 1
> max 1
> cost 85
>
> min 2
> max 2
> cost 170
>
> min 3
> max 3
> cost 200.00
>
> Paul
>
>

After several tests with different combinations, this looks like it
solves this problem.
Not sure why it did not work with elseif, but time to go to the next
project.

Thanks for the help.

truckbig: Truck Shipping
criteria <<EOC
[calcn]
my $big=0;
foreach my $item (@$Items) {
if ($item->{width} >= 160) {
# We have to use largest shipping
return 2;
}

if ($item->{width} >= 108) {
# We have to use base truck shipping
$big = 1;
}
}
return $big;
[/calcn]
EOC
min 1
max 1
cost 85.00

min 2
max 2
cost 170.00

min 3
max 3
cost 200.00
BasicQ Inc
http://decor.basicq.com
800-448-0655


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

Interchange users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.