local/modules/AdminOrderCreation/Service/PostageService.php line 31
<?phpnamespace AdminOrderCreation\Service;use Propel\Runtime\ActiveQuery\Criteria;use Symfony\Component\DependencyInjection\ContainerInterface;use Thelia\Model\Base\ModuleQuery;use Thelia\TaxEngine\Calculator;use Thelia\Model\TaxRuleQuery;use Thelia\Model\Country;/*** Class PostageService** @package AdminOrderCreation\Service* @author François Carfantan <f.carfantan@orange.fr>*/class PostageService{protected $container;/*** PostageService constructor.* @param ContainerInterface $container We need the container because we use a service from another module* which is not mandatory, and using its service without it being installed will crash*/public function __construct(ContainerInterface $container,){$this->container = $container;}function getPostageAmount(int $deliveryModuleId,float $weight=0.00,Country $country):float{$areaId = $country->getAreaId();$deliveryModule = ModuleQuery::create()->findOneById($deliveryModuleId);$moduleInstance = $deliveryModule->getModuleInstance($this->container);if (method_exists($moduleInstance::class,'getPostageAmount')) {return $moduleInstance::class::getPostageAmount($areaId,$weight);} else {return 0.00;}}public function getPostageWithTaxRuleId(int $taxRuleId,Country $country, string $untaxedPrice):string{$calc = new Calculator();$rule = TaxRuleQuery::create()->findOneById($taxRuleId);$calc->loadTaxRuleWithoutProduct($rule,$country);return (float) $untaxedPrice + $calc->getTaxAmountFromUntaxedPrice($untaxedPrice);}}