Request for improvements: 'where' filter on prices/rrp
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
There is an issue on using the 'where' filter on product.variants with prices that doesn't work to correctly pull out valid prices from the variant array.
This occurs when using price with a number or string.
Liquid to verify:
assign test_all_variant_prices = product.variants | map: 'price'
echo test_all_variant_prices | json | prepend: '<p>Variant prices: ' | append: '</p>'
assign test1_product_price = product.variants | where: 'price', 12502
echo test1_product_price | json | prepend: '<p>Price tested with number: ' | append: '</p>'
assign test2_product_price = product.variants | where: 'price', '12502'
echo test2_product_price | json | prepend: '<p>Price tested with string: ' | append: '</p>'
Output from the liquid above:
Variant prices: [12502]
Price tested with number: []
Price tested with string: []
Interesting though is that if you do the following with a map you can prove that the where does work, but it doesn't seem to work on returning the variant objects.
assign test1 = product.variants | map: 'price'
echo test1 | json | prepend: '<p>output 1: ' | append: '</p>'
assign test2 = product.variants | map: 'price' | where: 12502
echo test2 | json | prepend: '<p>output 2: ' | append: '</p>'
Output from the liquid:
output 1: [12502]
output 2: [12502]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied Liquid snippets, focusing on the where filter applied to product.variants and mapped prices. Trace the filter's handling of variant objects and numeric or string values; it is done when valid matching variants are returned while the existing mapped-price behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100