@selldone/sdk-storefront
Version:
A TypeScript SDK to connect to your shop and build a fully functional storefront and website by simply developing a frontend web application. All backend operations are seamlessly managed by the serverless Selldone solution.
60 lines (59 loc) • 3.78 kB
TypeScript
import { Currency } from "../../enums/payment/Currency";
import { Shop } from "../../models/shop/shop.model";
import { Product } from "../../models/shop/product/product.model";
import type { BasketItem } from "../../models/shop/order/basket/basket_item.model";
import type { SubscriptionPrice } from "../../models/shop/product/subscription_price.model";
import type { ProductVariant } from "../../models/shop/product/product_variant.model";
import type { Valuation } from "../../models/shop/accounting/valuation/valuation.model";
import type { ExtraPricing } from "../../models/shop/extra-pricing/extra-pricing.model";
export declare class PriceHelper {
static FixPrecision(val: number, floats: number): number;
static FixPrecisionForCurrency(val: number, currency: keyof typeof Currency): number;
static getExchangeRate(shop: Shop, from: keyof typeof Currency, to: keyof typeof Currency): import("../..").ExchangeRate | {
rate: number;
} | null | undefined;
static getExchangeRateValue(shop: Shop, from: keyof typeof Currency, to: keyof typeof Currency, default_rate?: number | null): number | null | undefined;
static getBuyRateValue(shop: Shop, from_currency: keyof typeof Currency, to_currency: keyof typeof Currency): number | null;
static getBasketItemPrice(shop: Shop, item: BasketItem, to_currency: keyof typeof Currency): number | "Error";
static getBasketItemDiscount(shop: Shop, item: BasketItem, to_currency: keyof typeof Currency): number | "Error";
static getBasketItemSumPriceDiscount(shop: Shop, item: BasketItem, to_currency: keyof typeof Currency): number | "Error";
/**
* Get product price (final price)
* @param shop
* @param product Original product : in normal mode | Vendor product : in marketplace mode
* @param variant
* @param to_currency
* @param preferences Preferences by user (Used in valuation - custom pricing input)
* @param valuation Valuation (Pricing forms), Get independently because in marketplace mode we receive vendor product instead of original product.
* @param subscription_price
* @param current_extra_pricing
* @returns number | null
* @throws {Error}
*/
static priceProductByCurrency(shop: Shop, product: Product & {
valuation?: Valuation | null;
}, variant: ProductVariant | null, to_currency: keyof typeof Currency, preferences?: BasketItem.IPreferences | null, valuation?: Valuation | null, subscription_price?: SubscriptionPrice | null, // 🎗️ Subscription
current_extra_pricing?: ExtraPricing | null): number;
/**
* 🍁 Apply price auto calculation by custom pricing input 🍁
*
* @param valuation Valuation (Pricing forms), Get independently because in marketplace mode we receive vendor product instead of original product.
* @param preferences
* @param base_price
* @returns {*}
* @constructor
*/
static ApplyValuation(valuation: Valuation | null | undefined, preferences: BasketItem.IPreferences | null | undefined, base_price: number): number;
/**
* Calculate discount (final & check date of discount)
* @param shop
* @param product
* @param variant
* @param to_currency
* @returns {*}
*/
static getProductDiscountAmountByCurrency(shop: Shop, product: Product, variant: ProductVariant | null, to_currency: keyof typeof Currency): number;
static discountProductPercent(shop: Shop, product: Product, variant: ProductVariant | null, to_currency?: keyof typeof Currency): number;
static HasDiscountCountDownMode(product: Product, variant?: ProductVariant | null): boolean;
static GetEndOfDiscountDate(product: Product, variant?: ProductVariant | null): Date | null;
}