Skip to content

Wrong initialization sequence in mage.priceBox widget (price-box.js) #6117

Closed
@yariksheptykin

Description

@yariksheptykin

During initialization of priceBox the following code is executed:

this._setDefaultsFromPriceConfig();
this._setDefaultsFromDataSet();

However _setDefaultsFromPriceConfig relies on this.options.productId. This value is set in setDefaultsFromDataSet here.

Current sequence of function calls leaves this.options.productId always empty in this._setDefaultsFromPriceConfig().

I stumbled upon this issue while trying to add a custom price type and configuring priceBox to render it. With the current sequence of calls priceBox seem to ignore the configuration of the price types.

Preconditions

No pre-conditions. Just debug the function using browser developer tools.

Steps to reproduce

  1. Create a product which has a price.
  2. Navigate to the product details page
  3. Using your JS debugger set the breakpoint on https://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/view/base/web/js/price-box.js#L206

Expected result

  1. The line should be executed.

Actual result

  1. This line never gets called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions