Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

theme-product-form onSubmit option ID setting conflicts with buy now button #146

Description

@n-dawson

The way the product form handles changing options doesn't work with the "Buy It Now" button on product pages.

When you have a set of options, ProductForm will update the value of the "id" field to use the chosen variant. This happens through a submit listener on the product form.

ProductForm.prototype._onSubmit = function(options, event) {
  event.dataset = this._getProductFormEventData();

  this._setIdInputValue(event.dataset.variant.id);

  if (options.onFormSubmit) {
    options.onFormSubmit(event);
  }
};

When you press add to cart, the ID gets updated, and the correct variant is added to the user's cart. When you click the Buy It Now button however, that submit handler doesn't fire and the default variant shows in the checkout instead.

The simplest solution would likely be to move the point at which the id value is updated from submit to an option being changed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions