Changing variant.id on change via span

Topic summary

A user is seeking help with dynamically updating variant information on a product page. They want to change variant.id when a product variant is selected, similar to how variant.sku updates automatically.

Specific Requirements:

  • Update variant.id on variant change
  • Also update variant.compare-to-price and variant.price

Current Approach:
The user references existing code that assigns the current variant using Liquid templating ({% assign current_variant = product.selected_or_first_available_variant %} and {{ current_variant.sku }}). They mention they could write custom JavaScript but suspect a CSS class solution might already exist.

Status: The question remains unanswered with no responses or solutions provided yet.

Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

Hey,

Wondering if anyone knows if its possible to change a variant.id on change of the variant like the variant.sku?

like this effectively but for variant.id (and ideally variant.compare-to-price and variant.price)

{% assign current_variant = product.selected_or_first_available_variant %}
{{ current_variant.sku }}

could write the JS for this, but figured it probably exists somewhere as a class so wanted to save myself the headache.