Skip to content
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

Fix error when Google Merchant Center account is undefined #2518

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

jorgemd24
Copy link
Contributor

@jorgemd24 jorgemd24 commented Aug 12, 2024

Changes proposed in this Pull Request:

Closes https://wordpress.org/support/topic/typeerror-cannot-read-properties-of-undefined-2/

This PR fixes an issue where googleMCAccount is undefined when checking if notification_service_enabled is active. This can happen if the Google account isn’t connected or is missing scopes, leading to the following error:

Cannot read properties of undefined (reading ‘notification_service_enabled’)

if ( ! google || google.active === 'no' || ! scope.gmcRequired ) {
return {
googleMCAccount: undefined,
isResolving: isResolvingGoogle,
hasFinishedResolution: hasFinishedResolutionGoogle,
// If a user has not yet connected their Google account or the connected Google account
// has not been granted necessary access permissions for Google Merchant Center, then
// the precondition doesn't meet.
isPreconditionReady: false,
};
}

Screenshots:

Detailed test instructions:

  1. Go here:
    'active' => array_key_exists( 'status', $status ) && ( 'connected' === $status['status'] ) ? 'yes' : 'no',
    and set the active to no
  2. Go to the Settings page.
  3. Check that you don't see the following error:

image

Additional details:

Changelog entry

Fix - Error when Google Merchant Center account is undefined while checking the notification service enabled property.

@github-actions github-actions bot added type: bug The issue is a confirmed bug. changelog: fix Took care of something that wasn't working. labels Aug 12, 2024
Copy link

codecov bot commented Aug 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.7%. Comparing base (b80d149) to head (90e9747).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             develop   #2518      +/-   ##
============================================
- Coverage       64.7%   63.7%    -1.0%     
============================================
  Files            798     326     -472     
  Lines          22940    5084   -17856     
  Branches        1222    1228       +6     
============================================
- Hits           14844    3240   -11604     
+ Misses          7930    1677    -6253     
- Partials         166     167       +1     
Flag Coverage Δ
js-unit-tests 63.7% <100.0%> (-<0.1%) ⬇️
php-unit-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...s/src/components/enable-new-product-sync-notice.js 100.0% <100.0%> (ø)

... and 477 files with indirect coverage changes

@jorgemd24 jorgemd24 self-assigned this Aug 12, 2024
@jorgemd24 jorgemd24 requested a review from a team August 12, 2024 18:31
@jorgemd24 jorgemd24 marked this pull request as ready for review August 12, 2024 18:31
Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jorgemd24 jorgemd24 merged commit 7df1acb into develop Aug 12, 2024
9 checks passed
@jorgemd24 jorgemd24 deleted the fix/error-when-googleMCAccount-is-undefined branch August 12, 2024 20:57
@eason9487 eason9487 changed the title Fix Error when google mc account is undefined Fix error when Google Merchant Center account is undefined Aug 14, 2024
@eason9487 eason9487 mentioned this pull request Aug 14, 2024
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Took care of something that wasn't working. type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants