WooCommerce.NET icon indicating copy to clipboard operation
WooCommerce.NET copied to clipboard

Error deserializing the object of type SystemStatusTheme in SystemStatus

Open ghhv opened this issue 4 months ago • 0 comments

  • Wordpress version, WooCommerce version and WooCommerce.NET version WooCommerce 9.3.1 on WordPress 6.6.2 with WooCommerceNET 0.8.6

  • Steps to replicate the issue wc.SystemStatus.Get() fails with error below.

My WordPress install is returning the following in SystemStatus which gives the error below.

"theme": {
        "author_url": "https://aweb.site",
        "has_outdated_templates": false,
        "has_woocommerce_file": false,
        "has_woocommerce_support": true,
        "is_child_theme": true,
        "name": "Theme Name",
        "overrides": [
            {
                "core_version": "3.6.0",
                "file": "awebsite/woocommerce/content-product.php",
                "version": "3.6.0"
            },
            {
                "core_version": "3.0.0",
                "file": "awebsite/woocommerce/single-product/up-sells.php",
                "version": "3.0.0"
            }
        ],
        "parent_author_url": "https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dash",
        "parent_name": "Hello Elementor",
        "parent_version": "3.1.1",
        "parent_version_latest": "3.1.1",
        "version": "2.0.2",
        "version_latest": 0  **(this is also invalid or a bug)**
    },
  • Details of the error message if there is any This issue was raised previously: by @maxim-skuvault System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type WooCommerceNET.WooCommerce.v3.SystemStatus. End element 'item' from namespace '' expected. Found element 'file' from namespace ''. ---> System.Xml.XmlException: End element 'item' from namespace '' expected. Found element 'file' from namespace ''. at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)

    Any chance @XiaoFaye that this (and version_latest - see below) can be marked virtual so it can be overridden perhaps OR change to this class below? [DataMember(EmitDefaultValue = false)] public List<string> overrides { get; set; }

As per data sample, I'm getting an array of this object type in my data:

public List<Override>? overrides { get; set; }  (use this instead?)

public class Override
  {
      [JsonPropertyName("core_version")]
      public string? CoreVersion { get; set; }

      [JsonPropertyName("file")]
      public string? File { get; set; }

      [JsonPropertyName("version")]
      public string? Version { get; set; }
  }

You can see this in the WordPress source but they have not updated the API doc anywhere I could find to suit.

EXTRA ISSUE: Strangely, my WordPress instance is also returning the number zero for theme.version_latest instead of a string (see above) which also causes SystemStatus.Get() to fail.. According to ChatGPT "likely means that WooCommerce was unable to retrieve the latest version of the theme from the WordPress.org theme repository". I'm using a child theme which makes sense but more likely a bug.

ghhv avatar Sep 24 '24 13:09 ghhv