• Resolved adwjoe

    (@adwjoe)


    Hi,

    In trying to get to the bottom of how to import custom attributes I discovered that the Square API that’s being used is almost 2 years out of date.

    Looking in the composer.json file we have the following:

    {
        "name": "square/connect",
        "version": "2.20190814.2",
        "version_normalized": "2.20190814.2.0",
        "source": {
            "type": "git",
            "url": "https://github.com/square/connect-php-sdk.git",
            "reference": "d778579a9f42c06d4eb68bcd78e7371f1b2f8f94"
        },
        etc etc...
    }

    Crucially we can see that the version is "version": "2.20190814.2". The versioning control is simply a date, and looking at all the API releases we can see that the version 2019-08-14 as used by this plugin is almost 2 years old and is 23 versions out of date.

    Using Square’s API explorer I’ve been able to understand why I can’t find the custom attributes anywhere when logging responses. It’s because the 2019-08-14 version doesn’t return them in the Search Catalog Objects that’s being used.

    If you have a log in you can use the API explorer. If you view the output this is the difference:

    Version 2019-08-14
    https://developer.squareup.com/explorer/square_2019-08-14/catalog-api/search-catalog-objects

    Example output:

    {
       "type": "ITEM",
       "id": "H2I7PCDDSU6T6F5JY4Y7BUYD",
       "updated_at": "2021-06-10T16:41:13.671Z",
       "version": 1623343273671,
       "is_deleted": false,
       "present_at_all_locations": true,
       "image_id": "KXHVKSG6Z6ZZOTRVYVJPCJIT",
       "item_data": {
         "name": "Mesmerism",
         "description": "10.0% ABV\n\nTriple IPA\n\nA mesmerisingly punchy triple IPA with a juicy explosion of flavour.\n\nBig hitting hops complement smooth malts to create a beer that's hypnotically moreish.",
         "label_color": "593c00",
         "visibility": "PRIVATE",
         "category_id": "5SSRTFVDYTIXNHY3BR4TCRLW",
         "variations": [
           {
             "type": "ITEM_VARIATION",
             "id": "PN46PFCEFL53Y3YPNO3DY4CF",
             "updated_at": "2021-06-10T16:41:13.671Z",
             "version": 1623343273671,
             "is_deleted": false,
             "present_at_all_locations": true,
             "item_variation_data": {
               "item_id": "H2I7PCDDSU6T6F5JY4Y7BUYD",
               "name": "Regular",
               "sku": "2106-voc-mes",
               "ordinal": 1,
               "pricing_type": "FIXED_PRICING",
               "price_money": {
                 "amount": 650,
                 "currency": "GBP"
               },
               "location_overrides": [
                 {
                   "location_id": "LXTZYFD9F9350",
                   "track_inventory": true
                 }
               ]
             }
           }
         ],
         "product_type": "REGULAR",
         "skip_modifier_screen": false,
         "ecom_available": true,
         "ecom_visibility": "VISIBLE"
       }
    },

    Latest version (at time of writing is Version 2021-06-16)
    https://developer.squareup.com/explorer/square/catalog-api/search-catalog-objects

    Example output of same product:

    {
       "type": "ITEM",
       "id": "H2I7PCDDSU6T6F5JY4Y7BUYD",
       "updated_at": "2021-06-10T16:41:13.671Z",
       "version": 1623343273671,
       "is_deleted": false,
       "present_at_all_locations": true,
       "image_id": "KXHVKSG6Z6ZZOTRVYVJPCJIT",
       "item_data": {
         "name": "Mesmerism",
         "description": "10.0% ABV\n\nTriple IPA\n\nA mesmerisingly punchy triple IPA with a juicy explosion of flavour.\n\nBig hitting hops complement smooth malts to create a beer that's hypnotically moreish.",
         "label_color": "593c00",
         "visibility": "PRIVATE",
         "category_id": "5SSRTFVDYTIXNHY3BR4TCRLW",
         "variations": [
           {
             "type": "ITEM_VARIATION",
             "id": "PN46PFCEFL53Y3YPNO3DY4CF",
             "updated_at": "2021-06-10T16:41:13.671Z",
             "version": 1623343273671,
             "is_deleted": false,
             "custom_attribute_values": {
               "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee": {
                 "name": "Can Size",
                 "string_value": "440ml",
                 "custom_attribute_definition_id": "55EM4DQW4DOQTKN5IHAPKMEL",
                 "type": "STRING",
                 "key": "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee"
               },
               "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c": {
                 "name": "ABV",
                 "custom_attribute_definition_id": "LKK2USVTVFJEN7CZVRP3LZPA",
                 "type": "NUMBER",
                 "number_value": "10.0",
                 "key": "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c"
               },
               "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d": {
                 "name": "Brewery",
                 "string_value": "Vocation Brewery",
                 "custom_attribute_definition_id": "JCQGGR7ZXCOFLNILFZTFLBT7",
                 "type": "STRING",
                 "key": "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d"
               }
             },
             "present_at_all_locations": true,
             "item_variation_data": {
               "item_id": "H2I7PCDDSU6T6F5JY4Y7BUYD",
               "name": "Regular",
               "sku": "2106-voc-mes",
               "ordinal": 1,
               "pricing_type": "FIXED_PRICING",
               "price_money": {
                 "amount": 650,
                 "currency": "GBP"
               },
               "location_overrides": [
                 {
                   "location_id": "LXTZYFD9F9350",
                   "track_inventory": true
                 }
               ],
               "stockable": true
             }
           }
         ],
         "product_type": "REGULAR",
         "skip_modifier_screen": false,
         "ecom_available": true,
         "ecom_visibility": "VISIBLE"
       }
    },

    As you can see those very important custom attributes are returned in the latest version, 2021-06-16 but not in the version that this plugin is using, 2019-08-14.

    "custom_attribute_values": {
       "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee": {
         "name": "Can Size",
         "string_value": "440ml",
         "custom_attribute_definition_id": "55EM4DQW4DOQTKN5IHAPKMEL",
         "type": "STRING",
         "key": "Square:13273a54-ddc5-4b0e-96ce-9193283a20ee"
       },
       "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c": {
         "name": "ABV",
         "custom_attribute_definition_id": "LKK2USVTVFJEN7CZVRP3LZPA",
         "type": "NUMBER",
         "number_value": "10.0",
         "key": "Square:bbe746d0-63d2-42d4-84ac-9e5ca322c60c"
       },
       "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d": {
         "name": "Brewery",
         "string_value": "Vocation Brewery",
         "custom_attribute_definition_id": "JCQGGR7ZXCOFLNILFZTFLBT7",
         "type": "STRING",
         "key": "Square:e742a6d8-8a7c-4372-88b7-fee64e079f6d"
       }
    },

    This is the key to making the filters work on my website without having to do laborious data entry jobs multiple times.

    My Question
    What is the safest way to update the Square API version that is being used?

    I need the custom attributes to be synced with my WooCommerce store, and they are not available under the version being used. Therefore I need to update the API version before I can sort out the custom attributes. Please advise.

    Thanks in advance!

    Joe

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support Sol J. a11n

    (@solstudioim)

    Hi @adwjoe

    Thanks for your very detail explanation.

    As we mentioned before that at the moment the import scripts, used to import product data from Square to WooCommerce, only looks into specific data and doesn’t take into account custom attributes from Square.

    This is something that may change in the future, but for right now it does not.

    You can find the import script here – woocommerce-square/includes/Sync/Product_Import.php

    I know that’s not the kind of answer you’re looking for. But at the moment, it’s not supported yet.

    Thread Starter adwjoe

    (@adwjoe)

    Hi Sol J. a11n,

    Thanks for getting back to me.

    I was specifically asking what is the safest way to update the Square API being used? It is version 2019-08-14 and I wish to update it to 2021-06-16. Is it handled through Composer or is there a WordPress specific way of handling this?

    Please can you advise on that. I need the custom attributes and cannot wait for some indeterminate point in the future until this plugin can handle it ??

    Cheers,
    Joe

    P.s. The reason why I’m asking this is that import script doesn’t even receive the custom attributes. Here is a log of the raw data as received from Square (same product) before it has been parsed in any way. You won’t find any custom attributes there.

    [0] => SquareConnect\Model\CatalogObject Object
    (
        [type:protected] => ITEM
        [id:protected] => H2I7PCDDSU6T6F5JY4Y7BUYD
        [updated_at:protected] => 2021-06-10T16:41:13.671Z
        [version:protected] => 1623343273671
        [is_deleted:protected] =>
        [catalog_v1_ids:protected] =>
        [present_at_all_locations:protected] => 1
        [present_at_location_ids:protected] =>
        [absent_at_location_ids:protected] =>
        [image_id:protected] => KXHVKSG6Z6ZZOTRVYVJPCJIT
        [item_data:protected] => SquareConnect\Model\CatalogItem Object
        (
            [name:protected] => Mesmerism
            [description:protected] => 10.0% ABV
    
    Triple IPA
    
    A mesmerisingly punchy triple IPA with a juicy explosion of flavour.
    
    Big hitting hops complement smooth malts to create a beer that's hypnotically moreish.
            [abbreviation:protected] =>
            [label_color:protected] => 593c00
            [available_online:protected] =>
            [available_for_pickup:protected] =>
            [available_electronically:protected] =>
            [category_id:protected] => 5SSRTFVDYTIXNHY3BR4TCRLW
            [tax_ids:protected] =>
            [modifier_list_info:protected] =>
            [variations:protected] => Array
            (
                [0] => SquareConnect\Model\CatalogObject Object
                (
                    [type:protected] => ITEM_VARIATION
                    [id:protected] => PN46PFCEFL53Y3YPNO3DY4CF
                    [updated_at:protected] => 2021-06-10T16:41:13.671Z
                    [version:protected] => 1623343273671
                    [is_deleted:protected] =>
                    [catalog_v1_ids:protected] =>
                    [present_at_all_locations:protected] => 1
                    [present_at_location_ids:protected] =>
                    [absent_at_location_ids:protected] =>
                    [image_id:protected] =>
                    [item_data:protected] =>
                    [category_data:protected] =>
                    [item_variation_data:protected] => SquareConnect\Model\CatalogItemVariation Object
                    (
                        [item_id:protected] => H2I7PCDDSU6T6F5JY4Y7BUYD
                        [name:protected] => Regular
                        [sku:protected] => 2106-voc-mes
                        [upc:protected] =>
                        [ordinal:protected] => 1
                        [pricing_type:protected] => FIXED_PRICING
                        [price_money:protected] => SquareConnect\Model\Money Object
                        (
                            [amount:protected] => 650
                            [currency:protected] => GBP
                        )
    
                        [location_overrides:protected] => Array
                        (
                            [0] => SquareConnect\Model\ItemVariationLocationOverrides Object
                            (
                                [location_id:protected] => LXTZYFD9F9350
                                [price_money:protected] =>
                                [pricing_type:protected] =>
                                [track_inventory:protected] => 1
                                [inventory_alert_type:protected] =>
                                [inventory_alert_threshold:protected] =>
                            )
    
                        )
    
                        [track_inventory:protected] =>
                        [inventory_alert_type:protected] =>
                        [inventory_alert_threshold:protected] =>
                        [user_data:protected] =>
                        [service_duration:protected] =>
                        [item_option_values:protected] =>
                        [measurement_unit_id:protected] =>
                    )
    
                    [tax_data:protected] =>
                    [discount_data:protected] =>
                    [modifier_list_data:protected] =>
                    [modifier_data:protected] =>
                    [time_period_data:protected] =>
                    [product_set_data:protected] =>
                    [pricing_rule_data:protected] =>
                    [image_data:protected] =>
                    [measurement_unit_data:protected] =>
                    [item_option_data:protected] =>
                    [item_option_value_data:protected] =>
                )
    
            )
    
            [product_type:protected] => REGULAR
            [skip_modifier_screen:protected] =>
            [item_options:protected] =>
        )
    
        [category_data:protected] =>
        [item_variation_data:protected] =>
        [tax_data:protected] =>
        [discount_data:protected] =>
        [modifier_list_data:protected] =>
        [modifier_data:protected] =>
        [time_period_data:protected] =>
        [product_set_data:protected] =>
        [pricing_rule_data:protected] =>
        [image_data:protected] =>
        [measurement_unit_data:protected] =>
        [item_option_data:protected] =>
        [item_option_value_data:protected] =>
    )
    • This reply was modified 3 years, 5 months ago by adwjoe.
    Plugin Support Ryan Ray, a11n

    (@ryanr14)

    Hi @adwjoe,

    I’m not aware of a clear or preferred way to update the API in use in the plugin, or what, if any issues, would arise from doing so. That sort of work exceeds what we could support here. Thought another community member could chime in in case they’ve done something similar.

    Nonetheless, the code for the plugin is available via GitHub and you could open an issue there and see what our developers think about getting the API updated in the first place.

    Then if you’ve not already seen maybe you can decipher how the Square API is integrated and could be updated.

    https://github.com/woocommerce/woocommerce-square/issues

    Richard Bakos

    (@resonancedesigns)

    Maybe not open source anymore? That link leads to a 404. Looks like the repo was taken down or made private. I couldn’t find it in all of the 154 repos under woocommerce.

    Plugin Support Stuart Duff – a11n

    (@stuartduff)

    Automattic Happiness Engineer

    Hey @resonancedesigns,

    Looking at the Github issue tracker today it does seem that the repository is now private for some reason. With regards to updating the API I’m not too sure what that would involve and it may take a lot more work in the plugin than simply updating the API call.

    I’ve posted an issue on the WooCommerce Square GitHub repository for us to make our developers aware of your findings. Regrettably, I don’t have an answer as yet which I could share with you as to whether the API will be updated but our developers will definitely investigate this further.

    Richard Bakos

    (@resonancedesigns)

    Thank you for the info @stuartduff

    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @resonancedesigns @adwjoe

    We’re happy to help here! We’ll reply back to this thread with any update from our developers around this when we can.

    If updating the API version used is urgent for you, this would fall outside our Scope of support. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thanks,

    Thread Starter adwjoe

    (@adwjoe)

    Hi,

    Thank you for the responses and discussion on this thread!

    I’ve been busy with other matters and haven’t progressed this any further than when posted.

    Just to post where I was at. The Square changelog is here. I was starting to go through the changelog to find if there were any breaking changes between v2019-08-14 as used currently by woocommerce-square and v2021-06-16 as desired to upgrade to.

    The Square composer page is here. I have PHP and Composer installed locally and ran the following:
    ? ~ composer require square/square

    This outputted:

    Updating dependencies (including require-dev)
    Package operations: 3 installs, 0 updates, 0 removals
      - Installing apimatic/jsonmapper (v2.0.2): Loading from cache
      - Installing apimatic/unirest-php (2.0.0): Loading from cache
      - Installing square/square (12.0.0.20210616): Loading from cache

    Square now seems to have a couple of dependencies in jsonmapper and unirest-php both within the apimatic folder. My next step was to copy these vendor folders into the woocommerce-square vendor folder and see what happened next.

    vendor/
    ..apimatic/
    ..square/

    The folder apimatic does not exist in the current vendor folder so would be an addition. The square folder would replace the existing square folder. I’m not sure how I would go about updating the composer classmap or any of the other composer files within vendor but I’m sure there’s a way to do it. I would just start comparing files and updating as seemed necessary.

    Or ideally this is updated by the devs before I get to it.

    As a request, would you please ask the devs if they could leave the composer.json file within the file structure at the next release? It’s only saving a few kbs by removing, but it would be much nicer for anyone like myself trying to update API’s when they are 2 years out of date to simply update the composer.json file than having to manually attempt all these steps.

    Hopefully will hear an update soon!

    Cheers,
    Joe

    Plugin Support Sol J. a11n

    (@solstudioim)

    Hi @adwjoe

    Thanks for sharing further about your work on the plugin.

    We have received a feedback from our developers.

    Basically we have an open issue to update Square package, it’s a low priority as the objects response we get from this 2-year old Square package is all we need to run the plugin.

    However, we have marked this as high priority now. But it will be re-marked low priority if this will require a lot of re-work to refactor other requests (payment, sync, import, etc).

    I hope that helps!

    Thread Starter adwjoe

    (@adwjoe)

    Hi,

    Is there any update on this? Is it something that will be done in the immediate future? With the security breach in WooCommerce that was reported recently I’m now concerned for security reasons too that this API is so old.

    I paused development on the site but will be resuming again in the coming weeks.

    Cheers,
    Joe

    Thread Starter adwjoe

    (@adwjoe)

    The latest release doesn’t appear to have updated the API. Nothing in the release log about that.

    2.5.2 – 2021.07.21

    Fix – Product and inventory data not being synced due to duplicate/orphaned product metadata in database. PR#625
    Fix – Bypass SSL verification when checking background job processing eligibility. PR#624
    Fix – Correctly apply taxes in the Order API request and report accurate percentages. PR#559

    melinda a11n

    (@melindahelt)

    Automattic Happiness Engineer

    Hi there! We don’t have any updates on this issue at this time, but as mentioned this is tagged as a high priority issue. I don’t have an ETA on when this will be addressed at this time.

    Plugin Support Augustus – a11n

    (@augustuswp)

    Hello there,
    as Melinda explained above, we do not have an ETA for this issue at the moment but our developers are working on it.

    You can refer to the changelog to see when a new update is released and if it includes a patch for this.

    I will be marking this thread as Resolved for now since there’s nothing else we can do other than wait, but please feel free to open a new one if you want to ask for more information or get a status update from us.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Safest way to update Square API? It’s 2 years out of date…’ is closed to new replies.