Quantity selector on Product page - use value in calculation to show total units

I am selling bulk chemicals that can be sold in different package quantities - a jug with 2.5 gal, a tote with 265 gallons, or a custom gallon qty. I would like to show the customer the total gallons being added to cart by doing a calculation on the product page, before they click ‘add to quote’.

I have set up my product to have a metafield of unit (ie gallon) and the product variants to have a metafield to store the unit_qty (decimal field for conversions). The variant of 2.5 Gal Jug is unit_qty: 2.5, the 265 Gal Tote is unit_qty: 265, and then the Partial Tote (Specify # of Gallons) is unit_qty: 1. All variant prices are per unit (gallon).

I am able to display the “Total Gallons to Add:” and it works when a different variant is clicked. I have a math calculation ready to update the total gallons, but I can’t find the right syntax to access the value of the quantity selector. Also, I will need to add code for when the quantity is updated, it updates the total gallons.

Here is what it currently looks like, with corrected numbers for Add and Total Gallons. For instance, when 2.5 gal jug and qty of 4, the “Total Gallons to Add” should be 10.

(Later, I will also need to update the cart to display the Total Gallons next to the Qty.)

the test website, password is 2023

https://b-and-d-chemical.myshopify.com/

Theme is Dawn

I currently added a “custom liquid” section to the product page (below). I also made modifications to some of the theme files. To test my math function, I added 12 to the unit_qty. It is calculating correctly. I would like to replace the ‘12’ with the ‘quantity_selector’ but can’t seem to get the syntax correct!

Total {{ product.metafields.custom.unit | metafield_text }} to Add:

{% capture ‘meta_data_1’ %}
{% for variant in product.variants %}
{% assign calcMeta = variant.metafields.custom.unit_qty | plus: 12 %}

{{variant.id}}:{{ calcMeta | json}}
{% unless forloop.last %},{% endunless %}
{% endfor %}
{% endcapture %}

Actually, after sleeping on it, I decided to go a different route. So not pursuing this at this time.