Skip to content

Latest commit

 

History

History
573 lines (325 loc) · 13.7 KB

CheckoutStoreSelector.md

File metadata and controls

573 lines (325 loc) · 13.7 KB

@bigcommerce/checkout-sdk / CheckoutStoreSelector

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.

Table of contents

Methods

Methods

getBillingAddress

getBillingAddress(): undefined | BillingAddress

Gets the billing address of an order.

Returns

undefined | BillingAddress

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


getBillingAddressFields

getBillingAddressFields(countryCode): 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(): undefined | Country[]

Gets a list of countries available for billing.

Returns

undefined | Country[]

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


getCart

getCart(): undefined | Cart

Gets the current cart.

Returns

undefined | Cart

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


getCheckout

getCheckout(): undefined | Checkout

Gets the current checkout.

Returns

undefined | Checkout

The current checkout if it is loaded, otherwise undefined.


getConfig

getConfig(): undefined | StoreConfig

Gets the checkout configuration of a store.

Returns

undefined | StoreConfig

The configuration object if it is loaded, otherwise undefined.


getConsignments

getConsignments(): undefined | Consignment[]

Gets a list of consignments.

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

Returns

undefined | Consignment[]

The list of consignments if any, otherwise undefined.


getCoupons

getCoupons(): undefined | Coupon[]

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

Returns

undefined | Coupon[]

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


getCustomer

getCustomer(): undefined | Customer

Gets the current customer.

Returns

undefined | Customer

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.


getExtensionByRegion

getExtensionByRegion(region): undefined | Extension

Gets the extension associated with a given region.

alpha

Parameters

Name Type Description
region ExtensionRegion A checkout extension region.

Returns

undefined | Extension

The extension corresponding to the specified region, otherwise undefined.


getExtensions

getExtensions(): undefined | Extension[]

Gets a list of extensions available for checkout.

alpha

Returns

undefined | Extension[]

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


getFlashMessages

getFlashMessages(type?): undefined | FlashMessage[]

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? "error" | "info" | "warning" | "success" The type of flash messages to be returned. Optional

Returns

undefined | FlashMessage[]

The flash messages if available, otherwise undefined.


getGiftCertificates

getGiftCertificates(): undefined | GiftCertificate[]

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

Returns

undefined | GiftCertificate[]

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


getInstruments

getInstruments(): undefined | CardInstrument[]

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

Returns

undefined | CardInstrument[]

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

getInstruments(paymentMethod): undefined | PaymentInstrument[]

Parameters

Name Type
paymentMethod PaymentMethod<any>

Returns

undefined | PaymentInstrument[]


getOrder

getOrder(): undefined | Order

Gets the current order.

Returns

undefined | Order

The current order if it is loaded, otherwise undefined.


getPaymentMethod

getPaymentMethod(methodId, gatewayId?): undefined | PaymentMethod<any>

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? string The identifier of a payment provider providing the payment method.

Returns

undefined | PaymentMethod<any>

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


getPaymentMethods

getPaymentMethods(): undefined | PaymentMethod<any>[]

Gets a list of payment methods available for checkout.

Returns

undefined | PaymentMethod<any>[]

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


getPaymentProviderCustomer

getPaymentProviderCustomer(): undefined | BraintreeAcceleratedCheckoutCustomer

Gets payment provider customers data.

alpha

Returns

undefined | BraintreeAcceleratedCheckoutCustomer

The object with payment provider customer data


getPickupOptions

getPickupOptions(consignmentId, searchArea): undefined | PickupOptionResult[]

Gets a list of pickup options for specified parameters.

Parameters

Name Type Description
consignmentId string Id of consignment.
searchArea SearchArea An object containing of radius and co-ordinates.

Returns

undefined | PickupOptionResult[]

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


getSelectedPaymentMethod

getSelectedPaymentMethod(): undefined | PaymentMethod<any>

Gets the payment method that is selected for checkout.

Returns

undefined | PaymentMethod<any>

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


getSelectedShippingOption

getSelectedShippingOption(): undefined | ShippingOption

Gets the selected shipping option for the current checkout.

Returns

undefined | ShippingOption

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


getShippingAddress

getShippingAddress(): undefined | Address

Gets the shipping address of the current checkout.

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

Returns

undefined | Address

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


getShippingAddressFields

getShippingAddressFields(countryCode): 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(): undefined | Country[]

Gets a list of countries available for shipping.

Returns

undefined | Country[]

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


getShippingOptions

getShippingOptions(): undefined | ShippingOption[]

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

undefined | ShippingOption[]

The list of shipping options if any, otherwise undefined.


getSignInEmail

getSignInEmail(): undefined | SignInEmail

Gets the sign-in email.

Returns

undefined | SignInEmail

The sign-in email object if sent, otherwise undefined


getUserExperienceSettings

getUserExperienceSettings(): undefined | UserExperienceSettings

Gets user experience settings.

Returns

undefined | UserExperienceSettings

The object of user experience settings if it is loaded, otherwise undefined.


isPaymentDataRequired

isPaymentDataRequired(useStoreCredit?): 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? boolean 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, gatewayId?): 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? string The identifier of a payment provider providing the payment method.

Returns

boolean

True if payment data is submitted, otherwise false.