Shopify / Shopify/shopify_app

issues with bottle deposit calculations

Open
#2,043 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.9k
Forks
739
Avg merge
21h 2m
Merged PRs (30d)
1

Description

We are working on a Shopify store using the Tinker theme. I need to implement a bottle deposit calculation for liquor sales in British Columbia (BC). My current code (generated by AI) is unstable and causing several issues.
Current Problems:

  • Missing/Incorrect Properties: Line items for liquor are not correctly carrying properties[_deposit] or properties[_containers_per_unit]. This causes the sync script to "guess," resulting in missing or duplicated deposits.
  • Unstable Sync Triggers: The script currently listens to button clicks or uses update.js via variant IDs. This results in:
    • Deleted items being "added back" by the script.
    • Discrepancies between the Cart (hidden) and Checkout (visible).
    • Single items being split into multiple lines.
      Proposed Solution/Requirements:
  1. Configuration (theme.liquid):
    Place the window.BC_DEPOSIT_SYNC configuration in the , specifically after {{ content_for_header }} and before the sync script.
    {%- assign deposit_product = all_products['bottle-deposit'] -%}
<script> window.BC_DEPOSIT_SYNC = { depositHandle: "bottle-deposit", variantIdByValue: { {% if deposit_product %} {% for v in deposit_product.variants %} "{{ v.option1 | strip }}": {{ v.id }}{% unless forloop.last %},{% endunless %} {% endfor %} {% endif %} } }; </script> <script defer src="{{ 'bottle-deposit-sync.js' | asset_url }}"></script>
  1. Product Form Updates (buy-buttons.liquid):
    Clean up duplicate property inputs. Only one set of _deposit and _containers_per_unit hidden inputs should exist, updating dynamically with the variant picker.
  2. Sync Script Logic (bottle-deposit-sync.js):
    The goal for the script is:
  • Calculate deposits based strictly on line item properties.
  • Automatically reduce/remove deposits when the parent item is removed.
  • Use a fetch interceptor (patching window.fetch) to trigger a re-sync after any /cart/add.js, change.js, or update.js call.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting theme.liquid, buy-buttons.liquid, and bottle-deposit-sync.js, then trace the existing cart add, change, and update requests. Confirm how variant pickers populate the hidden line-item properties and how the current sync is triggered. Done means deposits are calculated from those properties, removed parent items do not reappear, and cart and checkout remain consistent without unwanted line splitting.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.