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

Checkout Additional fields not validated if required in Store API #45496

Closed
Tracked by #42769
senadir opened this issue Mar 11, 2024 · 1 comment · Fixed by #45840
Closed
Tracked by #42769

Checkout Additional fields not validated if required in Store API #45496

senadir opened this issue Mar 11, 2024 · 1 comment · Fixed by #45840
Labels
focus: checkout Issues related to checkout page. team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues type: bug The issue is a confirmed bug.

Comments

@senadir
Copy link
Member

senadir commented Mar 11, 2024

When you have a required custom field in contact or additional, it doesn't get validated when you place a Store API order and it seems to be ignored.

Steps to reproduce:

  • Add the following field via code:
add_action(
	'woocommerce_loaded',
	function() {
		__experimental_woocommerce_blocks_register_checkout_field(
			array(
				'id'       => 'plugin-namespace/job-function',
				'label'    => 'What is your main role at your company?',
				'location' => 'contact',
				'required' => true,
				'type'     => 'text'
			)
		);
	}
);
  • In a REST client, add an item to cart, then head to Checkout and place the following the order:
{
	"billing_address": {
		"first_name": "test",
		"last_name": "test",
		"company": "",
		"address_1": "test",
		"address_2": "",
		"city": "test",
		"state": "",
		"postcode": "cb241ab",
		"country": "GB",
		"phone": "",
		"email": "testaccount@test.com"
	},
	"shipping_address": {
		"first_name": "test",
		"last_name": "test",
		"company": "",
		"address_1": "test",
		"address_2": "",
		"city": "test",
		"state": "",
		"postcode": "cb241ab",
		"country": "GB",
		"phone": ""
	},
	"payment_method": "bacs",
	"additional_fields": []
}
  • Notice that you can place an order just fine, regardless if plugin-namespace/job-function is required or not.

Expected behavior

The order placing should reject.

@senadir senadir added type: bug The issue is a confirmed bug. focus: checkout Issues related to checkout page. labels Mar 11, 2024
@senadir
Copy link
Member Author

senadir commented Mar 12, 2024

Once this is fixed this test should be unskipped test_place_order_required_contact_field

@adimoldovan adimoldovan added the team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: checkout Issues related to checkout page. team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants