-
Notifications
You must be signed in to change notification settings - Fork 7
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
faisal-alvi
wants to merge
74
commits into
trunk
Choose a base branch
from
multiple-variations-support
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+550
−30
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…te the dynamic option meta
faisal-alvi
added
the
type: enhancement
The issue is a request for an enhancement.
label
Nov 13, 2024
includes/Sync/Product_Import.php ----------------------------------------------------------------------------------------------- FOUND 1 ERROR AND 0 WARNINGS AFFECTING 1 LINE ----------------------------------------------------------------------------------------------- 92 | ERROR | Using short ternaries is not allowed as they are rarely used correctly (Universal.Operators.DisallowShortTernary.Found) -----------------------------------------------------------------------------------------------
FILE: includes/Sync/Manual_Synchronization.php ----------------------------------------------------------------------------------------------- FOUND 1 ERROR AND 0 WARNINGS AFFECTING 1 LINE ----------------------------------------------------------------------------------------------- 1684 | ERROR | Using short ternaries is not allowed as they are rarely used correctly (Universal.Operators.DisallowShortTernary.Found) -----------------------------------------------------------------------------------------------
FILE: includes/Handlers/Product/Woo_SOR.php ----------------------------------------------------------------------------------------------- FOUND 14 ERRORS AND 0 WARNINGS AFFECTING 14 LINES ----------------------------------------------------------------------------------------------- 87 | ERROR | Using short ternaries is not allowed as they are rarely used correctly (Universal.Operators.DisallowShortTernary.Found) 113 | ERROR | The parameter "array( 'hide_empty' => false )" at position #2 of get_terms() has been deprecated since WordPress version 4.5.0. Instead do not pass the parameter. (WordPress.WP.DeprecatedParameters.Get_termsParam2Found) 142 | ERROR | Variable "$CatalogItemOptionForItem" is not in valid snake_case format, try "$catalog_item_option_for_item" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 143 | ERROR | Variable "$CatalogItemOptionForItem" is not in valid snake_case format, try "$catalog_item_option_for_item" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 144 | ERROR | Variable "$CatalogItemOptionForItem" is not in valid snake_case format, try "$catalog_item_option_for_item" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 348 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 349 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 350 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 352 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 357 | ERROR | The parameter "array( 'hide_empty' => false )" at position #2 of get_terms() has been deprecated since WordPress version 4.5.0. Instead do not pass the parameter. (WordPress.WP.DeprecatedParameters.Get_termsParam2Found) 378 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 379 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 380 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) 382 | ERROR | Variable "$CatalogItemOptionValueForItemVariation" is not in valid snake_case format, try "$catalog_item_option_value_for_item_variation" (WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase) -----------------------------------------------------------------------------------------------
github-actions
bot
added
status: e2e tests passing
and removed
status: e2e tests failing
labels
Nov 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
This PR adds support for Multiple Variations.
Square and WooCommerce Attribute Types
Square options:
WooCommerce attributes:
Key Differences Between Dynamic and Static Options
Dynamic options can be shared across products and mirror WooCommerce’s taxonomy attributes, and variation names cannot be modified, as they are automatically generated by combining the attribute values. For example: “Red, Small.” Static options are unique to each item. If multiple options exist at Square, they must be dynamic.
Syncing Logic (Overview)
WooCommerce to Square Sync:
Square to WooCommerce Sync/Import:
Syncing Logic for WooCommerce and Square (Detail)
From WooCommerce to Square:
From Square to WooCommerce:
Square API Limitations and Solutions
Square’s API only provides the option ID used in variations, not the display name. However, to match WooCommerce taxonomy attributes or to create a custom attribute, we need the option's display name. To address this, we fetch all options via another Square API (discussion link) and store the option names and their IDs in a transient (
wc_square_options_data
) with a 1-day expiration. Thefetch_options_data()
function initiates this before any import or sync process.If a transient doesn’t have updated data, a sync may fail when creating an option with a name that already exists at Square, which would require a latest options data. This PR then stops the sync and sets the
woocommerce_square_refresh_sync_cycle
option to refresh the data.Avoiding Attribute Name Conflicts
If WooCommerce’s taxonomy attribute is used, this PR passes the taxonomy name (e.g., “pa_color” rather than “Color”) to Square, preventing conflicts with custom attributes of the same name. The “pa_” prefix helps WooCommerce users distinguish between taxonomy and custom attributes, avoiding potential conflicts.
New Option for Tracking
This PR introduces a new
_dynamic_options
option withtrue/false
values to track whether dynamic options are used for a product. This is not in use but may be useful in future.Pending Tasks
Notes for Merchants
Closes #6, Closes #31 and Closes #231.
Steps to test the changes in this Pull Request:
Changelog entry