ChemPal Documentation - v1.6.0
    Preparing search index...

    Module helpers/purchaseRestriction

    Functions - Helpers

    canUserBuy

    Decides whether the current user may buy a single option (a product or one of its variants) given their location. Region, EU-only, unresolved-delivery, and buyer restrictions all exclude; a declaration-of-use requirement is informational and never excludes. An option with no restriction is buyable. euOnly is checked against EU_COUNTRY_CODES (the 27 EU member states), and an unknown user location is treated as ineligible for the safe EU-only case.

    filterRestrictedProduct

    Filters a grouped product against the user's location, hiding options they can't buy. The parent product is one purchasable option and its variants are the others (they're disjoint — SupplierBase.groupVariants splices the representative out of the variant list). Restricted variants are pruned; if the representative itself is restricted but a variant is buyable, the cheapest buyable variant is promoted into the representative's sale fields (identity fields are kept). Returns undefined when no option is buyable.