Skip to content

Feature Request: Disable Carrier if Any Product Exceeds Specific Weight #134

Description

@gadnis

Hi,

I'd like to request a new feature related to carrier availability conditions.

Feature Idea

Disable a shipping carrier if at least one product in the cart exceeds a configurable weight limit (e.g., 31.5 kg).

Why We Need It

There are countries where DPD does not ship items heavier than 31.5 kg per item, or the shipping cost becomes unreasonably high. In such cases, it's more efficient to disable DPD and use alternative carriers that can handle heavy parcels.

Real Example

Our client sells musical instruments, including heavy items like digital pianos that often weigh more than 31.5 kg.
Currently, PrestaShop allows carrier restrictions only based on total cart weight, which is inefficient in this case. A cart may contain many light items that collectively exceed the limit.

Proposed Solution

We need an option to iterate through all cart products and disable the carrier if any product's weight exceeds a configurable threshold.

At the moment, I've implemented a custom solution by hardcoding the logic inside the getOrderShippingCostExternal method in dbdbaltics.php:

if (isset($deliveryAddress->id_country) && $cart->getTotalWeight() > 31.5) {
    $cartCountryIsoCode = \Country::getIsoById($deliveryAddress->id_country);
    $heavyParcelCountryIsoCodes = ['LT', 'LV', 'EE', 'PL'];

    if (!in_array($cartCountryIsoCode, $heavyParcelCountryIsoCodes)) {
        foreach ($cart->getProducts() as $product) {
            if (isset($product['weight']) && $product['weight'] > 31.5) {
                return false;
            }
        }
    }
}

Request

Could you let me know if this feature might be considered for implementation in the near future?

Thanks in advance for your time

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions