# 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 all channels:

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

    core()->getCurrentChannel();
    
  • Set the current channel: This method takes an instance of the Webkul\Core\Models\Channel class as an argument.

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

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

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

    core()->getDefaultChannelCode();
    
  • Get the requested channel code: This method is useful when you need to retrieve the channel from the request, with an optional fallback parameter.

    core()->getRequestedChannelCode($fallback = true);
    
  • Get the channel name: This method retrieves the name of the channel. It handles fallback cases by checking the name in the property, app locale code, and the app.fallback_locale config key.

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

    core()->getAllLocales();
    
  • Get all locales by requested channel: This method provides all the locales associated with the requested channel.

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

    core()->getCurrentLocale();
    
  • Get the requested locale code: This method retrieves the locale code from the request, with optional parameters for specifying the locale key and fallback behavior.

    core()->getRequestedLocaleCode($localeKey = null, $fallback = true);
    
  • Get all customer groups:

    core()->getAllCustomerGroups();
    
  • Get the requested customer group code: This method fetches the customer group code from the request.

    core()->getRequestedCustomerGroupCode();
    
  • Get all 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 data based on the key, channel, and locale:

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

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

    core()->country_name($countryCode);
    
  • Get all states of a country:

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

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

    core()->getAdminEmailDetails();
    

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