Announcement

Collapse
No announcement yet.

Exclude Pickup/Delivery from Sort Shipping Options by Price

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

    Exclude Pickup/Delivery from Sort Shipping Options by Price

    Store is using this to override the Shipping Priorities and sort by price:

    Code:
    <mvt:comment> Sorts Shipping Methods Low to Hi </mvt:comment>
    <mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:shippingmethods, ':price', 1)" />
    Now the Scheduled Pickup & Delivery by Miva module has been added into the mix and it would be really nice to be able to place it at the bottom of the shipping options. Of course, this isn't doable as is because the Priorities are ignored and it gets placed at the head of the class because it's price is $0.00. I do suspect there is a way to exclude it but my mvt:do foo is weak.

    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

    #2
    In most cases, you can sort shipping by shipping method. i.e., ground will always be lower than, 2nd day which will always be lower than next day, etc. so, see if you can do that and then go back to using priority.
    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
      Originally posted by Bruce - PhosphorMedia View Post
      In most cases, you can sort shipping by shipping method. i.e., ground will always be lower than, 2nd day which will always be lower than next day, etc. so, see if you can do that and then go back to using priority.
      In "most" cases yes, you can sort by shipping method. But this isn't most cases, hence the need for the original override and now the need for a touch of magic.

      ps... RTHOMASDESIGN - thanks!
      Leslie Kirk
      Miva Certified Developer
      Miva Merchant Specialist since 1997
      Previously of Webs Your Way
      (aka Leslie Nord leslienord)

      Email me: [email protected]
      www.lesliekirk.com

      Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

      Comment


        #4
        Try this if you haven't already figured it out:

        Code:
        <mvt:comment> Sorts Shipping Methods Low to Hi </mvt:comment>
        <mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:shippingmethods, ':price', 1)" />
        
        <mvt:comment> Filters Array with Expression to Include (EQ) Pickup/DeliveryShipping Methods (by code) and Copies them into an "Excluded Array" and Returns the Count into a Variable </mvt:comment>
        <mvt:assign name="l.settings:excluded_methods_count" value="miva_array_filter( l.settings:shippingmethods, 1, l.settings:method, 'l.settings:method:code EQ \'Insert_Pickup_Method_Code\' OR l.settings:method:code EQ \'Insert_Delivery_Method_Code\'', l.settings:excluded_methods )" />
        
        <mvt:comment> Filters Array with Expression to Exclude (NE) Pickup/Delivery Shipping Methods (by code) and Copies the Remaining Methods into a "New Array" (Essentially rewriting original array to exclude those methods) </mvt:comment>
        <mvt:assign name="l.result" value="miva_array_filter( l.settings:shippingmethods, 1, l.settings:method, 'l.settings:method:code NE \'Insert_Pickup_Method_Code\' AND l.settings:method:code NE \'Insert_Delivery_Method_Code\'', l.settings:shippingmethods )" />
        
        <mvt:comment> Copies all methods (l.settings:excluded_methods_count) from "Excluded Array" (l.settings:excluded_methods ) into "New Array" (l.settings:shippingmethods), starting with 1st position of "Excluded Array" (1) and inserting the methods at the last position of "New Array" (-1).   </mvt:comment>
        <mvt:assign name="l.result" value="miva_array_merge( l.settings:excluded_methods, 1, l.settings:excluded_methods_count, l.settings:shippingmethods, -1 )"/>
        
        <mvt:foreach array="shippingmethods" iterator="method">
        Nick Harkins
        www.loveisarose.com

        Comment


          #5
          Thanks Nick! I have an ignorant question. When I view the source I see "pickupdelivery:pickup" is this Pickup or Delivery method code or do I split them up? Or do I use the method name?
          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment


            #6
            I've done something wrong. This produces an error

            Error compiling template: Line 63: Expression compilation failed: Found additional argument 'p' while looking for operator

            Code:
            <mvt:comment> Sorts Shipping Methods Low to Hi </mvt:comment>
            <mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:shippingmethods, ':price', 1)" />
            
            <mvt:comment> Filters Array with Expression to Include (EQ) Pickup/DeliveryShipping Methods (by code) and Copies them into an "Excluded Array" and Returns the Count into a Variable </mvt:comment>
            <mvt:assign name="l.settings:excluded_methods_count" value="miva_array_filter(l.settings:shippingmethod s, 1, l.settings:method, 'l.settings:method:code EQ 'pickup'', l.settings:excluded_methods)" />
            
            <mvt:comment> Filters Array with Expression to Exclude (NE) Pickup/Delivery Shipping Methods (by code) and Copies the Remaining Methods into a "New Array" (Essentially rewriting original array to exclude those methods) </mvt:comment>
            <mvt:assign name="l.result" value="miva_array_filter(l.settings:shippingmethod s, 1, l.settings:method, 'l.settings:method:code NE 'pickup'', l.settings:shippingmethods)" />
            
            <mvt:comment> Copies all methods (l.settings:excluded_methods_count) from "Excluded Array" (l.settings:excluded_methods ) into "New Array" (l.settings:shippingmethods), starting with 1st position of "Excluded Array" (1) and inserting the methods at the last position of "New Array" (-1). </mvt:comment>
            <mvt:assign name="l.result" value="miva_array_merge(l.settings:excluded_method s, 1, l.settings:excluded_methods_count, l.settings:shippingmethods, -1)"/>
            
            <mvt:foreach array="shippingmethods" iterator="method">
            LOL, I should have waited for Nick's reply.
            Leslie Kirk
            Miva Certified Developer
            Miva Merchant Specialist since 1997
            Previously of Webs Your Way
            (aka Leslie Nord leslienord)

            Email me: [email protected]
            www.lesliekirk.com

            Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

            Comment


              #7
              Originally posted by lesliekirk View Post
              I've done something wrong. This produces an error




              Code:
              <mvt:comment> Sorts Shipping Methods Low to Hi </mvt:comment>
              <mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:shippingmethods, ':price', 1)" />
              
              <mvt:comment> Filters Array with Expression to Include (EQ) Pickup/DeliveryShipping Methods (by code) and Copies them into an "Excluded Array" and Returns the Count into a Variable </mvt:comment>
              <mvt:assign name="l.settings:excluded_methods_count" value="miva_array_filter(l.settings:shippingmethod s, 1, l.settings:method, 'l.settings:method:code EQ 'pickup'', l.settings:excluded_methods)" />
              
              <mvt:comment> Filters Array with Expression to Exclude (NE) Pickup/Delivery Shipping Methods (by code) and Copies the Remaining Methods into a "New Array" (Essentially rewriting original array to exclude those methods) </mvt:comment>
              <mvt:assign name="l.result" value="miva_array_filter(l.settings:shippingmethod s, 1, l.settings:method, 'l.settings:method:code NE 'pickup'', l.settings:shippingmethods)" />
              
              <mvt:comment> Copies all methods (l.settings:excluded_methods_count) from "Excluded Array" (l.settings:excluded_methods ) into "New Array" (l.settings:shippingmethods), starting with 1st position of "Excluded Array" (1) and inserting the methods at the last position of "New Array" (-1). </mvt:comment>
              <mvt:assign name="l.result" value="miva_array_merge(l.settings:excluded_method s, 1, l.settings:excluded_methods_count, l.settings:shippingmethods, -1)"/>
              
              <mvt:foreach array="shippingmethods" iterator="method">
              LOL, I should have waited for Nick's reply.
              Lol sorry for the late reply.

              As for choosing to use the shipping method code vs the name either should work.

              I believe the "pickupdelivery" part of "pickupdelivery:pickup" is the module code so just use what the method code is.

              I would imagine you should be able to just grab the method code from that module.

              If for some reason you can't find it there you can try the following:

              Using the same browser you're logged into Miva with open a another tab and go to the site in question. Add a product to the cart and then start checkout however you need to trigger the pickup/delivery shipping method to display as an option on OSEL (use local address on OCST?).

              Once your'e on OSEL (for the site in question) stay on that page of checkout and go back to your Miva Tab.

              Then in Miva go to the OSEL template and check the token list to grab the pickup/delivery method code.


              And for the error:
              You need to escape the single quotes in the 2 miva_array_filter expressions:

              Code:
              <mvt:assign name="l.settings:excluded_methods_count" value="miva_array_filter(l.settings:shippingmethods, 1, l.settings:method, 'l.settings:method:code EQ \'pickup\'', l.settings:excluded_methods)" />
              
              <mvt:assign name="l.result" value="miva_array_filter(l.settings:shippingmethods, 1, l.settings:method, 'l.settings:method:code NE \'pickup\'', l.settings:shippingmethods)" />
              Last edited by SidFeyDesigns; 02-20-23, 12:39 PM.
              Nick Harkins
              www.loveisarose.com

              Comment

              Working...
              X