[FIX] Og_Subscription/js/switch-subscription deps #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Ordergroove_Subscription/js/switch-subscription module definition dependencies requiring
window.checkoutConfig
causing errors.Fix Issue #24.
Only load models that require
window.checkoutConfig
if it is available. Stop errors caused bywindow.checkoutConfig
being undefined in Magento_Checkout/js/model/quote & Magento_Checkout/js/model/cart/totals-processor/default.The workflow that uses these models is the same the click event listeners for both the 'og-optin-button' & 'og-optout-button', with the expectation that the page URL path begins with "checkout". Add
estimateTotals
function that runs the cart totals-processorestimateTotals()
workflow, but only if thewindow.checkoutConfig
is available, as it would be within the already checked for "checkout" URL path pages. Only require classes that depend onwindow.checkoutConfig
if it is defined. Do nothing if it is not defined. This does not change any of the current expected functionality of the switch-scripts file, continuing to run theseestimateTotals()
calls where they would run before. It does prevent attempting to load models that are unavailable due to missing required data dependencies, preventing calls that cannot be made anyway and the errors that accompany those bad calls. The data is available and the calls are made in the places where it was expected to be available before.