JS error: Cannot read property 'overlayContentSelector' of undefined

Created on 24 November 2020, almost 5 years ago
Updated 18 August 2025, 3 months ago

Problem/Motivation

When performing any AJAX command on a page that does not have `settings.commerceAddToCartConfirmation` object (i.e. admin pages) I get the JS error:

Uncaught TypeError: Cannot read property 'overlayContentSelector' of undefined
    at Object.attach (commerce_add_to_cart_confirmation.js?qk4s59:19)
    at Object.<anonymous> (drupal.js?qk4s59:112)
    at Function.each (jquery.min.js?v=1.7.2:2)
    at Object.Drupal.attachBehaviors (drupal.js?qk4s59:110)
    at Object.insert (ajax.js?v=7.74:590)
    at Drupal.ajax.success (ajax.js?v=7.74:448)
    at Object.success (ajax.js?v=7.74:189)
    at Object.b.success (jquery.form.min.js?v=4.2.1:11)
    at o (jquery.min.js?v=1.7.2:2)
    at Object.fireWith [as resolveWith] (jquery.min.js?v=1.7.2:2)

Steps to reproduce

In a node edit page, use the Media module "Browse" button to attach media. The following AJAX command will throw the error above.

Proposed resolution

Inside `commerce_add_to_cart_confirmation.js`, relocate:

if (typeof settings.commerceAddToCartConfirmation.overlayContentSelector != 'undefined') {
  overlayContentSelector = settings.commerceAddToCartConfirmation.overlayContentSelector;
}

into the above conditional:

if (typeof settings.commerceAddToCartConfirmation != 'undefined') {
  ...
}

Remaining tasks

Add patch with above.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States firewaller

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024