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

[Enhancement]: Expose Checkout API types for use in TypeScript projects integrating with the Cart and Checkout blocks #47154

Open
reykjalin opened this issue May 3, 2024 · 4 comments
Labels
focus: cart Issues related to the cart. focus: checkout Issues related to checkout page. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues type: enhancement The issue is a request for an enhancement.

Comments

@reykjalin
Copy link
Contributor

Describe the solution you'd like

An easy way to import types for use with blocks that integrate with the Cart and Checkout blocks.

As an example when making an express checkout component it'd be nice to have access to the PaymentMethodInterface type as that's what will be passed to the component when registered with registerExpressPaymentMethod:

const ExpressPaymentMethod: React.FC< PaymentMethodInterface > = ( { billing, shippingData } ) => {
    // ...
}

This could be through making a new npm package, adding the types to an existing npm package, maybe a WC TypeScript specific package with just types?

Describe alternatives you've considered

No response

Additional context

No response

@reykjalin reykjalin added the type: enhancement The issue is a request for an enhancement. label May 3, 2024
@lanej0 lanej0 added focus: cart Issues related to the cart. focus: checkout Issues related to checkout page. team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues labels May 6, 2024
@opr
Copy link
Contributor

opr commented May 7, 2024

I agree, this is something that would benefit a lot of folks! Ideally it would be something we export automatically (as opposed to relying on something like definitely typed).

Not sure exactly how it would work, maybe a specific package for types would be easiest, for both us and consumers? We already have an internal types "package" that would be nice to export.

@opr opr added the priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. label May 7, 2024
@reykjalin
Copy link
Contributor Author

Yeah it'd be great to have this for WooPayments and WooPay where we're integrating pretty heavily with the Cart and Checkout blocks :)

@reykjalin
Copy link
Contributor Author

reykjalin commented May 7, 2024

We already have an internal types "package" that would be nice to export.

And yes, this is where I've been lifting types from the WC Core codebase to use in WooPayments 👍

@multiplehats
Copy link
Contributor

multiplehats commented May 13, 2024

Same, I'm using the types in Cartpops. But Ideally they're exported so that we can version them and also know when changes have been made.

For anyone who stumbles upon this, here's a script to automate this for now:

#!/bin/bash

REPO_URL="https://github.com/woocommerce/woocommerce.git"
BRANCH="trunk"
DEST_DIR="wc-types"

# Create a temporary directory for cloning
TEMP_DIR=$(mktemp -d)

# Clone the repository
git clone -b $BRANCH --depth 1 $REPO_URL $TEMP_DIR

# Copy the TypeScript files to the destination directory
mkdir -p $DEST_DIR
cp -R "$TEMP_DIR/plugins/woocommerce-blocks/assets/js/types/"* $DEST_DIR

# Remove the temporary directory
rm -rf $TEMP_DIR

# Echo success message
echo "WooCommerce types have been successfully fetched to $DEST_DIR"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: cart Issues related to the cart. focus: checkout Issues related to checkout page. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

4 participants