EasyStore - Custom Shipping Method Configuration - Question | JoomShaper

EasyStore - Custom Shipping Method Configuration

SG

Steven Guigou

EasyStore 2 weeks ago

Hello, my team and I are developing a local shipping method (for Uruguay) to add to EasyStore. We have a first version, but when we test it, something isn't working. Our shipping method dynamically calculates the shipping cost at checkout; that is, the plugin communicates via API with a service that, based on the delivery address, returns the shipping cost. I can't figure out how to configure it. Is there a way to configure a shipping method like this in EasyStore without having to set static amounts?

Thanks, regards!

0
1 Answers
Atick Eashrak Shuvo
Atick Eashrak Shuvo
Accepted Answer
Support Agent 1 week ago #231917

Hello Steven,

Yes, EasyStore supports dynamic, API-calculated shipping methods, so you do not need to configure static shipping amounts in the backend.

EasyStore uses a dynamic carrier plugin architecture under the easystoreshipping plugin group. To set this up, please check the following:

1. EasyStore Configuration

  1. Go to System → Plugins in Joomla, locate your custom shipping plugin under the easystoreshipping group, enable it, and configure your API parameters.
  2. Go to EasyStore → Settings → Shipping.
  3. Edit the relevant shipping zone (for example, Uruguay).
  4. Under Carrier Options, enable your custom carrier plugin.
  5. You do not need to define static prices or weight-based rules for the carrier if the shipping cost is being returned dynamically by your API.

2. Custom Plugin Requirements

If the rate is not appearing during checkout, please make sure your plugin follows EasyStore's shipping plugin architecture:

  • The plugin group should be easystoreshipping in the plugin manifest.
  • The plugin should extend JoomShaper\Component\EasyStore\Administrator\Plugin\CommonShippingPlugin.
  • The plugin should listen for the onEasyStoreGetShippingMethods event.
  • The shipping address can be retrieved from the checkout event, including the country, state, city, postcode, and address.
  • After receiving the shipping cost from your API, the calculated rate needs to be added to the shippingMethods array and passed back through the event.

For example:

namespace YourNamespace\Plugin\EasyStoreShipping\UruguayCarrier\Extension;

use Joomla\Event\Event;
use JoomShaper\Component\EasyStore\Administrator\Plugin\CommonShippingPlugin;

class UruguayCarrierShipping extends CommonShippingPlugin
{
    public function onEasyStoreGetShippingMethods(Event $event)
    {
        $arguments = $event->getArguments();
        $shippingAddress = $arguments['subject']->shipping_address;

        // Validate the shipping address
        if (
            empty($shippingAddress) ||
            empty($shippingAddress->country_code) ||
            empty($shippingAddress->city)
        ) {
            return;
        }

        // Call your Uruguay shipping API here
        $apiResponse = $this->callUruguayCarrierApi($shippingAddress);

        $shippingMethods = $event->getArgument('shippingMethods') ?? [];

        foreach ($apiResponse['rates'] as $rate) {
            $shippingMethods[] = [
                'uuid'     => $this->generate_uuid(),
                'id'       => 'uruguay_carrier_' . $rate['code'],
                'name'     => $rate['title'],
                'rate'     => (float) $rate['amount'],
                'estimate' => $rate['delivery_time'],
                'provider' => $this->_name,
            ];
        }

        $event->setArgument('shippingMethods', $shippingMethods);
    }
}

The important part is that the rate value is populated with the amount returned by your API. EasyStore can then use that value as the shipping cost during checkout without requiring a predefined static amount in the shipping configuration.

If you are still having trouble with your current implementation, please share the plugin code and any error messages/console or network errors you see when the shipping address is entered at checkout. We can then check whether the issue is related to the event, address data, API response, or the way the shipping method is being registered.

0