Skip to content

[FIX] Og_Subscription/js/switch-subscription deps #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tpierce-somethingdigital

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 by window.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-processor estimateTotals() workflow, but only if the window.checkoutConfig is available, as it would be within the already checked for "checkout" URL path pages. Only require classes that depend on window.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 these estimateTotals() 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.

Fix Ordergroove_Subscription/js/switch-subscription module definition dependencies requiring `window.checkoutConfig` causing errors.

Fix [Issue 24](ordergroove#24).

Only load models that require `window.checkoutConfig` if it is available.
Stop errors caused by `window.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-processor `estimateTotals()` workflow, but only if the `window.checkoutConfig` is available, as it would be within the already checked for "checkout" URL path pages.  Only require classes that depend on `window.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 these `estimateTotals()` 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant