protected function getShippingCostsCollection(ShippingMethodInterface $shippingMethod) { $collection = new ArrayCollection(); $cost = new ShippingMethodCost(); $cost->setRangeFrom(0); $cost->setRangeTo(100000); $price = new Price(); $price->setCurrency('EUR'); $price->setNetAmount(10); $price->setTaxAmount(2.3); $price->setTaxRate(23); $price->setGrossAmount(12.3); $cost->setCost($price); $cost->setShippingMethod($shippingMethod); $collection->add($cost); return $collection; }
private function prepareCostsCollection(array $values, ShippingMethod $shippingMethod) { if (!isset($values['ranges'])) { throw new \InvalidArgumentException('Wrong arguments passed. Ranges are missing in the "costs" array.'); } $collection = new ArrayCollection(); foreach ($values['ranges'] as $value) { $cost = new Price(); $cost->setGrossAmount($value['price']); $range = new ShippingMethodCost(); $range->setCost($cost); $range->setRangeFrom($value['min']); $range->setRangeTo($value['max']); $range->setShippingMethod($shippingMethod); $collection->add($range); } return $collection; }