Skip to content

Latest commit

 

History

History
430 lines (248 loc) · 11.3 KB

checkoutstoreselector.md

File metadata and controls

430 lines (248 loc) · 11.3 KB

@bigcommerce/checkout-sdkCheckoutStoreSelector

Interface: CheckoutStoreSelector

Responsible for getting the state of the current checkout.

This object has a set of methods that allow you to get a specific piece of checkout information, such as shipping and billing details.

Hierarchy

  • CheckoutStoreSelector

Index

Methods

Methods

getBillingAddress

getBillingAddress(): BillingAddress | undefined

Gets the billing address of an order.

Returns: BillingAddress | undefined

The billing address object if it is loaded, otherwise undefined.


getBillingAddressFields

getBillingAddressFields(countryCode: string): FormField[]

Gets a set of form fields that should be presented to customers in order to capture their billing address for a specific country.

Parameters:

Name Type Description
countryCode string A 2-letter country code (ISO 3166-1 alpha-2).

Returns: FormField[]

The set of billing address form fields if it is loaded, otherwise undefined.


getBillingCountries

getBillingCountries(): Country[] | undefined

Gets a list of countries available for billing.

Returns: Country[] | undefined

The list of countries if it is loaded, otherwise undefined.


getCart

getCart(): Cart | undefined

Gets the current cart.

Returns: Cart | undefined

The current cart object if it is loaded, otherwise undefined.


getCheckout

getCheckout(): Checkout | undefined

Gets the current checkout.

Returns: Checkout | undefined

The current checkout if it is loaded, otherwise undefined.


getConfig

getConfig(): StoreConfig | undefined

Gets the checkout configuration of a store.

Returns: StoreConfig | undefined

The configuration object if it is loaded, otherwise undefined.


getConsignments

getConsignments(): Consignment[] | undefined

Gets a list of consignments.

If there are no consignments created for to the current checkout, the list will be empty.

Returns: Consignment[] | undefined

The list of consignments if any, otherwise undefined.


getCoupons

getCoupons(): Coupon[] | undefined

Gets a list of coupons that are applied to the current checkout.

Returns: Coupon[] | undefined

The list of applied coupons if there is any, otherwise undefined.


getCustomer

getCustomer(): Customer | undefined

Gets the current customer.

Returns: Customer | undefined

The current customer object if it is loaded, otherwise undefined.


getCustomerAccountFields

getCustomerAccountFields(): FormField[]

Gets a set of form fields that should be presented in order to create a customer.

Returns: FormField[]

The set of customer account form fields if it is loaded, otherwise undefined.


getFlashMessages

getFlashMessages(type?: FlashMessageType): FlashMessage[] | undefined

Gets the available flash messages.

Flash messages contain messages set by the server, e.g: when trying to sign in using an invalid email link.

Parameters:

Name Type Description
type? FlashMessageType The type of flash messages to be returned. Optional

Returns: FlashMessage[] | undefined

The flash messages if available, otherwise undefined.


getGiftCertificates

getGiftCertificates(): GiftCertificate[] | undefined

Gets a list of gift certificates that are applied to the current checkout.

Returns: GiftCertificate[] | undefined

The list of applied gift certificates if there is any, otherwise undefined.


getInstruments

getInstruments(): Instrument[] | undefined

Gets a list of payment instruments associated with the current customer.

Returns: Instrument[] | undefined

The list of payment instruments if it is loaded, otherwise undefined.

getInstruments(paymentMethod: PaymentMethod): PaymentInstrument[] | undefined

Parameters:

Name Type
paymentMethod PaymentMethod

Returns: PaymentInstrument[] | undefined


getOrder

getOrder(): Order | undefined

Gets the current order.

Returns: Order | undefined

The current order if it is loaded, otherwise undefined.


getPaymentMethod

getPaymentMethod(methodId: string, gatewayId?: undefined | string): PaymentMethod | undefined

Gets a payment method by an id.

The method returns undefined if unable to find a payment method with the specified id, either because it is not available for the customer, or it is not loaded.

Parameters:

Name Type Description
methodId string The identifier of the payment method.
gatewayId? undefined | string The identifier of a payment provider providing the payment method.

Returns: PaymentMethod | undefined

The payment method object if loaded and available, otherwise, undefined.


getPaymentMethods

getPaymentMethods(): PaymentMethod[] | undefined

Gets a list of payment methods available for checkout.

Returns: PaymentMethod[] | undefined

The list of payment methods if it is loaded, otherwise undefined.


getSelectedPaymentMethod

getSelectedPaymentMethod(): PaymentMethod | undefined

Gets the payment method that is selected for checkout.

Returns: PaymentMethod | undefined

The payment method object if there is a selected method; undefined if otherwise.


getSelectedShippingOption

getSelectedShippingOption(): ShippingOption | undefined

Gets the selected shipping option for the current checkout.

Returns: ShippingOption | undefined

The shipping option object if there is a selected option, otherwise undefined.


getShippingAddress

getShippingAddress(): Address | undefined

Gets the shipping address of the current checkout.

If the address is partially complete, it may not have shipping options associated with it.

Returns: Address | undefined

The shipping address object if it is loaded, otherwise undefined.


getShippingAddressFields

getShippingAddressFields(countryCode: string): FormField[]

Gets a set of form fields that should be presented to customers in order to capture their shipping address for a specific country.

Parameters:

Name Type Description
countryCode string A 2-letter country code (ISO 3166-1 alpha-2).

Returns: FormField[]

The set of shipping address form fields if it is loaded, otherwise undefined.


getShippingCountries

getShippingCountries(): Country[] | undefined

Gets a list of countries available for shipping.

Returns: Country[] | undefined

The list of countries if it is loaded, otherwise undefined.


getShippingOptions

getShippingOptions(): ShippingOption[] | undefined

Gets a list of shipping options available for the shipping address.

If there is no shipping address assigned to the current checkout, the list of shipping options will be empty.

Returns: ShippingOption[] | undefined

The list of shipping options if any, otherwise undefined.


getSignInEmail

getSignInEmail(): SignInEmail | undefined

Gets the sign-in email.

Returns: SignInEmail | undefined

The sign-in email object if sent, otherwise undefined


isPaymentDataRequired

isPaymentDataRequired(useStoreCredit?: undefined | false | true): boolean

Checks if payment data is required or not.

If payment data is required, customers should be prompted to enter their payment details.

if (state.checkout.isPaymentDataRequired()) {
    // Render payment form
} else {
    // Render "Payment is not required for this order" message
}

Parameters:

Name Type Description
useStoreCredit? undefined | false | true If true, check whether payment data is required with store credit applied; otherwise, check without store credit.

Returns: boolean

True if payment data is required, otherwise false.


isPaymentDataSubmitted

isPaymentDataSubmitted(methodId: string, gatewayId?: undefined | string): boolean

Checks if payment data is submitted or not.

If payment data is already submitted using a payment method, customers should not be prompted to enter their payment details again.

Parameters:

Name Type Description
methodId string The identifier of the payment method.
gatewayId? undefined | string The identifier of a payment provider providing the payment method.

Returns: boolean

True if payment data is submitted, otherwise false.