Sha256: 8d2becc19f975309d4cff6de70b3ebe3ac6b722ded3b5ea31fda9748f98c4bb3

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

window.addEventListener('DOMContentLoaded', () => {
  function updateVariantPrice(variant) {
    const variantPrice = variant.dataset.price;
    if (variantPrice) {
      document.querySelector('.price.selling').innerHTML = variantPrice;
    }
  };

  const radios = document.querySelectorAll('#product-variants input[type="radio"]');

  if (radios.length > 0) {
    const selectedRadio = document
      .querySelector('#product-variants input[type="radio"][checked="checked"]');

    updateVariantPrice(selectedRadio);
  }

  radios.forEach(radio => {
    radio.addEventListener('click', () => updateVariantPrice(radio));
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_starter_frontend-0.1.0 app/assets/javascripts/spree/frontend/product.js