Skip to content

fix(product): randomize tax_class on generated products - #215

Open
faisalahammad wants to merge 1 commit into
woocommerce:trunkfrom
faisalahammad:fix/178-dynamic-tax-class
Open

fix(product): randomize tax_class on generated products#215
faisalahammad wants to merge 1 commit into
woocommerce:trunkfrom
faisalahammad:fix/178-dynamic-tax-class

Conversation

@faisalahammad

Copy link
Copy Markdown

Currently tax_class is hardcoded to '' (Standard) in the product generator, so all generated products always get the Standard tax class regardless of what tax classes are configured in the store.

This change uses wc_get_product_tax_class_options() to get all available tax class slugs (Standard + any custom/reduced-rate classes), then picks one at random via Faker — the same pattern already used for tax_status and other randomized fields.

Changes:

  • generate_simple_product() — randomize tax_class
  • generate_variable_product() — randomize tax_class for parent product
  • generate_variable_product() — randomize tax_class for each variation

Fixes #178

- Use wc_get_product_tax_class_options() to get available tax classes
- Randomly pick a tax class instead of always defaulting to Standard
- Applied to simple, variable, and variation product generation

Fixes woocommerce#178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Dynamic tax_class

1 participant