Request a Demo
  • Platform
    • Donations
    • Campaigns
    • Events
    • eCards
    • CRM
  • Features
  • Integrations
  • Resources
    • Docs
    • Product updates
    • Changelog
  • Company
  • Platform
    • Donations
    • Campaigns
    • Events
    • eCards
    • CRM
  • Features
  • Integrations
  • Resources
    • Docs
    • Product updates
    • Changelog
  • Company
Request a Demo

Classes

  • Helpers/AdminMenuHelper
  • Helpers/API
  • Helpers/Helper
View Categories

Helpers/Helper

4 min read

Namespace #

LevCharity\Helpers\Helper

Overview #

The Main Helper class with static methods that you can use everywhere


Properties #


NameTypeVisibilityUsageDescription
$propertystring[]privatestatic (or leave empty)Some description here

Methods #

convertMetaKeyToTitle #

Converts a meta key (slug) into a human-readable title by removing a prefix and transforming it into a title-case format.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$slugstringn/aThe slug to convert.

Examples:

LevCharity\Helpers\Helper::convertMetaKeyToTitle('levcharity_custom_field_example_slug');

formatToCamelCase #

Converts a string into camelCase format. Non-alphanumeric characters are replaced by spaces, and words are capitalized, except the first word.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$stringstringn/aThe string to format.

Examples:

LevCharity\Helpers\Helper::formatToCamelCase('example_string_to_convert');

convertYearToHebrew #

Converts a Gregorian year to its corresponding Hebrew year. Returns null if the year is invalid.

Returns: int|null

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$yearintn/aThe Gregorian year to convert.

Examples:

LevCharity\Helpers\Helper::convertYearToHebrew(2025);

mergeMultipleObjects #

Merges multiple objects into one by copying the properties of each object to the first object.

Returns: object

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$objectsarrayn/aAn array of objects to merge.

Examples:

LevCharity\Helpers\Helper::mergeMultipleObjects([$object1, $object2]);

getApprovalInfoByHash #

Fetches the approval information based on a provided hash. Returns an empty array if no information is found.

Returns: array

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$hashstringn/aThe hash used to find approval information.

Examples:

LevCharity\Helpers\Helper::getApprovalInfoByHash('someHash');

generateHashAndSaveInfoInUserMeta #

Generates a hash based on the user ID and stores related approval information in the user meta.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$user_idintn/aThe user ID for which the hash is generated.
$team_idintn/aThe team ID related to the user.
$captain_idintn/aThe captain ID associated with the user.

Examples:

LevCharity\Helpers\Helper::generateHashAndSaveInfoInUserMeta(1, 10, 5);

formatAmount #

Formats an amount into a human-readable form with an appropriate suffix (K for thousands, M for millions). Default is two decimal places.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$amountfloatn/aThe amount to format.
$decimalsint2The number of decimals to display.

Examples:

LevCharity\Helpers\Helper::formatAmount(1234567);

formatAmountWithCommas #

Formats an amount with commas separating the thousands.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$amountfloatn/aThe amount to format.

Examples:

LevCharity\Helpers\Helper::formatAmountWithCommas(1234567);

dateTimeToUTC #

Converts a given datetime to UTC format, considering the timezone offset from cookies.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$dateTimestringn/aThe datetime to convert.
$formatstring‘Y-m-d H:i:s’The format for the resulting UTC datetime.

Examples:

LevCharity\Helpers\Helper::dateTimeToUTC('2025-01-15 10:00:00');

UTCToLocalTime #

Converts a UTC datetime to local time based on the user’s timezone offset from cookies.

Returns: string|false|int

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$date_time_utcint|string‘now’The UTC datetime to convert.
$formatstring|false‘Y-m-d H:i:s’The format for the local datetime or timestamp.

Examples:

LevCharity\Helpers\Helper::UTCToLocalTime('2025-01-15 10:00:00');

utcTimeNow #

Returns the current UTC timestamp.

Returns: false|int

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
NoneNonen/aNo properties.

Examples:

LevCharity\Helpers\Helper::utcTimeNow();

allowedCurrencies #

Returns a list of allowed currencies, optionally excluding the shop’s default currency.

Returns: array

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$withoutShopCurrencybooltrueWhether to exclude the shop’s default currency from the result.

Examples:

LevCharity\Helpers\Helper::allowedCurrencies();

getP2PGoalAmountAndCurrencyByName #

Returns the goal amount and currency for a given name and currency, or an empty object if no match is found.

Returns: object|null

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$namestringn/aThe name of the goal to match.
$currencystringn/aThe currency to retrieve the amount in.

Examples:

LevCharity\Helpers\Helper::getP2PGoalAmountAndCurrencyByName('goalName', 'USD');

getLocalizedUrl #

Returns the localized URL for the provided URL based on the current language.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$urlstringn/aThe URL to localize.

Examples:

LevCharity\Helpers\Helper::getLocalizedUrl('http://example.com');

getCurrencyCodeFromLocale #

Returns the currency code for the given locale.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$localestringn/aThe locale for which to get the currency code.

Examples:

LevCharity\Helpers\Helper::getCurrencyCodeFromLocale('en_US');

calculateProductPriceForCart #

Calculates the price for a product in the cart, adjusting based on predefined or custom amounts, currency, and payment options.

Returns: void

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$cart_itemarrayn/aThe cart item array.
$cart_objectarrayn/aThe cart object (optional).
$return_priceboolfalseWhether to return the calculated price.

Examples:

LevCharity\Helpers\Helper::calculateProductPriceForCart($cart_item, $cart_object, $return_price);

checkUserEmail #

Checks if the user’s email domain is allowed (either ‘leverage.it’ or ‘levcharity.com’).

Returns: bool

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$user_idintn/aThe user ID to check.

Examples:

LevCharity\Helpers\Helper::checkUserEmail($user_id);

getModuleRedirectUrl #

Returns the redirect URL for the specified module, either to the cart or checkout page.

Returns: string

Visibility: public

Usage: static

Properties:

NameTypeDefaultDescription
$modulestringn/aThe module name for which to retrieve the redirect URL.

Examples:

LevCharity\Helpers\Helper::getModuleRedirectUrl('donation');

Was this article helpful?
Still stuck? How can we help?

How can we help?

Updated on January 16, 2025
Helpers/API
Table of Contents
  • Namespace
  • Overview
  • Properties
  • Methods
    • convertMetaKeyToTitle
    • formatToCamelCase
    • convertYearToHebrew
    • mergeMultipleObjects
    • getApprovalInfoByHash
    • generateHashAndSaveInfoInUserMeta
    • formatAmount
    • formatAmountWithCommas
    • dateTimeToUTC
    • UTCToLocalTime
    • utcTimeNow
    • allowedCurrencies
    • getP2PGoalAmountAndCurrencyByName
    • getLocalizedUrl
    • getCurrencyCodeFromLocale
    • calculateProductPriceForCart
    • checkUserEmail
    • getModuleRedirectUrl
Join our newsletter

Add your email to stay up to date on features and new releases:

loader

  • Docs
  • Changelog
  • Privacy Policy
  • Terms of Service
  • Cookies Settings
  • Docs
  • Changelog
  • Privacy Policy
  • Terms of Service
  • Cookies Settings