Developer forum

Forum » Swift » Sort quantity breaks prices properly

Sort quantity breaks prices properly

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

In Swift you can output a list or table of quantity break prices. Can that list be sorted by quantity as the default please? In Swift 1 and Switch 2, the default output looks like this for me:

possibly because internally the quantity is sorted as a string maybe or not sorted at all? Adding the highlighted code in two places in Swift_ProductPriceTable.cshtml should solve the problem and sort the prices by quantity:

@foreach (PriceListViewModel quantityPrice in product.Prices.OrderBy(x => x.Quantity))
{
  <tr>
    <td>@quantityPrice.Quantity</td>
    <td>@quantityPrice.Price.PriceFormatted</td>
  </tr>
}

 

Thanks!

Imar

 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Moved to here: https://github.com/dynamicweb/Swift/issues/59

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

https://doc.dynamicweb.dev/documentation/fundamentals/dw10release/releasenotes/workiteminfo.html?workitemid=25753

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Nice. For anyone else needing this: the fix was made in the core platform. If you're on an older version, you can fix it yourself in Swift templates with the code I posted earlier.

 

You must be logged in to post in the forum