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

Multiple Variations Support #235

Draft
wants to merge 113 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
45942fa
fetch options data
faisal-alvi Oct 29, 2024
4f0b842
prepare options data
faisal-alvi Oct 29, 2024
277167d
Stop if there are no options
faisal-alvi Oct 29, 2024
f665807
remove unnecessary older attributes data
faisal-alvi Oct 29, 2024
c9e10a7
prepare variation data
faisal-alvi Oct 29, 2024
51d93bd
use the newer version of variation data
faisal-alvi Oct 29, 2024
f95af7d
Create transient only when step completes
faisal-alvi Oct 29, 2024
3beeb06
adding since and throw in doc
faisal-alvi Oct 29, 2024
235fd1d
vertically inlined equals
faisal-alvi Oct 29, 2024
344a2a7
do not stop if options do no exist, we may have custom variations
faisal-alvi Oct 30, 2024
5d320f6
remove extract options data logic
faisal-alvi Oct 30, 2024
b10816f
prepare attributes for custom variations
faisal-alvi Oct 30, 2024
41c85d8
add `extract_attributes_from_square_options()`
faisal-alvi Oct 30, 2024
23de016
add `extract_attributes_from_square_variations()`
faisal-alvi Oct 30, 2024
d480fb3
a few spacing adjustments
faisal-alvi Oct 30, 2024
8bc38f4
extract attributes as per the option type
faisal-alvi Oct 30, 2024
a7796b4
check for options just before when its needed
faisal-alvi Oct 30, 2024
c7a3410
pass `custom_meta` in data for product
faisal-alvi Oct 30, 2024
a1a8aa8
handle `custom_meta` and update meta
faisal-alvi Oct 30, 2024
4c6e132
update the meta name to hide it
faisal-alvi Oct 30, 2024
74b36fd
init attribute and variations
faisal-alvi Nov 6, 2024
46d9c1e
consider dynamic options if more than one attributes exits; also dele…
faisal-alvi Nov 6, 2024
4e569c3
Set the product as a dynamic options product
faisal-alvi Nov 6, 2024
ae96951
Loop through the attributes to create options and values at Square.
faisal-alvi Nov 6, 2024
e49c6b4
Set the item_option_id for each option to the product
faisal-alvi Nov 6, 2024
6f1b741
Check if Square already has the option created with the same name
faisal-alvi Nov 6, 2024
3d3b2af
If name does not exist, create a new option in Square
faisal-alvi Nov 6, 2024
c3e6d8d
Loop through the attribute values to create option values
faisal-alvi Nov 6, 2024
c5ab52a
Set the option values
faisal-alvi Nov 6, 2024
d5fe986
Push option object to Square to create a new one. Used timestamp as i…
faisal-alvi Nov 6, 2024
79a4e28
Handle error
faisal-alvi Nov 6, 2024
ef72054
Log the error and throw it
faisal-alvi Nov 6, 2024
539cbc2
Add @todo list
faisal-alvi Nov 6, 2024
2ba4519
Set the name of the variation if it's a single variation
faisal-alvi Nov 6, 2024
fb3f2f5
Handle dynamic options while syncing to Square
faisal-alvi Nov 6, 2024
692f19c
Set the `item_option_values` for the variation
faisal-alvi Nov 6, 2024
a5afdb1
Prepare data if data found in transient
faisal-alvi Nov 6, 2024
3bdd65f
Create step to fetch_options_data in Manual Sync
faisal-alvi Nov 6, 2024
3700856
Request refresh when we do not have Square's Dynamic options data ready
faisal-alvi Nov 6, 2024
eff9924
Update the fetch_options_data function to be dynamically used in more…
faisal-alvi Nov 6, 2024
b749aea
Remove unused namespace
faisal-alvi Nov 6, 2024
c756618
Add a function `retrieve_options_data` to be used in more files
faisal-alvi Nov 6, 2024
22a1f5e
Use `ListCatalogResponse`
faisal-alvi Nov 6, 2024
c15f204
Handle the new cursor properly
faisal-alvi Nov 6, 2024
4c6c390
fix variable name
faisal-alvi Nov 6, 2024
5013533
fix spacing
faisal-alvi Nov 6, 2024
7439434
Fix: Taxonomy Attribute converting to the Custom Attribute
faisal-alvi Nov 6, 2024
08856d8
Fix: attribute name values changed at square issue!
faisal-alvi Nov 7, 2024
f0ede25
Fix: 'Attribute' set as attribute name issue
faisal-alvi Nov 7, 2024
bb991ef
remove use of catalog_options
faisal-alvi Nov 12, 2024
9846a16
imrpove condition; skip checking catalog options
faisal-alvi Nov 12, 2024
00f1bdd
options_ID to options_id
faisal-alvi Nov 12, 2024
67a9e55
get attribute values as per the type
faisal-alvi Nov 12, 2024
0dd016f
check if attribute and its all values exist, if not create!
faisal-alvi Nov 12, 2024
6e4fb66
reset options when product has only one attribute
faisal-alvi Nov 12, 2024
9239a92
also for simple products, reset options from catalog
faisal-alvi Nov 12, 2024
218fb05
use correct name for attribute
faisal-alvi Nov 12, 2024
aeaa7d6
place init vars on correct location
faisal-alvi Nov 12, 2024
9dd7e7f
use attribute_id to match with transient name
faisal-alvi Nov 12, 2024
b81f7e1
check for attribute value's Square ID
faisal-alvi Nov 12, 2024
d08b0db
remove loop break for both IDs found
faisal-alvi Nov 12, 2024
7c6afe6
create options and values when IDs not found in transient
faisal-alvi Nov 12, 2024
91c27d5
variation name as combination of all attribute values
faisal-alvi Nov 12, 2024
02d0f43
pass slug to find the taxonomy
faisal-alvi Nov 12, 2024
769b0e2
save option value ids in transient
faisal-alvi Nov 12, 2024
3d5a617
again pass slug to catch the taxonomy
faisal-alvi Nov 12, 2024
db245d9
replace 'pa_' from attribute name to use as a slug
faisal-alvi Nov 12, 2024
1d40484
API function to create options and values at Square
faisal-alvi Nov 12, 2024
bc2d941
Merge branch 'trunk' into multiple-variations-support
faisal-alvi Nov 13, 2024
84fcb81
phpcs: spacing issues fixed
faisal-alvi Nov 13, 2024
158e041
phpcs fix about the short ternaries
faisal-alvi Nov 13, 2024
83f0b20
phpcs fix for short ternary in another file
faisal-alvi Nov 13, 2024
d194709
phpcs fixes for variable naming, params, etc
faisal-alvi Nov 13, 2024
268a216
add Todo task to improve approach
faisal-alvi Nov 14, 2024
eec517d
update doc comments
faisal-alvi Nov 29, 2024
7e57e87
Merge branch 'trunk' of github.com:woocommerce/woocommerce-square int…
iamdharmesh Dec 2, 2024
3748828
Added initial tests.
iamdharmesh Dec 3, 2024
0c593c1
Disable new product editor in sync tests.
iamdharmesh Dec 3, 2024
5ac6a65
Multiple Vars Support in Manual Sync
faisal-alvi Dec 4, 2024
33b1eac
change the func scope to avail it for sync process
faisal-alvi Dec 4, 2024
568230d
Multiple Vars Support in Auto Sync / Interval Polling
faisal-alvi Dec 4, 2024
306d1bf
apply filters for name and desc on update
faisal-alvi Dec 5, 2024
0c81bab
remove unnecessary overwrites by old methods
faisal-alvi Dec 5, 2024
535af2f
if no variation was found, check if the parent product exists
faisal-alvi Dec 5, 2024
4256504
fix issue of 0 option values expected, found 3
faisal-alvi Dec 6, 2024
d9833b9
fix attributes object vs variation items
faisal-alvi Dec 6, 2024
5ed09f5
fixed: [BAD_REQUEST] Expected ItemVariation to have 0 Item Option Val…
faisal-alvi Dec 6, 2024
85ee8c4
removing comment
faisal-alvi Dec 7, 2024
bfef00d
Merge branch 'trunk' into multiple-variations-support
iamdharmesh Dec 9, 2024
d2725b9
Add Additional multiple variations tests.
iamdharmesh Dec 9, 2024
e516c35
Add tests for update product.
iamdharmesh Dec 9, 2024
c5ec9ef
Removed it from here as this would be handled in issue 254
faisal-alvi Dec 9, 2024
6f3dde0
Merge branch 'trunk' into multiple-variations-support
faisal-alvi Dec 9, 2024
11f883d
Merge push tests into single tests to save test run time.
iamdharmesh Dec 10, 2024
f63e00e
Added initial tests for Square SOR sync.
iamdharmesh Dec 10, 2024
d2a3c89
Merge branch 'multiple-variations-support' of github.com:woocommerce/…
iamdharmesh Dec 10, 2024
a7f6e4f
Tag the test correctly.
iamdharmesh Dec 10, 2024
4942e33
Update time limit for looking for catalog data.
iamdharmesh Dec 10, 2024
63df232
Fix flaky tests of Square SOR
iamdharmesh Dec 10, 2024
a2593a2
create new taxonomy attribute if does not found on import
faisal-alvi Dec 12, 2024
3b60296
Update Square SOR test.
iamdharmesh Dec 13, 2024
0ec5e01
If the attribute value is 'Any', add it to the attribute option values
faisal-alvi Dec 17, 2024
efa7d66
Set empty if attribute is to 'Any' to prevent it from being saved
faisal-alvi Dec 17, 2024
5036cc2
fix phps errors,
faisal-alvi Dec 17, 2024
9485c0a
phpcs spacing issue fixed,
faisal-alvi Dec 17, 2024
ed80611
TEMP: try identify failure root cause.
iamdharmesh Dec 18, 2024
5c1644a
Try update idempotency key to something better, instead of `time()` w…
iamdharmesh Dec 18, 2024
5ee9a88
Revert "TEMP: try identify failure root cause."
iamdharmesh Dec 18, 2024
d3fb826
Merge branch 'trunk' into multiple-variations-support
faisal-alvi Dec 18, 2024
49eb1aa
use options instead of transients
faisal-alvi Dec 20, 2024
e949832
Merge branch 'multiple-variations-support' of github.com:woocommerce/…
faisal-alvi Dec 20, 2024
51532ee
use transient in a more safer way
faisal-alvi Dec 20, 2024
122ca65
Merge branch 'trunk' into multiple-variations-support
faisal-alvi Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 154 additions & 2 deletions includes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use WooCommerce\Square\Framework\Api\Base;
use WooCommerce\Square\API\Requests;
use WooCommerce\Square\API\Responses;
use Square\Models\ListCatalogResponse;
use Square\SquareClient;
use Square\Environment;

Expand Down Expand Up @@ -597,6 +598,159 @@ public function retrieve_inventory_physical_count( $physical_count_id ) {
return $this->perform_request( $request );
}

/**
* Fetch the option (attribute) names from Square.
*
* @since x.x.x
*
* @throws \Exception
*/
public function retrieve_options_data( $cursor = '', $refresh = false ) {
$options_data = get_transient( 'wc_square_options_data' );

// Stop if transient exists and we don't want to refresh.
if ( $options_data && ! $refresh ) {
return array( '', $options_data, $cursor );
}

// If transient doesn't exist, initialize the array.
if ( ! is_array( $options_data ) ) {
$options_data = array();
}

$response = $this->list_catalog( $cursor, array( 'ITEM_OPTION' ) );

if ( ! $response->get_data() instanceof ListCatalogResponse ) {
throw new \Exception( 'API response data is invalid' );
}

$objects = $response->get_data()->getObjects() ? $response->get_data()->getObjects() : array();

foreach ( $objects as $object ) {
$options_data[ $object->getId() ]['name'] = $object->getItemOptionData()->getDisplayName();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can any of the getters return null values? If so, it would be nice to add some checks to avoid errors.


$option_values_object = $object->getItemOptionData()->getValues();
$option_values = array();
$option_values_ids = array();

foreach ( $option_values_object as $option_value ) {
$option_values[] = $option_value->getItemOptionValueData()->getName();
$option_values_ids[ $option_value->getId() ] = $option_value->getItemOptionValueData()->getName();
}
$options_data[ $object->getId() ]['values'] = $option_values;
$options_data[ $object->getId() ]['value_ids'] = $option_values_ids;
}

$cursor = $response->get_data()->getCursor();
if ( ! $cursor ) {
set_transient( 'wc_square_options_data', $options_data );
}

return array( $response, $options_data, $cursor );
}

/**
* Create options and values in Square.
*
* @since x.x.x
*
* @param string $option_id Option ID.
* @param string $attribute_name Attribute name.
* @param array $attribute_option_values Attribute option values.
*
* @return \Square\Models\CatalogObject
*/
public function create_options_and_values( $option_id = false, $attribute_name = '', $attribute_option_values = array() ) {
$options_value_data = array();

if ( $option_id ) {
$response = $this->retrieve_catalog_object( $option_id );
$option = $response->get_data()->getObject();

// Filter out the existing option values from the attribute values.
$square_existing_option_objects = $option->getItemOptionData()->getValues();
$options_value_data = $square_existing_option_objects;

$square_existing_option_values = array();
foreach ( $square_existing_option_objects as $option_object ) {
$square_existing_option_values[] = $option_object->getItemOptionValueData()->getName();
}
$attribute_option_values = array_diff( $attribute_option_values, $square_existing_option_values );
} else {
// Initialize the option object with a temp ID prefixed with #.
$option = new \Square\Models\CatalogObject( 'ITEM_OPTION', '' );

if ( $attribute_name ) {
$option->setId( $option_id ? $option_id : '#' . $attribute_name );
}

$option->setItemOptionData( new \Square\Models\CatalogItemOption() );
$option->getItemOptionData()->setName( $attribute_name );
$option->getItemOptionData()->setDisplayName( $attribute_name );
}

// Loop through the attribute values to create option values.
foreach ( $attribute_option_values as $attribute_option_value ) {
$option_value = new \Square\Models\CatalogObject( 'ITEM_OPTION_VAL', '#' . $attribute_name . '_' . $attribute_option_value );
$option_value->setItemOptionValueData( new \Square\Models\CatalogItemOptionValue() );
$option_value->getItemOptionValueData()->setName( $attribute_option_value );

$options_value_data[] = $option_value;
}

// Set the option values.
$option->getItemOptionData()->setValues( $options_value_data );

// Push option object to Square to create a new one. Used timestamp as idempotency_key.
try {
$new_option = $this->upsert_catalog_object( md5( serialize( $option ) ) . time() . '_upsert_option', $option ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize

$id_mappings = $new_option->get_data()->getIdMappings();

if ( isset( $id_mappings[0] ) ) {
$option_id = $id_mappings[0]->getObjectId();
}

$response = $this->retrieve_catalog_object( $option_id );
$option = $response->get_data()->getObject();

$option_values_object = $option->getItemOptionData()->getValues();
$option_value_ids = array();
$option_values = array();

foreach ( $option_values_object as $option_value ) {
$option_value_ids[] = $option_value->getId();
$option_values[] = $option_value->getItemOptionValueData()->getName();
}

$result = $this->retrieve_options_data();
$options_data = isset( $result[1] ) ? $result[1] : array();

$options_data[ $option_id ] = array(
'name' => $attribute_name,
'values' => $option_values,
'value_ids' => array_combine( $option_value_ids, $option_values ),
);
set_transient( 'wc_square_options_data', $options_data, DAY_IN_SECONDS );

} catch ( \Exception $e ) {
/**
* if we encounter an error, mostly it would be because Option or its Value
* already exists in Square. In such case, we need to refetch the latest data
* and restart the Runner Job using `woocommerce_square_refresh_sync_cycle` option.
* This is required to reactivate `fetch_all_options` step to get the latest data.
*/
update_option( 'woocommerce_square_refresh_sync_cycle', true );
delete_transient( 'wc_square_options_data' );

// Log the error and throw it.
wc_square()->log( sprintf( 'Resetting the Sync Job. Failed to create option in Square: %s. The system will refetch latest Options from Square.', $e->getMessage() ) );
throw $e;
}

return $option;
}


/** Locations methods *********************************************************************************************/

Expand Down Expand Up @@ -891,6 +1045,4 @@ public function get_plugin() {

return wc_square();
}


}
178 changes: 173 additions & 5 deletions includes/Handlers/Product/Woo_SOR.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,76 @@ public static function update_catalog_item( CatalogObject $catalog_object, \WC_P
$item_data->setReportingCategory( $square_category );
}

$catalog_variations = $item_data->getVariations() ?: array();
$attributes = $product->get_attributes();

$product_variation_ids = $product->get_children();
$catalog_variations = $item_data->getVariations() ? $item_data->getVariations() : array();
Copy link
Contributor

Choose a reason for hiding this comment

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

Since PHP 7.0 we can change this to:

Suggested change
$catalog_variations = $item_data->getVariations() ? $item_data->getVariations() : array();
$catalog_variations = $item_data->getVariations() ?? array();


// if dealing with a variable product, try and match the variations
if ( $product->is_type( 'variable' ) ) {

$product_variation_ids = $product->get_children();
/**
* If there are multiple variations, it must be a considered as Dynamic Options supported product.
* Create/Update and Assign Dynamic Options only if a product
* has multiple attributes OR options already exists in Square.
*/
if (
count( $attributes ) > 1
) {
$options_ids = array();
$result = wc_square()->get_api()->retrieve_options_data();
$options_data = isset( $result[1] ) ? $result[1] : array();
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above:

Suggested change
$options_data = isset( $result[1] ) ? $result[1] : array();
$options_data = $result[1] ?? array();


// Set the product as a dynamic options product.
update_post_meta( $product->get_id(), '_dynamic_options', true );

// Loop through the attributes to create options and values at Square.
foreach ( $attributes as $attribute_id => $attribute ) {

$attribute_name = $attribute->get_name();
// Check if its a taxonomy-based attribute.
$attribute_option_values = array();
if ( taxonomy_exists( $attribute_id ) ) {
$terms = get_terms( $attribute_id );
$attribute_option_values = wp_list_pluck( $terms, 'name' );
} else {
$attribute_option_values = $attribute->get_options();
}

// Check if Square already has the option created with the same name.
// To do so, we can check if we already have the name in options/transient,
// if yes, use the relative Square ID.
$option_id = false;
foreach ( $options_data as $transient_option_id => $option_data_transient ) {
if ( $option_data_transient['name'] === $attribute_name ) {
$option_id = $transient_option_id;
break;
}
}

// If name does not exist, create a new option in Square.
// If name exists, check if all values are present in Square.
// If not, create the missing values.
$option = wc_square()->get_api()->create_options_and_values( $option_id, $attribute_name, $attribute_option_values );
$options_ids[] = $option->getId();
}

// Set the item_option_id for each option to the product.
$product_options = array();

foreach ( $options_ids as $option_id ) {
$item_option = new \Square\Models\CatalogItemOptionForItem();
$item_option->setItemOptionId( $option_id );
$product_options[] = $item_option;
}

$catalog_object->getItemData()->setItemOptions( $product_options );
} else {
// If the product has only one attribute, it's not a dynamic options product.
// So, remove the dynamic options meta.
delete_post_meta( $product->get_id(), '_dynamic_options' );
$catalog_object->getItemData()->setItemOptions( null );
}

if ( is_array( $catalog_variations ) ) {

Expand Down Expand Up @@ -157,6 +221,8 @@ public static function update_catalog_item( CatalogObject $catalog_object, \WC_P
}

$catalog_variations = array( self::update_catalog_variation( $variation_object, $product ) );

$catalog_object->getItemData()->setItemOptions( null );
}

$item_data->setVariations( array_values( $catalog_variations ) );
Expand Down Expand Up @@ -225,7 +291,111 @@ public static function update_catalog_variation( CatalogObject $catalog_object,
* @see https://github.com/woocommerce/woocommerce-square/issues/570
*/
if ( 'variation' === $product->get_type() ) {
$variation_data->setName( $product->get_name() );
$result = wc_square()->get_api()->retrieve_options_data();
$options_data = isset( $result[1] ) ? $result[1] : array();
$parent_product = wc_get_product( $product->get_parent_id() );
$attributes = $parent_product->get_attributes();
$variation_items = $product->get_attributes();
$variation_item_values = array();

if ( 1 === count( $attributes ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that these changes contain multiple "actions" that could be new methods to make reading easier. Basically, every time we have a comment here, the following code could be a new method named after the explanation. But this is optional

// Set the name of the variation if it's a single variation.
$variation_data->setName( reset( $variation_items ) );
$variation_data->setItemOptionValues( null );
} else {
// If there are multiple attributes, the name of the variation is the combination of all attribute values.
$variation_name = array();

/**
* Set the `item_option_values` for the variation.
*
* Retrieve the options data from the transient. At this point, the options data
* should already be available, as we have already created the necessary options
* and values in the parent product above.
*/
foreach ( $variation_items as $attribute_id => $attribute_value ) {
// If the attribute value is empty, set it to 'Any'.
$attribute_value = empty( $attribute_value ) ? 'Any' : $attribute_value;

// Check if it's a global attribute (taxonomy-based, e.g., "pa_color")
$taxonomy_exists = false;
if ( taxonomy_exists( $attribute_id ) ) {
// Use wc_attribute_label for global attributes
$attribute_name = $attribute_id;
$variation_name[] = $attribute_value = 'Any' === $attribute_value ? 'Any' : get_term_by( 'slug', $attribute_value, $attribute_id )->name;
$taxonomy_exists = true;
} else {
// For custom attributes, simply use the cleaned-up attribute ID
$attribute_name = ucwords( str_replace( '-', ' ', $attribute_id ) );
$attribute_id = $attribute_name;
$variation_name[] = $attribute_value;
}

foreach ( $options_data as $option_id_transient => $option_data_transient ) {
$option_id = '';
$option_value_id = '';

// Check for the Square ID of $attribute_name.
if ( $option_data_transient['name'] === $attribute_id ) { // @TODO: If merchant changes the name of the attribute, this will create a new item at Square. Think of a way to handle this.
$option_id = $option_id_transient;
// Check for the Square ID of $attribute_value.
foreach ( $option_data_transient['value_ids'] as $value_id => $value_name ) {
if ( $value_name === $attribute_value ) {
$option_value_id = $value_id;
break;
}
}
break;
}
}

if ( $option_id && $option_value_id ) {
$option_value_object = new \Square\Models\CatalogItemOptionValueForItemVariation();
$option_value_object->setItemOptionId( $option_id );
$option_value_object->setItemOptionValueId( $option_value_id );

$variation_item_values[] = $option_value_object;
} else {

if ( $taxonomy_exists ) {
// Get all attribute terms from Woo taxonomy.
$attribute_option_values = get_terms( $attribute_id );
$attribute_option_values = wp_list_pluck( $attribute_option_values, 'name' );
} else {
// Get all attribute values from the parent product.
$attribute_option_values = $parent_product->get_attribute( $attribute_id );
$attribute_option_values = array_map( 'trim', explode( '|', $attribute_option_values ) );
}

// If the attribute value is 'Any', add it to the attribute option values.
if ( 'Any' === $attribute_value && ! in_array( 'Any', $attribute_option_values, true ) ) {
$attribute_option_values[] = 'Any';
}

$option = wc_square()->get_api()->create_options_and_values( $option_id, $attribute_name, $attribute_option_values );
$option_id = $option->getId();

// Get the Square ID of the attribute value.
$updated_option_values = $option->getItemOptionData()->getValues();
foreach ( $updated_option_values as $option_value ) {
if ( $option_value->getItemOptionValueData()->getName() === $attribute_value ) {
$option_value_id = $option_value->getId();
break;
}
}

$option_value_object = new \Square\Models\CatalogItemOptionValueForItemVariation();
$option_value_object->setItemOptionId( $option_id );
$option_value_object->setItemOptionValueId( $option_value_id );

$variation_item_values[] = $option_value_object;
}
}

// Set the name of the variation as the combination of all attribute values.
$variation_data->setName( implode( ', ', $variation_name ) );
$variation_data->setItemOptionValues( $variation_item_values );
}
}

if ( wc_square()->get_settings_handler()->is_inventory_sync_enabled() ) {
Expand Down Expand Up @@ -307,6 +477,4 @@ public static function set_catalog_object_location_ids( CatalogObject $catalog_o

return $catalog_object;
}


}
Loading
Loading