Repository navigation
Helpers and Utilities
Selldone Core ships the small, battle-tested functions that the Storefront, Components and dashboards use every day: price and exchange-rate math, currency and date formatting, shop URLs, local-storage keys, validation rules, CSV formats, cookies, styled console output and prototype extensions. This page groups them by task (helper/, utils/, prototypes/, timeserie/) with real signatures and examples.
Most helpers are static classes exported from the package root:
import { PriceHelper, CurrencyHelper, DateConverter, NumberHelper, ShopURLs, StorefrontLocalStorages } from "@selldone/core-js";| Method | Description |
|---|---|
priceProductByCurrency(shop, product, variant, to_currency, preferences?, valuation?, subscription_price?, current_extra_pricing?) |
Final price of a product or variant in a target currency, including commission, valuation (custom pricing forms), extra pricing and subscription prices. Throws if a needed exchange rate is missing. |
getProductDiscountAmountByCurrency(shop, product, variant, to_currency) |
Discount amount in the target currency. |
discountProductPercent(shop, product, variant, to_currency?) |
Discount as a percentage. |
HasDiscountCountDownMode(product, variant?), GetEndOfDiscountDate(...)
|
Limited-time discount helpers. |
getBasketItemPrice(...), getBasketItemDiscount(...), getBasketItemSumPriceDiscount(...)
|
Basket item amounts. |
getExchangeRate(shop, from, to), getExchangeRateValue(...), getBuyRateValue(shop, from, to)
|
Look up rates in shop.shop_exchange_rates (reverse rates are tried too). |
FixPrecision(val, floats), FixPrecisionForCurrency(val, currency)
|
Round to the currency's decimal places. |
const price = PriceHelper.priceProductByCurrency(shop, product, variant, "EUR");
const percent = PriceHelper.discountProductPercent(shop, product, variant, "EUR");
PriceHelper.FixPrecisionForCurrency(10.4567, "USD"); // 10.46| Method | Description |
|---|---|
ConvertToString(amount, currency, local = "en-US") |
Format with Intl currency style: "$100.50", "100,50 €". |
GetUserSelectedCurrency(path) / SetUserSelectedCurrency(...)
|
Read or save the customer's currency under a local-storage base path such as shop/@my-shop/. |
GetUserSelectedCurrencyName / Floats / RoundFactor / Format / Unicode / SignAtEnd(...) |
Individual properties of the selected currency. |
NeedToSHowCurrencyFlag(codes) |
true when several currencies share a symbol (e.g. AUD and USD), so flags are needed to tell them apart. |
GetCountryByCurrencyCode(code) |
Country for a currency. |
CurrencyHelper.ConvertToString(100.5, "EUR", "de-DE"); // "100,50 €"
CurrencyHelper.NeedToSHowCurrencyFlag(["AUD", "USD"]); // true| Method | Description |
|---|---|
getFromNowString(date, local?, abstract?) |
Relative time, e.g. "3 days ago", using Intl.RelativeTimeFormat. |
getFromOtherTimeString(start, end, local?, abstract?) |
Relative time between two dates. |
GetLocalTimeString(date, added_seconds?, isShort?, isMicro?, noTime?) |
Localized date/time string. |
convertToLocalTime(value, keep_only_date?) |
Parse a date string (or Laravel { date } object) into a Date. |
isToday(date), inDayRange(...), inBetweenDates(test, start, end), InSameDay(d1, d2)
|
Date checks. |
SecondsToString(seconds) |
"45 minutes" / "3 hours" (uses window.$t). |
When local is omitted, window.$language.full_locale is used.
DateConverter.getFromNowString(order.created_at, "en-US"); // "2 hours ago"
DateConverter.getFromNowString(order.created_at, "en-US", true); // short style, e.g. "2 hr. ago"helper/date/DateConverter.ts also adds Date.prototype helpers: addDays(n), addHours(n), addSeconds(n), setStart(), setEnd() and printDayWeek().
Normalizes Persian and Arabic digits typed by customers: toEnglishDigits(str), toEnglishNumber(str), toEnglishInt(str), toEnglishFloat(str, decimal).
NumberHelper.toEnglishDigits("قیمت: ۵۰۰"); // "قیمت: 500"
NumberHelper.toEnglishNumber("۲۵.۵"); // 25.5| Helper | Methods |
|---|---|
ShopURLs |
MainShopUrl(shop), GetProductLink(shop, product_id, slug?), GetCategoryLink(shop, category_name), GetBlogLink(shop, blog_id), GetVendorLandingPageUrl(shop, vendor), GetVendorListingPageUrl(shop, vendor), GetShopPageLink(...), GetShopHyperUrl(shop), GetShopAvocadoUrl(shop), GetAvocadoBuyerUrl(shop, avocado), GetShopInstagramUrl(shop)
|
SelldoneURLs |
UserProfilePageUrl(...) |
URLHelper |
OpenInNewWindow(...) |
ProductEmbedHelper |
ProductIframe(...): embed code for a product. |
DomainsHelper |
GetShopDomains(...) |
ShopURLs.GetProductLink(shop, 1234); // "<shop url>/product/1234"
ShopURLs.GetCategoryLink(shop, "shoes"); // "<shop url>/shoes-category"| Helper | Use |
|---|---|
ShopOptionsHelper |
Read shop options: GetSizeUnit, GetMassUnit, GetDistanceUnit, GetLoginMethods, GetCheckout, GetRefundPolicy, GetActiveTypes, GetLanguages, GetShopMap, GetCustomVariants, GetLabeling, … (all take the shop). |
BasketHelper |
GetBasketItemWeight, GetTotalBasketItemsWeight, GetBasketItemSize, FindItem, IsServiceAndNeedPricing. |
ExtraPricingHelper |
GetListOfExtraPricings, FindMatchInList (quantity-based pricing). |
BuyButtonHelper |
ExtractIconCaption for custom buy-button captions. |
RibbonHelper |
hasShipping, hasBilling, hasCount, isMembershipSubscribed. |
ShopCautionHelper, ShopDebugging
|
Warnings about shop configuration and theme. |
SpecHelper |
CONVERT_SPEC_JSON_TO_ARRAY, CONVERT_SPEC_ARRAY_TO_JSON for product specifications. |
LogisticHelper |
calculateWeightBasket, calculateVolumeBasket, calculateDistanceBasket, GPSCalculateDistance, calculateShipping. |
MapHelper |
GenerateFullAddressFromMapInfo(address), GetMapImage(lng, lat, zoom, size?, style_id?) (Mapbox static image), GetMapDirectionUrl(...). |
ShopCategoryHelper, DeliveryServiceHelper
|
Icon URLs by ID. |
CampaignHelper |
Traffic source aggregation for campaign reports. |
AugmentHelper |
MixAugments, ConvertToAugmentArray: build "augment" lists ({ key, value }[]) that applyAugment() uses to replace {{key}} placeholders in texts. |
StorefrontLocalStorages centralizes the local-storage keys used by storefronts, so every package reads and writes the same keys:
import { StorefrontLocalStorages } from "@selldone/core-js";
const base = "shop/@my-shop/";
StorefrontLocalStorages.GetUserCurrencyPath(base); // "shop/@my-shop/user-currency"
StorefrontLocalStorages.GetShopCouponsCodes(base); // "shop/@my-shop/coupon-codes"
StorefrontLocalStorages.GetSeenPopups(base); // "shop/@my-shop/seen-pops"
StorefrontLocalStorages.SetShopGuestCode(code); // guest checkout code
StorefrontLocalStorages.GetShopHistoryGuestAllCodes(); // guest codes of previous ordersBackofficeLocalStorages does the same for dashboards. LRUCache<K, V> is a small least-recently-used cache (get, set, clear, entries, length); APIAbstract uses one to cache responses.
GlobalRules (default export of helper/rules/GlobalRules) provides validators and Vuetify-style rule factories whose error messages come from window.$i18n_global:
import GlobalRules from "@selldone/core-js/helper/rules/GlobalRules";
GlobalRules.ValidateEmail("jane@example.com"); // true
GlobalRules.ValidURL("selldone.com"); // true
// In a Vuetify field: :rules="[GlobalRules.required(), GlobalRules.email()]"Rule factories: required(), counter(maxCount), email(), domain(), minLength(length), url().
ProductsCsvFormat, CategoriesCsvFormat, CustomersCsvFormat, InventoryCsvFormat and VendorsCsvFormat define the column headers, styling and a CheckValidFile() check for bulk imports (see also the excel templates). helper/converters/ExcelConverter (default export) turns a JSON array into a legacy SpreadsheetML .xls download in the browser.
| Helper | Use |
|---|---|
MD5.hash(value) |
MD5 hash of a string. |
ToQueryString(obj), RandomString(length)
|
String utilities (helper/string/StringHelper). |
StripTags, CompileMarkdown, SmartConvertTextToHtml, SmartConvertTextToHtmlHashtags
|
HTML and Markdown helpers. |
SEO |
GetPageTitleScore, GetPageURLScore, GetPageDescription, CTRScore. |
StringToColour, ShadeColor, interpolateColors, color sets |
Color utilities (helper/color/). |
FontLoader, FontHelper, FontSizeHelper
|
Load web and custom fonts, auto-size text. |
ImageDimension, PlaceholderImages
|
Image aspect ratios and placeholder images. |
VideoHelper.GetMime, SoundHelper
|
Media helpers. |
CONSOLE.log |
Logging helper. |
| Utility | Description |
|---|---|
Cookie (utils/cookie/cookie) |
config, get, set(key, value, expires?, path?, domain?, secure?, sameSite?, partitioned?), remove(key, path?, domain?), isKey, keys. SelldoneCore.Setup() registers it as window.$cookies. |
console.style() (utils/console/ConsoleStyle) |
Styled console messages with inline tags, e.g. console.style("<b='color:#009688'>Ready</b>"). Installed when you import SelldoneCore. |
Slugify.apply(text, options?) (utils/slugify/slugify) |
URL slugs with locale maps. Options: replacement, remove, lower, strict, locale, trim. |
debounceSearch(func, wait = 750, immediate = true) (utils/thread/threads) |
Debounce for search inputs. |
FileHelper |
GetFileName, GetFileExtension, GetFileIcon, DataURItoBlob, DownloadBlobFile, LoadFile, GetFileExtensionImage. |
ScrollHelper (default export) |
scrollToTop(top?, behavior?), scrollToElement(selector, offset?, behavior?, center?). |
ThemeHelper |
SetMetaThemeColor(color, calculator_element?), SetHtmlFontSize(low_vision). |
ImageHelper |
Image dimension lookups with a short-lived cache (clearCache(url?)). |
registerServiceWorker (utils/service-worker/registerServiceWorker) |
Default-exported function that registers /service-worker.js (PWA) when NODE_ENV is production. |
import { Slugify } from "@selldone/core-js/utils/slugify/slugify";
import { debounceSearch } from "@selldone/core-js";
Slugify.apply("Summer Sale 2026!", { lower: true, strict: true }); // "summer-sale-2026"
const onInput = debounceSearch((text: string) => search(text), 500);Importing the package root installs these extensions (declared globally for TypeScript):
| Type | Methods |
|---|---|
Array |
limit(max), insert(index, item), findMax(), findMin(), sortByKey(key, ASC = false), random(), remove(val), add(val), toggle(val, key?), move(from, to), moveRight(i), moveLeft(i), sumByKey(key), minByKey(key), maxByKey(key), countUnique(key), unique(), uniqueByKey(key), rotateRight(n), removeNulls(clone), applyAugment(...)
|
String |
isNumber(), limitWords(n), wordsCount(), starMiddle(visible = 6, max_stars = 10), ellipsis(length), toColor(dark?), removeVariantAsset(), hasVariantAsset(), applyAugment(...), findAllDynamicAugmentKeys(), toTransportationObject()
|
Number |
applyAugment(...) |
HTMLElement / HTMLTextAreaElement / Document
|
insertAtCaret(text), selectionAddTag(...), selectionSetStyle(...)
|
[5, 3, 9].findMax(); // 9
items.sumByKey("price"); // total of item.price
baskets.uniqueByKey("type"); // one basket per type
"A very long product title".ellipsis(10); // "A very ..."
"jane.doe@example.com".starMiddle(4); // "jane**********.com"prototypes/ObjectPrototypes also exports two functions: ApplyAugmentToObject(object, augment, bypass?) and RemoveEmptyFromObject(obj).
TimeSeries turns daily statistics rows (each with a created_at) into ready-to-chart views for dashboards. Import it by path:
import { TimeSeries } from "@selldone/core-js/timeserie/TimeSeries";
// raw_data: [{ created_at: "2026-10-01", views: 12, sells: 3 }, …]
const series = new TimeSeries(raw_data, "Shop stats", 0 /* offset days */, 30 /* days */);
series.todayData(); // values for today
series.yesterdayData();
series.lastWeekData(); // last 7 days
series.lastMonthData();
series.arrayOfTime("created_at", true); // localized date labels
series.simpleChartDataset("views", "sells"); // [[views, sells], …] per day
series.downloadExcel(); // download the raw data as .xls (ExcelConverter)Duplicate rows for the same day are ignored (the first one is kept). Other methods include previousWeekData(), lasDaysDataPack(days, offset), financeTotalOf(key), getTotalAllKeys(except_keys), maxItemByKey(key) and TimeSeries.diffDays(t1, t2).
- Server and APIs
- Models and Types
- Enums
- Components: see these helpers used in real UI.