verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

Add order to modify rates event #10

Closed keyurshah closed 4 years ago

keyurshah commented 4 years ago

I was thinking of how to access the order information from a modify rates event. Would it be possible to include $event->order as an event property or is the $order info available in some other way?

Event::on(USPS::class, Provider::EVENT_MODIFY_RATES, function(ModifyRatesEvent $event) {
    $rates = $event->rates; // The calculated rates from Postie
    $response = $event->response; // The raw response from the provider's API

    // To modify the rates, directly modify the variable via `$event->rates = ...`

});
engram-design commented 4 years ago

Added in 2.1.0. Thanks @AugustMiller