From 77a6c79ca1accbd14a879d89f9203d11c332f292 Mon Sep 17 00:00:00 2001 From: Andrew Wikel Date: Wed, 8 Apr 2026 12:37:16 +0200 Subject: [PATCH 1/2] fix: add null guards for getItemOptionData()->getValues() calls Three locations in API.php call getItemOptionData()->getValues() without checking for null, crashing sync jobs when Square returns ITEM_OPTION objects with null item_option_data. Apply the same guard pattern already used in Product_Import.php (lines 789 and 894). Fixes SQUARE-292. --- includes/API.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/API.php b/includes/API.php index 7099a501..2685796e 100644 --- a/includes/API.php +++ b/includes/API.php @@ -641,7 +641,7 @@ public function retrieve_options_data( $cursor = '', $refresh = false ) { $option_name = $this->get_item_option_name_from_catalog_object( $object ); $options_data[ $object->getId() ]['name'] = $option_name; - $option_values_object = $object->getItemOptionData()->getValues(); + $option_values_object = $object->getItemOptionData() ? $object->getItemOptionData()->getValues() : array(); $option_values = array(); $option_values_ids = array(); @@ -680,7 +680,7 @@ public function create_options_and_values( $option_id = false, $attribute_name = $option = $response->get_data()->getObject(); // Filter out the existing option values from the attribute values. - $square_existing_option_objects = $option->getItemOptionData()->getValues(); + $square_existing_option_objects = $option->getItemOptionData() ? $option->getItemOptionData()->getValues() : array(); $options_value_data = $square_existing_option_objects; $square_existing_option_values = array(); @@ -726,7 +726,7 @@ public function create_options_and_values( $option_id = false, $attribute_name = $response = $this->retrieve_catalog_object( $option_id ); $option = $response->get_data()->getObject(); - $option_values_object = $option->getItemOptionData()->getValues(); + $option_values_object = $option->getItemOptionData() ? $option->getItemOptionData()->getValues() : array(); $option_value_ids = array(); $option_values = array(); From 355a8a3a4bb676602b8b1cb09fc6abf3cde695f6 Mon Sep 17 00:00:00 2001 From: Andrew Wikel Date: Wed, 8 Apr 2026 12:37:38 +0200 Subject: [PATCH 2/2] fix: add null guard for getItemOptionData()->getValues() in Woo_SOR The update_catalog_variation() method calls getItemOptionData()->getValues() without checking for null, matching the same pattern fixed in API.php. Part of SQUARE-292. --- includes/Handlers/Product/Woo_SOR.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Handlers/Product/Woo_SOR.php b/includes/Handlers/Product/Woo_SOR.php index ab7c6c57..9d774533 100644 --- a/includes/Handlers/Product/Woo_SOR.php +++ b/includes/Handlers/Product/Woo_SOR.php @@ -382,7 +382,7 @@ public static function update_catalog_variation( CatalogObject $catalog_object, $option_id = $option->getId(); // Get the Square ID of the attribute value. - $updated_option_values = $option->getItemOptionData()->getValues(); + $updated_option_values = $option->getItemOptionData() ? $option->getItemOptionData()->getValues() : array(); foreach ( $updated_option_values as $option_value ) { if ( $option_value->getItemOptionValueData()->getName() === $attribute_value ) { $option_value_id = $option_value->getId();