Back to PhocacartCountry class

Method getCountries

public static
getCountries
(mixed $id, mixed $select = 0, mixed $table = 'shipping')

Method getCountries - Source code

public static function getCountries($id, $select = 0, $table = 'shipping')
{
    if ($table == 'shipping') {
        $t = '#__phocacart_shipping_method_countries';
        $c = 'shipping_id';
    } else {
        if ($table == 'payment') {
            $t = '#__phocacart_payment_method_countries';
            $c = 'payment_id';
        } else {
            if ($table == 'zone') {
                $t = '#__phocacart_zone_countries';
                $c = 'zone_id';
            }
        }
    }
    $db = Factory::getDBO();
    if ($select == 1) {
        $query = 'SELECT c.country_id';
    } else {
        $query = 'SELECT a.*';
    }
    $query .= ' FROM #__phocacart_countries AS a' . ' LEFT JOIN ' . $t . ' AS c ON a.id = c.country_id' . ' WHERE c.' . $c . ' = ' . (int) $id . ' ORDER BY a.id';
    $db->setQuery($query);
    if ($select == 1) {
        $countries = $db->loadColumn();
    } else {
        $countries = $db->loadObjectList();
    }
    return $countries;
}