Developer forum

Forum » Feature requests » Sort delivery/payment options

Sort delivery/payment options


Reply
I would really appriciate a feature so I could sort delivery and payment options.

My option are listed in a dropdown box and it would be great if the prefered choice could be at the top of the dropdown.

Replies

 
Reply
The default output should give you a list of options sorted by name. If you need custom sorting, you can use an XSLT template and apply xsl:sort to the options in each loop (Paymethods, Shippingmethods).
 
Reply
 Morten,

Do you have an XSLT template you can upload so we could see how this could be done? just as an example?

thanks.
Peter


 
Reply
Your options are limited, but as an example you could sort payment methods by price.
I have attached a template showing how to do that.

If you need to do some weird custom sorting, based on values that is not available as tags, then you would probably have to add some kind of ASP.NET sortable list to the administration and render your own loops :)

/Morten
 
Reply
Thats great.

But the price can vary, since some of the cards are using percentage as a fee calculation.
I changed two places in the code, so You can sort by ID (text) instead. That way you can put the "newest" pay or shipping method on top. You would have to delete and create paymethods to get the right sorting, but it works.

 
  
  <xsl:template match="loop[@name='Paymethods']">
     <xsl:for-each select="item">
      <xsl:sort data-type="text" order="descending" select="Ecom.Cart.Paymethod.ID" />
       <label>
        <input type="radio" name="EcomCartPaymethodID" value="{Ecom.Cart.Paymethod.ID}">
           <xsl:if test="string(Ecom.Cart.Paymethod.IsSelected)">
            <xsl:attribute name="checked">checked</xsl:attribute>
          </xsl:if>
        </input>
        <xsl:value-of select="Ecom.Cart.Paymethod.Name" />
      </label>
    </xsl:for-each>    
  </xsl:template>
 
 
  <xsl:template match="loop[@name='Shippingmethods']">
    <xsl:for-each select="item">
      <xsl:sort data-type="text" order="descending" select="Ecom.Cart.Shippingmethod.ID" />
      <label>
        <input type="radio" name="EcomCartShippingmethodID" value="{Ecom.Cart.Shippingmethod.ID}">
          <xsl:if test="string(Ecom.Cart.Shippingmethod.IsSelected)">
            <xsl:attribute name="checked">checked</xsl:attribute>
          </xsl:if>
        </input>
        <xsl:value-of select="Ecom.Cart.Shippingmethod.Name" />
      </label>
    </xsl:for-each>
  </xsl:template>