Magento IWD Onepage checkout - set default shipping method

Magento IWD Onepage checkout - set default shipping method

September 28, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento IWD Onepage checkout - set default shipping method

Show Magento IWD Onepage Checkout Shipping Methods on Page Load

Are you trying to display shipping methods before the user enters their shipping information in your Magento store’s IWD Onepage checkout? By default, this module shows available shipping methods only after filling out the shipping details form. But what if you want to show those options right away?

In this post, we’ll guide you through implementing this feature step-by-step. We’ll provide a practical solution that works and explain the reasoning behind it.

Understanding the Default Behavior

Before we dive into customization, let’s understand why Magento (and IWD Onepage checkout) have this default behavior:

  1. Dynamic Shipping Rates: Most carriers calculate shipping rates based on real-time factors like distance, weight, package dimensions, etc.
  2. Performance Optimization: Loading all available shipping methods can be resource-intensive for large catalogs or when using multiple carriers.

Changing the Default Behavior

To show shipping methods before users enter their shipping information, we’ll need to override some core Magento functionality and IWD Onepage checkout logic.

Step 1: Override Magento’s Shipping Method Collection Generation

Open your terminal and navigate to:

app/code/local/Iwd/OneStepCheckout/Model/Shipping/Carrier/Abstract.php

In this file, find the getRates method. We’ll modify it to fetch shipping methods without validation.

Step 2: Retrieve Shipping Methods Without Validation

Replace the existing getRates implementation with the following code:

public function getRates($request)
{
    $this->resetQuote();
    $rates = [];

    if (!$this->isAllowed($request)) {
        return [];
    }

    $method = $this->getMethod();

    // This is where we fetch all available methods without validation
    $rate = Mage::getModel('shipping/rate_request')->getRequest(
        $request,
        $method
    );

    if ($rate) {
        foreach ($rate->getAllRates() as $rate) {
            $rates[] = [
                'code' => $rate->getCode(),
                'name' => $rate->getName(),
                'title' => $this->getRateTitle($rate),
                'price' => $this->getRatePrice($rate, $request)
            ];
        }
    }

    return $rates;
}

Step 3: Set the Shipping Method Immediately

Now, let’s set a default shipping method automatically when the page loads. Open your terminal and navigate to:

app/code/local/Mage/Checkout/controllers/OnepageController.php

Find the saveShippingAddress action.

Add this code at the beginning of the action:

if (!$quote->isVirtual()) {
    $shippingAddress = $quote->getShippingAddress();
    $shippingAddress->setCountryId('UK')
        ->setShippingMethod('matrixrate_matrixrate') // Set your method here
        ->save();
}

This will set the ‘matrixrate_matrixrate’ shipping method for UK shipments automatically.

Conclusion

In this post, we’ve demonstrated how to show Magento IWD Onepage checkout shipping methods before users enter their shipping details. By overriding core Magento and IWD Onepage checkout logic, we achieved our goal of displaying available shipping options from page load.

Remember, this approach deviates from the default behavior for a specific reason—improving the user experience by showing available shipping methods upfront. However, it comes with potential trade-offs in terms of performance and flexibility.

If you’re a Magento developer looking to customize your store’s checkout process or need expert guidance on other aspects of Magento development, don’t hesitate to reach out to Laravel Company.

Happy coding!

Checkout Catalog Performance Extensions

Our network