BUG V1.3.0 Attempted to call an undefined method named "getPackageTypeId"
Closed this issue · 4 comments
Attempted to call an undefined method named "getPackageTypeId" of class "MyParcelNL\Sdk\src\Adapter\DeliveryOptions\DeliveryOptionsV3Adapter".
Did you mean to call "getPackageType"?
in modules/myparcelnl/src/Label/LabelOptionsResolver.php (line 97)
This one needs to get fixed fast. Our customers are once again stuck
Quick and dirty workaround:
File LabelOptionsResolver.php
function getPackageType()
from :
private function getPackageType(Order $order, ?AbstractDeliveryOptionsAdapter $deliveryOptions): int
{
$packageType = $deliveryOptions ? $deliveryOptions->getPackageType() : null;
if(!empty($packageType)) {
$packageType = $this->getPackageTypeId($packageType);
}
return $packageType ?? (new PackageTypeCalculator())->getOrderPackageType($order);
}
To:
private function getPackageType(Order $order, ?AbstractDeliveryOptionsAdapter $deliveryOptions): int
{
$packageType = $deliveryOptions ? $deliveryOptions->getPackageType() : null;
if(!empty($packageType)) {
$packageType = $this->getPackageTypeId($packageType);
}
return $packageType ?? (new PackageTypeCalculator())->getOrderPackageType($order);
}
And add this function:
/**
* @return int
*/
public function getPackageTypeId($packageType): ?int
{
if ($packageType === null) {
return null;
}
return AbstractConsignment::PACKAGE_TYPES_NAMES_IDS_MAP[$packageType];
}
And add this line:
use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment;
On to the next bug...are you kidding me ...
@Multipage: we suspect this errors is thrown because you are trying to generate a label for a shipping method that is not coupled to our plugin. In the next release (v1.4.0) a shipping method does not have to be coupled to our plugin anymore. This version will probably be released in the coming days.
Since we are not sure what you are trying to do though and under which circumstances, we cannot guarantee that this version will fix your problem.
Fixed in latest release.