Skip to content

fix(customer): add first and last name for company customers - #219

Open
faisalahammad wants to merge 1 commit into
woocommerce:trunkfrom
faisalahammad:fix/162-customer-missing-name
Open

fix(customer): add first and last name for company customers#219
faisalahammad wants to merge 1 commit into
woocommerce:trunkfrom
faisalahammad:fix/162-customer-missing-name

Conversation

@faisalahammad

Copy link
Copy Markdown

All Submissions:

Changes proposed in this Pull Request:

Closes #162

Company-type customers were generated without a first name or last name, so saving them through WooCommerce's customer data store failed with WC_Data_Exception: First name is a required field. Order generation creates customers as part of building an order, so wp wc generate orders crashed for affected users.

The fix generates a contact person name for company customers and includes it in both billing and shipping data, so the customer saves correctly. Person-type customers were already correct.

How to test the changes in this Pull Request:

  1. With WooCommerce and Smooth Generator active on a default theme, run wp wc generate orders 10.
  2. Run wp wc generate customers 10 --type=company.
  3. Open one generated company customer and confirm the first and last name fields are populated.

Expected: orders and company customers generate without errors, and company customers have a contact name.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Fix fatal error when generating orders caused by company customers missing a first and last name.

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

Company-type customers were generated without first_name or last_name, so
saving them through WooCommerce's customer data store failed with
'First name is a required field.' This crashed order generation, which
creates customers as part of the order.

Generate a contact person name for company customers and include it in
billing and shipping data so the customer saves correctly.

Closes woocommerce#162
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.

Fatal error: Uncaught WC_Data_exception

1 participant