Although Solidus isn't set up out-of-the-box to allow multiple cart-forms on the same page, it is still good practice to make sure that the updatePrice function only interacts with the form fields on the correct product.
I added an optional context argument to the updatePrice function so that it will only update the price inside the context it is given (i.e. for the correct #cart-form).
I also added a test to illustrate the above context problem and several tests to exercise the calculators from the front end users perspective.
I also moved the partial lookup logic (first look in customization_type, then calculator_type, then fallback to a default) to a helper to clean up the view layer a bit.
…ePrice function.
Although Solidus isn't set up out-of-the-box to allow multiple cart-forms on the same page, it is still good practice to make sure that the updatePrice function only interacts with the form fields on the correct product.
I added an optional context argument to the updatePrice function so that it will only update the price inside the context it is given (i.e. for the correct #cart-form).
I also added a test to illustrate the above context problem and several tests to exercise the calculators from the front end users perspective.
I also moved the partial lookup logic (first look in customization_type, then calculator_type, then fallback to a default) to a helper to clean up the view layer a bit.