<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 25/06/2013 09:09, Kerry Blalock a
      écrit :<br>
    </div>
    <blockquote
      cite="mid:2a3d80901810b5cbbd78dddfb62609b7.squirrel@carlc.com"
      type="cite">
      <pre wrap="">
</pre>
      <blockquote type="cite">
        <pre wrap="">
On 2013-06-23, at 10:18 AM, kerry blalock wrote:

</pre>
        <blockquote type="cite">
          <pre wrap="">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
<a class="moz-txt-link-abbreviated" href="mailto:interchange-users@icdevgroup.org">interchange-users@icdevgroup.org</a>
<a class="moz-txt-link-freetext" href="http://www.icdevgroup.org/mailman/listinfo/interchange-users">http://www.icdevgroup.org/mailman/listinfo/interchange-users</a>
</pre>
        </blockquote>
        <pre wrap="">


</pre>
        <blockquote type="cite">
          <pre wrap="">         if (($item->{width} >= 108 and ($item->{width} <=160)) {
</pre>
        </blockquote>
        <pre wrap="">

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 <a class="moz-txt-link-abbreviated" href="http://www.retailservices.uwaterloo.ca">www.retailservices.uwaterloo.ca</a>





_______________________________________________
interchange-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:interchange-users@icdevgroup.org">interchange-users@icdevgroup.org</a>
<a class="moz-txt-link-freetext" href="http://www.icdevgroup.org/mailman/listinfo/interchange-users">http://www.icdevgroup.org/mailman/listinfo/interchange-users</a>

</pre>
      </blockquote>
      <pre wrap="">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
</pre>
      <blockquote type="cite">
        <pre wrap="">

</pre>
      </blockquote>
      <pre wrap="">

BasicQ Inc
<a class="moz-txt-link-freetext" href="http://decor.basicq.com">http://decor.basicq.com</a>
800-448-0655


_______________________________________________
interchange-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:interchange-users@icdevgroup.org">interchange-users@icdevgroup.org</a>
<a class="moz-txt-link-freetext" href="http://www.icdevgroup.org/mailman/listinfo/interchange-users">http://www.icdevgroup.org/mailman/listinfo/interchange-users</a>



</pre>
    </blockquote>
    Hi Kerry,<br>
    <br>
    I am not a Perl expert but in your situation I think that you should
    try like:<br>
    <br>
    <pre wrap="">[calcn]
        foreach my $item (@$Items) {
                if ($item->{width} >= 160) {
                        # We have to use truckbigger shipping method
                        return 2;
               }

               if ($item->{width} >= 108 <u>and <= 159</u>) {
                        # We have to use truckbig shipping method
                        return 1;
               }
       }
       return 0;
[/calcn]</pre>
    <br>
    I will explain.<br>
    <br>
    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".<br>
    <br>
    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".<br>
    <br>
    I hope this help you.<br>
    <br>
    Luiz<br>
  </body>
</html>