Shopify compareAtPrice "0.00" vs Blank: Automated Collections, Inverted Sale Prices, and Broken Badges
A compare-at price looks like a single number in the admin. In the data model it has three meaningfully different states: not set
(null), set to zero ("0.00"), and set to some other value, which may sit above, at, or below the
selling price. Integrations, CSV files and humans blur these all the time, and each state behaves differently in collection rules, theme code and product feeds.
The most common source of "0.00" is a sync that writes 0 when it means "no sale". Microsoft's Business Central connector shipped exactly
that bug in its bulk price path until BCApps PR #8125;
we dissect it in the ERP sync guide. This page is about the damage once the zeros are in your catalog.
1. The state matrix
| Stored compare-at | "is empty" rule | "is not empty" rule | Liquid {% if variant.compare_at_price %} | Liquid compare_at_price > price |
|---|---|---|---|---|
null (not set) | matches | no | false | false |
0.00 | no match | matches | true | false |
| below price (79 vs 99) | no match | matches | true | false |
| equal to price | no match | matches | true | false |
| above price (valid sale) | no match | matches | true | true |
Red cells are where stores get hurt.
Where the zeros come from
- Bulk sync templates that format an empty decimal as
0instead of emittingnull(the BC case above). - Supplier and PIM exports that fill every numeric column, so "no compare-at" travels as
0or0.00in the CSV. - Spreadsheet edits where someone "cleans" blanks with fill-down or a formula like
=IF(A2="",0,A2). - Flow or script workflows that "end a sale" by writing
0back instead of clearing the field.
Every one of these looks harmless in a spreadsheet, which is why the bad state can sit in a catalog for months before a collection or badge exposes it. Three of the red cells deserve a closer look.
2. Automated collections silently re-sort your catalog
Smart collections often use the condition Compare-at price is empty for "full price" or "new season" collections, and
Compare-at price is not empty for a Sale collection. Because 0.00 is a value, a sync that writes zeros does two things at once:
- products fall out of the "is empty" collection (once none of their variants are empty), so your full-price landing page shrinks without anyone editing it;
- products join the "is not empty" Sale collection as soon as one variant carries
0.00, so customers see full-price items under a Sale banner.
You can tighten a Sale collection to Compare-at price is greater than 0, which excludes the zeros. It will not exclude inverted values like 79 vs 99, because collection rules cannot compare two fields. The condition is a mitigation; cleaning the data is the fix.
3. Liquid treats zero as true
In Liquid only nil and false are falsy. 0 is truthy. A theme or app block that checks presence instead of comparing values
will render a strikethrough for 0.00:
{%- comment -%} fragile: renders "was $0.00" and a broken badge {%- endcomment -%}
{%- if variant.compare_at_price -%}
<s>{{ variant.compare_at_price | money }}</s>
<span class="badge">
-{{ variant.compare_at_price | minus: variant.price | times: 100 | divided_by: variant.compare_at_price }}%
</span>
{%- endif -%}
With 0.00, the badge division hits zero and the storefront prints Liquid error: divided by 0 in place of the badge. With an inverted
value it prints a negative discount such as --25%. Shopify's reference themes compare compare_at_price > price, which is why
many stores never notice the bad data until a custom section or a third-party badge app goes live. Harden every place you render sale styling:
{%- liquid
assign cmp = variant.compare_at_price | default: 0
assign on_sale = false
if cmp > variant.price
assign on_sale = true
endif
-%}
{%- if on_sale -%}
<s>{{ cmp | money }}</s> {{ variant.price | money }}
<span class="badge">-{{ cmp | minus: variant.price | times: 100 | divided_by: cmp }}%</span>
{%- endif -%}
4. Feeds and discount display
Feed tools commonly send compare-at as the regular price and the selling price as the sale price when a sale exists. A tool that maps the fields without
checking compare_at_price > price can submit a regular price of 0.00, or a "sale" price higher than the regular price — both
of which shopping channels reject or flag. Discount apps and "You save" widgets inherit the same arithmetic problems as the Liquid badge above.
5. Find every affected variant with a bulk export
Don't rely on admin search filters for compare-at values. Export every variant with a bulk operation and filter locally — it is cheap, complete, and gives you an audit file.
mutation {
bulkOperationRunQuery(query: """
{ productVariants { edges { node {
id sku price compareAtPrice
product { id handle status }
} } } }
""") {
bulkOperation { id status }
userErrors { field message }
}
}
# poll until COMPLETED, then download the JSONL from `url`
query ($id: ID!) { node(id: $id) { ... on BulkOperation { status objectCount url } } }
python -B -c "
import json, csv
plan = []
for line in open('variants.jsonl', encoding='utf-8'):
v = json.loads(line)
cmp = v.get('compareAtPrice')
if cmp is None:
continue
price, cmpf = float(v['price']), float(cmp)
if cmpf == 0:
plan.append((v['product']['id'], v['id'], v['sku'], v['price'], cmp, 'ZERO'))
elif cmpf <= price:
plan.append((v['product']['id'], v['id'], v['sku'], v['price'], cmp, 'INVERTED'))
with open('compare_at_cleanup_plan.csv', 'w', newline='', encoding='utf-8') as f:
w = csv.writer(f); w.writerow(['product_id','variant_id','sku','price','compare_at','reason']); w.writerows(plan)
print(len(plan), 'variants to clear')
"
6. Clear them with null, product by product
Review the plan file first. Then group rows by product_id and send one productVariantsBulkUpdate per product. The value must be
null; "0" recreates the problem you are fixing.
mutation Clear($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
productVariantsBulkUpdate(productId: $productId, variants: $variants) {
productVariants { id compareAtPrice }
userErrors { field message }
}
}
# variables
{
"productId": "gid://shopify/Product/8123456789",
"variants": [
{ "id": "gid://shopify/ProductVariant/4412345678901", "compareAtPrice": null },
{ "id": "gid://shopify/ProductVariant/4412345678902", "compareAtPrice": null }
]
}
- Run the first 10 products, then re-check the Sale and full-price collections on the storefront.
- Respect GraphQL cost limits: read
extensions.cost.throttleStatusand back off instead of retrying blindly. - Pause the integration that wrote the zeros before running the clean-up, or it will undo your work tonight.
- In CSV workflows, a literal
0in the compare-at column sets0.00. Express "no sale" as an empty cell and confirm the behavior on a 10-product canary with your import tool's settings. - Fix the writer: it should send
nullto clear and omit the field when nothing changed.
0, the zeros come back on the next run and your
collections quietly drift again. Data hygiene here is a continuous job, not a one-off script.
Check an export for free
The browser-local checker flags $0 and unparseable prices and inverted compare-at prices (set, but below price) without uploading anything. For compare-at values of exactly 0.00, run the export filter from section 5.
FAQ
Why are products missing from my "Compare at price is empty" collection?
Their compare-at price is stored as 0.00 rather than empty. 0.00 is a value, so the "is empty" condition does not match it, and the same products start matching "is not empty" rules such as a Sale collection.
How do I clear a compare-at price through the Shopify API?
Send compareAtPrice: null in productVariantsBulkUpdate (or the equivalent variant update). Sending "0" or "0.00" stores a zero value instead of clearing the field.
What is an inverted compare-at price?
A compare-at price that is set but is lower than or equal to the selling price. Well-built themes hide the sale styling, but custom badges can show negative discounts, and feed tools that map compare-at to the regular price can submit a sale price higher than the regular price.
Can I build a Sale collection that ignores 0.00 compare-at prices?
Partly. "Compare at price is greater than 0" excludes 0.00, but Shopify collection rules cannot compare two fields, so inverted values above zero still match. The reliable fix is cleaning the data and keeping it clean.