Sitback / commerce_auspost

Drupal 8 fork of the Drupal 'commerce_auspost' module
https://www.drupal.org/sandbox/torpy/2876488
2 stars 1 forks source link

ShippingRate requires an array. #4

Open RaphaelBriskie opened 3 years ago

RaphaelBriskie commented 3 years ago

The ShippingRate object requires an array when it is created.

src/Plugin/Commerce/ShippingMethod/AusPost.php - Line 494, function calculateRates()

Should be:

$rates[] = new ShippingRate(
  [
    'shipping_method_id' => $serviceId,
    'service' => $service,
    'amount' => $postagePrice,
  ]
);
RaphaelBriskie commented 3 years ago

Additional to this, the variable $serviceId should not be used here, it should be the method id:

$rates[] = new ShippingRate(
  [
    'shipping_method_id' => $shipment->getShippingMethodId(),
    'service' => $service,
    'amount' => $postagePrice,
  ]
);
RaphaelBriskie commented 3 years ago

Actually, $shipment->getShippingMethodId() is no longer working; however $this->parentEntity->id() does.