Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for improvements: 'where' filter on prices/rrp #1861

Open
Powellze opened this issue Dec 2, 2024 · 0 comments
Open

Request for improvements: 'where' filter on prices/rrp #1861

Powellze opened this issue Dec 2, 2024 · 0 comments

Comments

@Powellze
Copy link

Powellze commented Dec 2, 2024

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant