woocommerce / woocommerce-square

Square POS and Payments Integration
https://woo.com/products/square
Other
11 stars 7 forks source link

Sync fails when Dynamic Options used by Variations #231

Open faisal-alvi opened 3 weeks ago

faisal-alvi commented 3 weeks ago

When Woo is set as SOR, the sync fails when the dynamic options are used by a variable product. The plugin tries to update the variation name but it is not allowed when the variations use dynamic options. Even at the Square dashboard, we can not edit it.

Image

Here is the logged error:

Image

(
            [category:Square\Models\Error:private] => INVALID_REQUEST_ERROR
            [code:Square\Models\Error:private] => INVALID_VALUE
            [detail:Square\Models\Error:private] => Invalid object: Invalid Object with Id: XRYU7OMNCTNVD652UI4JENFD
[merchant_token=ML8ES32FTDWFZ] Item variation names may not be edited if they use item options (requested name "trunk-dynamic-options-variable-product woo02 - Red", actual name "Red"). Variation ID `XRYU7OMNCTNVD652UI4JENFD`.
            [field:Square\Models\Error:private] => 
)

We should skip updating the variation name here:

https://github.com/woocommerce/woocommerce-square/blob/d47dd1d162d8a9d0f6efe0b279db019556e0bba4/includes/Handlers/Product/Woo_SOR.php#L228

faisal-alvi commented 3 weeks ago

Additionally, if variation names cannot be modified when using dynamic options, we might consider disabling the attributes tab and also restricting any changes to the dropdown values under the variations tab. This approach would help prevent confusion since a new dropdown value will never be synced to the Square side!

Image

I also noticed that if we add more variations in Woo, those aren't syncing to Square too!, so we might consider disabling the option to add/create more variations as well. It’s also worth evaluating whether removing variations should be restricted as well.