Back to PhocacartShipping class

Method isShippingNotUsed

public static
isShippingNotUsed
(mixed $options = array())

Method isShippingNotUsed - Source code

/* Checkout - is there even some shipping NOT is used reverse
 * This function is different to getPossibleShippingMethods()
 *
 * getPossibleShippingMethods - all methods they fit the criterias (e.g. amount rule, contry rule, etc.)
 * isShippingNotUsed() - all existing methods in shop which are published
 *
 * IF NO SHIPPPING METHOD EXIST - it is ignored when 1) skip_shipping_method parameter is enabled 2) all products are digital and skip_shipping_method is enabled
 *
 * */
public static function isShippingNotUsed($options = array())
{
    $paramsC = PhocacartUtils::getComponentParameters();
    $skip_shipping_method = $paramsC->get('skip_shipping_method', 0);
    // 1) TEST IF ANY SHIPPING METHOD EXISTS
    $db = Factory::getDBO();
    $query = 'SELECT a.id' . ' FROM #__phocacart_shipping_methods AS a' . ' WHERE a.published = 1' . ' AND a.type IN (0, 1)' . ' ORDER BY id LIMIT 1';
    $db->setQuery($query);
    $methods = $db->loadObjectList();
    if (empty($methods) && $skip_shipping_method == 2) {
        return true;
    }
    // 2) TEST IF SHIPPING METHOD IS NOT DISABLED FOR ALL DOWNLOADABLE PRODUCTS
    // PRODUCTTYPE tested
    if (isset($options['all_digital_products']) && $options['all_digital_products'] == 1 && $skip_shipping_method == 1) {
        return true;
    }
    return false;
}