# Helpers

In Bagisto, there are several packages have been used. We have provided useful helper methods in the packages which can help developers to develop their projects with ease.

# Core Helpers

All the mentioned helper methods are from Bagisto's core package class named Core in the Webkul\Core namespace. Let's discuss some common methods,

  • Get all the channels,

    core()->getAllChannels();
    
  • Get the current channel,

    core()->getCurrentChannel();
    
  • Set the current channel, this method will take one argument i.e. instance of this class Webkul\Core\Models\Channel,

    core()->setCurrentChannel($channel);
    
  • Get the current channel code,

    core()->getCurrentChannelCode();
    
  • Get the default channel,

    core()->getDefaultChannel();
    
  • Get the default channel code,

    core()->getDefaultChannelCode();
    
  • Get requested channel code, this method is useful when you need to fetch the channel from the request, and no need to worry about the fallback as well. This method also has the optional parameter $fallback, which means the developer can use this with or without fallback,

    core()->getRequestedChannelCode();
    
  • Get the channel name, yeah we know that you can chain it with the Channel instance but the purpose of this method is to handle the fallback case as well. This method will first check the name in the property, if not found then it will proceed further with app locale code, if still not found then it will check from the config key name as app.fallback_locale,

    core()->getChannelName($channel);
    
  • Get all the locales,

    core()->getAllLocales();
    
  • Get all locales by requested channel, this method will provide you all the locales associated with the requested channel,

    core()->getAllLocalesByRequestedChannel();
    
  • Get the current locale,

    core()->getCurrentLocale();
    
  • Get the requested locale code, this method is useful when you need to fetch the locale code from the request, and no need to worry about the fallback as well. This method also has the optional parameter $localeKey and $fallback, which means the developer can use this with or without fallback,

    core()->getRequestedLocaleCode();
    
  • Get all the customer groups,

    core()->getAllCustomerGroups();
    
  • Get requested customer group code, this method will fetch you customer group code from the request,

    core()->getRequestedCustomerGroupCode();
    
  • Get all the currencies,

    core()->getAllCurrencies();
    
  • Get the base currency,

    core()->getBaseCurrency();
    
  • Get the base currency code,

    core()->getBaseCurrencyCode();
    
  • Get the channel based currency,

    core()->getChannelBaseCurrency();
    
  • Get the channel based currency code,

    core()->getChannelBaseCurrencyCode();
    
  • Get the current currency,

    core()->getCurrentCurrency();
    
  • Get the current currency code,

    core()->getCurrentCurrencyCode();
    
  • Get the exchange rate based on the currency id,

    core()->getExchangeRate($targetCurrencyId);
    
  • Get the formatted amount,

    core()->currency($amount = 0);
    
  • Get the configuration date based on the key, channel and locale,

    core()->getConfigData($field, $channel = null, $locale = null);
    
  • Get all the countries,

    core()->countries();
    
  • Get the country name by country code,

    core()->country_name($countryCode);
    
  • Get all the country's state,

    core()->states($countryCode);
    
  • Get sender email details,

    core()->getSenderEmailDetails();
    
  • Get admin email details,

    core()->getAdminEmailDetails();