Announcement

Collapse
No announcement yet.

foreach

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    foreach

    I can use some help with this foreach loop. I'll comment to show what I think should be happening but it isn't.

    Code:
    <select name="PaymentMethod"  onchange="selOnAcctCheck(this);" >
    <option value="">Select Payment Option</option>
    <mvt:foreach array="paymentmethods" iterator="method">
        <mvt:if expr="NOT ('Mohawk' CIN l.settings:method:name)">
            <mvt:if expr="l.settings:method:code EQ 'COD'">
                <option value="&mvte:method:module;:&mvte:method:code;" id="selOnAcct">On Account</option>
            </mvt:if>
        <mvt:else>
            <option value="&mvte:method:module;:&mvte:method:code;">&mvt:method:name;</option>
        </mvt:if>
    </mvt:foreach>
    </select>
    So this is what I think I'm doing

    Code:
    <mvt:foreach array="paymentmethods" iterator="method">
    * Loop through array
    
    <mvt:if expr="NOT ('Mohawk' CIN l.settings:method:name)">
    * If the method does NOT contain 'Mohawk' in the method name 
    * then execute the following IF statement which
    * checks to see if the method is EQ to COD
    * if it is it adds an ID
    
    <mvt:if expr="l.settings:method:code EQ 'COD'">
        <option value="&mvte:method:module;:&mvte:method:code;" id="selOnAcct">On Account</option>
    </mvt:if>
    
    * ELSE exit the IFNOT 'Mohawk' condition (so if its gets here sole remaining method should be 'Mohawk')
    * which we want to show.
    
        <mvt:else>
            <option value="&mvte:method:module;:&mvte:method:code;">&mvt:method:name;</option>
        </mvt:if>

    Why the gymnastics? I want to hide all shipping methods if the 'Mohawk' flat rate shipping is returned. The COD method - which is re-purposed Miva flat rate set to 0.00 for people who pick up at our warehouse. In this case Mohawk charges us $89 no matter what (using their trucks) so if a customer picks up at our warehouse they still have to pay. We don't want people selecting the $0 option.

    Information

    We are using KingWebMaster's Advanced Shipping Manager for shipping. We use Miva's flat rate shipping module for the single COD/Pickup at warehouse $0.00 option.

    Problems

    -The Miva shipping method rules do not work to exclude the COD/Pickup method, neither the EXCLUDES nor EXCLUDED BY.
    -The Advanced Shipping Manager returns the methods names as ADVANCEDSHIPPING:1 to ADVANCEDSHIPPING:(total number of methods). These method names are not always the same (depending on number of relevant shipping methods returned) given parameters (weight, LTL or ground, Lift gate or not etc). So 'Standard Ground' could be ADVANCEDSHIPPING:3 one time and ADVANCEDSHIPPING:1 another or not returned at all if the total weight makes it an LTL shipment.

    Notes

    We are working with Miva towards a new site design over the next 6 months. In the meantime I just want to make sure that the Warehouse Pickup $0.00 (re-purposed COD using Miva flat rate shipping) is not visible if Mohawk Shipping is the shipping option.

    If the customer adds the floor tile product that qualifies for the 'Mohawk' shipping method all methods are hidden EXCEPT the warehouse pickup/COD.

    I tried creating the method in Advanced Shipping Manager but still cannot EXCLUDE with Shipping Rules.

    Thanks.
    Last edited by habreu; 01-07-16, 05:22 PM.

    #2
    Re: foreach

    The first thing do do is be sure you're correctly matching variable values in your expressions. The built in Token list may be able to expose these but for sure our Inspector module will.
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      Re: foreach

      Thanks Bruce. I have Inspector and will run through it.

      Comment


        #4
        Re: foreach

        While not efficient, it might be easier to run through the shipping array once to see if Mohawk is in there, and if so set a flag, then wrap the original foreach loop in a test based on that flag.

        Otherwise, you'd need to ensure that the Mohawk rate would ALWAYS be first (which you might be able to do with shipping rules.
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          Re: foreach

          Thanks Bruce. The shipping rules didn't work (to make it first). I'm actually going to poke around some more as I think there might have been some old modules that sorted the shipping rules and may be a conflict. Otherwise I'll test your other suggestion. It might be good enough for now as it is a low volume store right now and in 6 months or so we'll have a new Miva site with all new templates - so just want to get it done for now.
          Last edited by habreu; 01-11-16, 10:54 AM.

          Comment


            #6
            Re: foreach

            Gosh I'm a goofball. I won't even post my error. I thin k I have it sorted out - thanks.

            Comment

            Working...
            X