Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

OrderProductReductionCatalogSolver.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Order;
  3. use Lc\CaracoleBundle\Model\Order\OrderProductReductionCatalogInterface;
  4. class OrderProductReductionCatalogSolver
  5. {
  6. // getSummaryOrderProductReductionCatalog
  7. public function getSummary(OrderProductReductionCatalogInterface $orderProductReductionCatalog): string
  8. {
  9. $text = '';
  10. if ($orderProductReductionCatalog->getUnit() == 'amount') {
  11. $text .= '- ' . $orderProductReductionCatalog->getValue() . '&nbsp;€';
  12. }
  13. if ($orderProductReductionCatalog->getUnit() == 'percent') {
  14. $text .= '- ' . $orderProductReductionCatalog->getValue() . '&nbsp;%';
  15. }
  16. return $text;
  17. }
  18. // compareOrderProductReductionCatalog
  19. public function compare(
  20. OrderProductReductionCatalogInterface $orderProductReductionCatalog = null,
  21. OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare = null
  22. ): bool {
  23. if(is_null($orderProductReductionCatalog) && is_null($orderProductReductionCatalogCompare)) {
  24. return true;
  25. }
  26. if(is_null($orderProductReductionCatalog) || is_null($orderProductReductionCatalogCompare)) {
  27. return false;
  28. }
  29. return $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit()
  30. && (string)$orderProductReductionCatalog->getValue(
  31. ) == (string)$orderProductReductionCatalogCompare->getValue()
  32. && $orderProductReductionCatalog->getBehaviorTaxRate(
  33. ) == $orderProductReductionCatalogCompare->getBehaviorTaxRate();
  34. }
  35. }