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 UI] useAppMetafields returns stringified booleans #1810

Open
masonmcelvain opened this issue Mar 7, 2024 · 2 comments
Open

[Checkout UI] useAppMetafields returns stringified booleans #1810

masonmcelvain opened this issue Mar 7, 2024 · 2 comments
Labels
bug Something isn't working Checkout UI Extensions

Comments

@masonmcelvain
Copy link

Please list the package(s) involved in the issue, and include the version you are using

@shopify/[email protected]

Describe the bug

useAppMetafields returns the values "true" and "false" for boolean metafields instead of true and false. This is surprising because AppMetafield.value's type definition includes boolean.

/**
* Represents a custom metadata attached to a resource.
*/
export interface AppMetafield {
/** The key name of a metafield. */
key: string;
/** The namespace for a metafield. */
namespace: string;
/** The value of a metafield. */
value: string | number | boolean;
/** The metafield’s information type. */
valueType: 'boolean' | 'float' | 'integer' | 'json_string' | 'string';
/** The metafield's type name. */
type: string;
}

Steps to reproduce the behavior:

  1. The metafield can have a definition or be unstructured. I tested with a product variant metafield. It's type must be boolean.
  2. Add a value of true or false to a variant's metafield.
  3. console.log(useAppMetafields({ id: yourMetafieldId })) produces a value similar to the screenshot below.

Expected behavior

AppMetafield.value should be a boolean if the type of the metafield is boolean, not "true" or "false".

Screenshots

screenshot

Additional context

Similar to #971

@masonmcelvain masonmcelvain added the bug Something isn't working label Mar 7, 2024
@dnagoda
Copy link
Contributor

dnagoda commented Mar 22, 2024

Thanks for the report. I was able to reproduce the issue. Adding to our backlog.

@masonmcelvain
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Checkout UI Extensions
Projects
None yet
Development

No branches or pull requests

3 participants