This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
300 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @typedef {Object} CheckoutDispatchActions | ||
* | ||
* @property {function()} resetCheckout Dispatches an action that resets | ||
* the checkout to a pristine state. | ||
* @property {function()} setRedirectUrl Dispatches an action that sets the | ||
* redirectUrl to the given value. | ||
* @property {function()} setHasError Dispatches an action that sets the | ||
* checkout status to having an error. | ||
* @property {function()} clearError Dispatches an action that clears | ||
* the hasError status for the | ||
* checkout. | ||
* @property {function()} incrementCalculating Dispatches an action that | ||
* increments the calculating state | ||
* for checkout by one. | ||
* @property {function()} decrementCalculating Dispatches an action that | ||
* decrements the calculating state | ||
* for checkout by one. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} CheckoutStatusConstants | ||
* | ||
* @property {string} PRISTINE Checkout is in it's initialized state. | ||
* @property {string} IDLE When checkout state has changed but there is | ||
* no activity happening. | ||
* @property {string} CALCULATING When something in the checkout results in the | ||
* totals being recalculated, this will be the | ||
* state while calculating is happening. | ||
* @property {string} PROCESSING This is the state when the checkout button has | ||
* been pressed and the checkout data has been | ||
* sent to the server for processing. | ||
* @property {string} COMPLETE This is the status when the server has | ||
* completed processing the data successfully. | ||
*/ | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
/** | ||
* @typedef {import('./cart').CartShippingOption} CartShippingOption | ||
* @typedef {import('./cart').CartShippingAddress} CartShippingAddress | ||
* @typedef {import('./cart').CartBillingAddress} CartBillingAddress | ||
* @typedef {import('./checkout').CheckoutDispatchActions} CheckoutDispatchActions | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} ShippingMethodDataContext | ||
* | ||
* @property {string} shippingErrorStatus The current error | ||
* status for shipping | ||
* rates if present. | ||
* @property {Function} dispatchErrorStatus A function for | ||
* dispatching a shipping | ||
* rate error status. | ||
* @property {ShippingErrorTypes} shippingErrorTypes The error type | ||
* constants for the | ||
* shipping rate error | ||
* status. | ||
* @property {CartShippingOption[]} shippingRates An array of available | ||
* shipping rates. | ||
* @property {Function} setShippingRates Used to set the | ||
* available shipping | ||
* rates. | ||
* @property {boolean} shippingRatesLoading Whether or not the | ||
* shipping rates are | ||
* being loaded. | ||
* @property {string[]} selectedRates The ids of the rates | ||
* that are selected. | ||
* @property {Function} setSelectedRates A function for setting | ||
* the selected rates. | ||
* @property {CartShippingAddress} shippingAddress The current set | ||
* address for shipping. | ||
* @property {function()} setShippingAddress A function for setting | ||
* the shipping address. | ||
* @property {function()} onShippingRateSuccess Used to register a | ||
* callback to be invoked | ||
* when shipping rates | ||
* are retrieved | ||
* successfully. | ||
* @property {function()} onShippingRateSelectSuccess Used to register | ||
* a callback to be | ||
* invoked when shipping | ||
* rate is selected | ||
* successfully. | ||
* @property {function()} onShippingRateSelectFail Used to register a | ||
* callback to be invoked | ||
* when shipping rate is | ||
* selected unsuccessfully | ||
* @property {function()} onShippingRateFail Used to register a | ||
* callback to be invoked | ||
* when there is an | ||
* error with retrieving | ||
* shipping rates. | ||
* @property {boolean} needsShipping True if the cart has | ||
* items requiring | ||
* shipping. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} ShippingErrorTypes | ||
* | ||
* @property {string} NONE No shipping error. | ||
* @property {string} INVALID_ADDRESS Error due to an invalid address for | ||
* calculating shipping. | ||
* @property {string} UNKNOWN When an unknown error has occurred in | ||
* calculating/retrieving shipping rates. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} PaymentMethodCurrentStatus | ||
* | ||
* This contains status information for the current active payment method in | ||
* the checkout. | ||
* | ||
* @property {boolean} isPristine If true then the payment method state in | ||
* checkout is pristine. | ||
* @property {boolean} isStarted If true then the payment method has been | ||
* initialized and has started. | ||
* @property {boolean} isProcessing If true then the payment method is | ||
* processing payment. | ||
* @property {boolean} isFinished If true then the payment method is in a | ||
* finished state (which may mean it's status | ||
* is either error, failed, or success) | ||
* @property {boolean} hasError If true then the payment method is in an | ||
* error state. | ||
* @property {boolean} hasFailed If true then the payment method has failed | ||
* (usually indicates a problem with the | ||
* payment method used, not logic error) | ||
* @property {boolean} isSuccessful If true then the payment method has | ||
* completed it's processing successfully. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} PaymentStatusDispatchers | ||
* | ||
* @property {function()} started | ||
* @property {function()} processing | ||
* @property {function()} completed | ||
* @property {function(string)} error | ||
* @property {function(string, CartBillingAddress, Object)} failed | ||
* @property {function(CartBillingAddress, Object)} success | ||
*/ | ||
|
||
/** | ||
* @typedef {function():PaymentStatusDispatchers} PaymentStatusDispatch | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} PaymentMethodDataContext | ||
* | ||
* @property {PaymentStatusDispatch} setPaymentStatus Sets the | ||
* payment status | ||
* for the payment | ||
* method. | ||
* @property {PaymentMethodCurrentStatus} currentStatus The current | ||
* payment status. | ||
* @property {Object} paymentStatuses An object of | ||
* payment status | ||
* constants. | ||
* @property {CartBillingAddress} billingData The current set | ||
* billing data. | ||
* @property {Object} paymentMethodData Arbitrary data | ||
* to be passed | ||
* along for | ||
* processing by | ||
* the payment | ||
* method on the | ||
* server. | ||
* @property {string} errorMessage An error | ||
* message provided | ||
* by the payment | ||
* method if there | ||
* is an error. | ||
* @property {string} activePaymentMethod The active | ||
* payment method | ||
* slug. | ||
* @property {function()} setActivePaymentMethod A function for | ||
* setting the | ||
* active payment | ||
* method. | ||
* @property {function()} setBillingData A function for | ||
* setting the | ||
* billing data. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} CheckoutDataContext | ||
* | ||
* @property {string} submitLabel The label to use for | ||
* the submit checkout | ||
* button. | ||
* @property {function()} onSubmit The callback to | ||
* register with the | ||
* checkout submit | ||
* button. | ||
* @property {boolean} isComplete True when checkout is | ||
* complete and ready for | ||
* redirect. | ||
* @property {boolean} isIdle True when the checkout | ||
* state has changed and | ||
* checkout has no | ||
* activity. | ||
* @property {boolean} isProcessing True when checkout has | ||
* been submitted and is | ||
* being processed by the | ||
* server. | ||
* @property {boolean} isCalculating True when something in | ||
* the checkout is | ||
* resulting in totals | ||
* being calculated. | ||
* @property {boolean} hasError True when the checkout | ||
* is in an error state. | ||
* Whatever caused the | ||
* error | ||
* (validation/payment | ||
* method) will likely | ||
* have triggered a | ||
* notice. | ||
* @property {string} redirectUrl This is the url that | ||
* checkout will redirect | ||
* to when it's ready. | ||
* @property {function()} onCheckoutCompleteSuccess Used to register a | ||
* callback that will | ||
* fire when the checkout | ||
* is marked complete | ||
* successfully. | ||
* @property {function()} onCheckoutCompleteError Used to register | ||
* a callback that will | ||
* fire when the checkout | ||
* is marked complete and | ||
* has an error. | ||
* @property {function()} onCheckoutProcessing Used to register a | ||
* callback that will | ||
* fire when the checkout | ||
* has been submitted | ||
* before being sent off | ||
* to the server. | ||
* @property {CheckoutDispatchActions} dispatchActions Various actions that | ||
* can be dispatched for | ||
* the checkout context | ||
* data. | ||
*/ | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* @typedef {Object} WooCommerceSiteCurrency | ||
* | ||
* @property {string} code The ISO code for the currency. | ||
* @property {number} precision The precision (decimal places). | ||
* @property {string} symbol The symbol for the currency (eg '$') | ||
* @property {string} symbolPosition The position for the symbol ('left', | ||
* or 'right') | ||
* @property {string} decimalSeparator The string used for the decimal | ||
* separator. | ||
* @property {string} thousandSeparator The string used for the thousands | ||
* separator. | ||
* @property {string} priceFormat The format string use for displaying | ||
* an amount in this currency. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} WooCommerceSiteLocale | ||
* | ||
* @property {string} siteLocale The locale string for the current | ||
* site. | ||
* @property {string} userLocale The locale string for the current | ||
* user. | ||
* @property {Array<string>} weekdaysShort An array of short weekday strings | ||
* in the current user's locale. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} WooCommerceSharedSettings | ||
* | ||
* @property {string} adminUrl The url for the current | ||
* site's dashboard. | ||
* @property {Object} countries An object of countries | ||
* where the keys are | ||
* Country codes and values | ||
* are country names | ||
* localized for the site's | ||
* current language. | ||
* @property {WooCommerceSiteCurrency} currency The current site | ||
* currency object. | ||
* @property {string} defaultDateRange The default date range | ||
* query string to use. | ||
* @property {WooCommerceSiteLocale} locale Locale information for | ||
* the site. | ||
* @property {Object} orderStatuses An object of order | ||
* statuses indexed by | ||
* status key and localized | ||
* status value. | ||
* @property {string} siteTitle The current title of the | ||
* site. | ||
* @property {string} wcAssetUrl The url to the assets | ||
* directory for the | ||
* WooCommerce plugin. | ||
*/ | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters