# Helpers

# Introduction

Bagisto provides several helper methods in its packages, which are designed to assist developers in building their projects more efficiently.

# Core Helpers

The core helper methods mentioned below are part of the Core class in the Webkul\Core namespace. Let's explore some common methods:

  • Get the version number of the Bagisto.
core()->version()
  • Get all channels.
core()->getAllChannels()
  • Get current channel models.
core()->getCurrentChannel()
  • Set the current channel.
core()->setCurrentChannel($channel)
  • Get current channel code.
core()->getCurrentChannelCode()
  • Get current channel code.
core()->getCurrentChannelCode()
  • Get default channel models.
core()->getDefaultChannel()
  • Set the default channel.
core()->setDefaultChannel()
  • Get the default channel code configured in config/app.php.
core()->getDefaultChannelCode()
  • Get default locale code from default channel.
core()->getDefaultLocaleCodeFromDefaultChannel()
  • Get channel from request.
core()->getRequestedChannel()
  • Get channel code from request.
core()->getRequestedChannelCode()
  • Get the channel name.
core()->getChannelName()
  • Get all locales.
core()->getAllLocales()
  • Get current locale.
core()->getCurrentLocale()
  • Get locale from request.
core()->getRequestedLocale()
  • Get locale code from request. Here if you want to use admin locale, you can pass it as an argument.
core()->getRequestedLocaleCode($localeKey = 'locale', $fallback = true)
  • Check requested locale code in requested channel. If not found, then set channel default locale code.
core()->getRequestedLocaleCodeInRequestedChannel()
  • Get all currencies.
core()->getAllCurrencies()
  • Get base currency model.
core()->getBaseCurrency()
  • Get base channel's currency code.
core()->getBaseCurrencyCode()
  • Get base channel's currency model.
core()->getChannelBaseCurrency()
  • Get base channel's currency code.
core()->getChannelBaseCurrencyCode()
  • Set current currency.
core()->setCurrentCurrency()
  • Get current channel's currency model.
core()->getCurrentCurrency()
  • Get current channel's currency code.
core()->getCurrentCurrencyCode()
  • Get exchange rates.
core()->getExchangeRate()
  • Converts price.
core()->convertPrice($amount, $targetCurrencyCode = null)
  • Converts to base price.
core()->convertToBasePrice($amount, $targetCurrencyCode = null)
  • Format and convert price with currency symbol.
core()->convertToBasePrice($amount)
  • Get currency symbol from currency code.
core()->currencySymbol($amount)
  • Format and convert price with currency symbol.
core()->formatPrice($price, $currencyCode = null)
  • Format price with base currency symbol. This method also give ability to encode the base currency symbol and its optional.
core()->formatBasePrice($price, $isEncoded = false)
  • Checks if current date of the given channel (in the channel timezone) is within the range.
core()->isChannelDateInInterval($dateFrom = null, $dateTo = null)
  • Get channel timestamp, timestamp will be builded with channel timezone settings.
core()->channelTimeStamp($channel)
  • Check whether sql date is empty.
core()->is_empty_date($date)
  • Format date using current channel.
core()->formatDate($date = null, $format = 'd-m-Y H:i:s')
  • Retrieve information from configuration.
core()->getConfigData($field, $channel = null, $locale = null)
  • Retrieve all countries.
core()->countries()
  • Get country name by code.
core()->country_name($code)
  • Retrieve all country states.
core()->states($countryCode)
  • Retrieve all grouped states by country code.
core()->groupedStatesByCountries()
  • Get states by country code.
core()->findStateByCountryCode($countryCode = null, $stateCode = null)
  • Get guest customer group.
core()->getGuestCustomerGroup()
  • Is country required.
core()->isCountryRequired()
  • Is state required.
core()->isStateRequired()
  • Is postcode required.
core()->isPostCodeRequired()
  • Week range.
core()->xWeekRange($date, $day)
  • Method to sort through the acl items and put them in order.
core()->sortItems($items)
  • Get config field.
core()->getConfigField($fieldName)
  • Convert to associative array.
core()->convertToAssociativeArray($items)
  • Array set.
core()->array_set(&$array, $key, $value)
  • Convert empty strings to null.
core()->convertEmptyStringsToNull($array)
  • Create singleton object through single facade.
core()->getSingletonInstance($className)
  • Returns a string as selector part for identifying elements in views.
core()->taxRateAsIdentifier(float $taxRate)
  • Get tax category through Id.
core()->getTaxCategoryById($id)
  • Get Shop email sender details.
core()->getSenderEmailDetails()
  • Get Admin email details.
core()->getAdminEmailDetails()
  • Array merge.
core()->arrayMerge(array &$array1, array &$array2)
  • Get core config values.
core()->getCoreConfig($field, $channel, $locale)
  • Get default config.
core()->getDefaultConfig($field)
  • Get max upload size from the php.ini file.
core()->getMaxUploadSize()

These core helper methods provide various functionalities to simplify common tasks and streamline development in Bagisto.