Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ReductionCartStore.php 1.9KB

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  4. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  5. use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
  6. use Lc\CaracoleBundle\Repository\AbstractStore;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class ReductionCartStore extends AbstractStore
  9. {
  10. use MerchantStoreTrait;
  11. protected ReductionCartRepositoryQuery $query;
  12. protected ReductionCartSolver $reductionCartSolver;
  13. protected PriceSolver $priceSolver;
  14. public function __construct(
  15. ReductionCartRepositoryQuery $query,
  16. ReductionCartSolver $reductionCartSolver,
  17. PriceSolver $priceSolver
  18. ) {
  19. $this->query = $query;
  20. $this->reductionCartSolver = $reductionCartSolver;
  21. $this->priceSolver = $priceSolver;
  22. }
  23. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  24. {
  25. $query->orderBy('id');
  26. return $query;
  27. }
  28. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  29. {
  30. $this->addFilterByMerchantRequired($query);
  31. $query->filterIsOnlineAndOffline();
  32. return $query;
  33. }
  34. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  35. {
  36. return $query;
  37. }
  38. // getReductionCartByCode
  39. public function getByCode(string $code, $query = null)
  40. {
  41. $query = $this->createDefaultQuery($query);
  42. $query->filterByCode($code);
  43. $reductionCarts = $query->find();
  44. $findReductionCart = null;
  45. foreach ($reductionCarts as $reductionCart) {
  46. if ($reductionCart && in_array($code, $reductionCart->getCodes())) {
  47. $findReductionCart = $reductionCart;
  48. }
  49. }
  50. return $findReductionCart;
  51. }
  52. }