Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure: A shipment cannot have a KGS/IN or LBS/CM or OZS/CM as its unit of measurements (110548) #365

Open
manish28112022 opened this issue Feb 10, 2023 · 1 comment

Comments

@manish28112022
Copy link

manish28112022 commented Feb 10, 2023

Facing this issue in "Rate Class" API

        $from = $request->from_zip;
        $to = $request->to_zip;

        $accessKey = env("UPS_ACCESS_KEY");
        $userId = env("UPS_USER_ID");
        $password = env("UPS_PASSWORD");

        $rate = new Rate($accessKey,$userId,$password);
        // dd($rate);
        
        try {
            $shipment = new Shipment();
        
            $shipperAddress = $shipment->getShipper()->getAddress();
            $shipperAddress->setPostalCode($from);
        
            $address = new Address();
            $address->setPostalCode($from);
            $shipFrom = new ShipFrom();
            $shipFrom->setAddress($address);
        
            $shipment->setShipFrom($shipFrom);
        
            $shipTo = $shipment->getShipTo();
            $shipTo->setCompanyName('Test Ship To');
            $shipToAddress = $shipTo->getAddress();
            $shipToAddress->setPostalCode($to);
        
            $package = new Package();
            $package->getPackagingType()->setCode(PackagingType::PT_PACKAGE);
            $package->getPackageWeight()->setWeight(1);
            
            // if you need this (depends of the shipper country)
            $weightUnit = new UnitOfMeasurement;
            $weightUnit->setCode(UnitOfMeasurement::UOM_KGS);
            $package->getPackageWeight()->setUnitOfMeasurement($weightUnit);
        
            $dimensions = new Dimensions();
            $dimensions->setHeight(5);
            $dimensions->setWidth(5);
            $dimensions->setLength(5);
        
            $unit = new UnitOfMeasurement;
            $unit->setCode(UnitOfMeasurement::UOM_IN);
        
            $dimensions->setUnitOfMeasurement($unit);
            $package->setDimensions($dimensions);
        
            $shipment->addPackage($package);
        
            var_dump($rate->getRate($shipment));
        } catch (Exception $e) {
            var_dump($e);
        }
@kenrutten
Copy link

Change UOM_KGS to UOM_LBS, that should fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants