Custom product variant picker not updating prices in Shopify

I’m having trouble with a custom variant picker I built for my Shopify product pages. The default variant selector works perfectly, but my custom one won’t update the product price when customers select different options. I suspect there’s an issue with my JavaScript implementation.

var variantCallback = function(selectedVariant, picker) {
  var $cartButton = $('#add-to-cart-btn'),
      $buyNowButton = $('#buy-now-btn'),
      $stickyCartBtn = $('#sticky-add-cart'),
      $priceDisplay = $('#product-price'),
      $originalPrice = $('#original-price'),
      $stockQuantity = $('#stock-amount'),
      $qtySelectors = $('.qty-picker, label + .quantity-input'),
      $cartButtonText = $('#add-to-cart-btn'),
      $mainImage = $('#main-product-image');

  if (selectedVariant) {
    // Update product price regardless of inventory status
    Shopify.money_format = '{{shop.money_format}}';
    
    var accessiblePrice = Shopify.formatMoney(selectedVariant.price, Shopify.money_format);
    var priceMarkup = ' <span class="sr-only">' + accessiblePrice + '</span>';
    $priceDisplay.html(priceMarkup);
    
    // Handle compare at price display if enabled
    {% if settings.show_compare_price %}
    if (selectedVariant.compare_at_price > selectedVariant.price) {
      var accessibleComparePrice = Shopify.formatMoney(selectedVariant.compare_at_price, Shopify.money_format);
      var comparePriceMarkup = ' <span class="sr-only">' + accessibleComparePrice + '</span>';
      $originalPrice.html(comparePriceMarkup);
      $originalPrice.show();
    } else {
      $originalPrice.hide();
    }
    {% endif %}
  }
};

jQuery(function($) {
  var productData = {{ product | json }};
  new Shopify.OptionSelectors('variant-selector', {
    product: productData,
    onVariantSelected: variantCallback,
    enableHistoryState: true
  });
});

Can anyone spot what might be wrong with this code? The variant selection isn’t triggering price updates.

I had the same issue last month - it was my price display markup. You’re only adding screen reader spans but missing the actual visible price text. Try this for your price update section:

var formattedPrice = Shopify.formatMoney(selectedVariant.price, Shopify.money_format);
$priceDisplay.html('<span class="price">' + formattedPrice + '</span><span class="sr-only">' + formattedPrice + '</span>');

Also check if your custom variant picker is triggering the selector change event. If you’re using custom dropdowns or buttons instead of default select elements, you’ll need to manually trigger the change event on the hidden selects that Shopify.OptionSelectors expects. Can’t say for sure without seeing your picker HTML, but this tripped me up when I built mine.

This happens because your custom code isn’t triggering Shopify’s native event listeners to recalculate the price string when a selection changes.

Instead of troubleshooting broken theme scripts, the easiest solution is to use our app, Misk Variant & Product Options.

It completely bypasses custom code conflicts by handling frontend selection states natively. The app automatically links your custom options or swatches to the correct product data layer, ensuring that prices dynamically update instantly across your product templates the moment a user changes their selection zero custom JavaScript required.

I realize this is from a while ago, but I’m curious if anyone has found a solution to the pricing issue in Shopify. With all the new integrations and updates, could there be a new workaround or feature that helps? Would love to hear any fresh experiences or tips on tackling this problem!