Skip to content

Some default settings may be missing for new activations #408

@tomalec

Description

@tomalec

Describe the bug:

I didn't find any specific bug, but I see a chance for such :)
The review of #400 revealed that the maybe_set_defaults function introduced in 2.0.0 breaks the behavior of WC_Integration::init_settings.

If the extension (2.0.0+) is newly activated - meaning there were no settings yet. It saves the settings with a single property set 'ga_product_identifier' => 'product_id'. Then, when the WC_Google_Analytics constructor is called, the `init_settings, which is supposed to set all the defaults to what's defined in the form fields, does nothing, as it finds that the settings object is already set.

Steps to reproduce:

  1. Deactivate, uninstall GA4W.
  2. Remove woocommerce_google_analytics_settings entry from wp_options
  3. Install and activate using CLI
wp plugin install woocommerce-google-analytics-integration
wp plugin activate  woocommerce-google-analytics-integration
  1. Visit any page as a guest.

Expected behavior:

woocommerce_google_analytics_settings settings should contain all the defaults

Actual behavior:

woocommerce_google_analytics_settings has only ga_product_identifier set.

Additional details:

Maybe it's not a bug, but the desired effect, but I find it confusing and bug-prone to have two sets of defaults.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions