src/Service/Cart/Cart.php line 66

Open in your IDE?
  1. <?php
  2. namespace App\Service\Cart;
  3. use App\Env;
  4. use App\DTO\AppDTO;
  5. use App\DTO\CartDTO;
  6. use App\Entity\Prod;
  7. use App\Model\ProdColor;
  8. use App\Service\Auth\Auth;
  9. use App\ValueObject\Money;
  10. use App\Entity\CartUnsaved;
  11. use App\Entity\Cart as EntityCart;
  12. use App\Repository\CartRepository;
  13. use App\Repository\ProdRepository;
  14. use App\Service\Discount\NumDiscount;
  15. use App\Service\Discount\SumDiscount;
  16. use App\Service\Discount\UserDiscount;
  17. use Doctrine\ORM\EntityManagerInterface;
  18. use App\Repository\CartUnsavedRepository;
  19. use Symfony\Component\Security\Core\Security;
  20. use Symfony\Component\HttpFoundation\RequestStack;
  21. use Symfony\Component\HttpFoundation\Session\Session;
  22. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  23. class Cart
  24. {
  25.     protected EntityManagerInterface $em;
  26.     protected AppDTO $app;
  27.     protected Auth $Auth;
  28.     protected SessionInterface $Session;
  29.     protected ProdColor $prodColor;
  30.     protected RequestStack $rs;
  31.     protected $cart;
  32.     protected $prods_limited = [];
  33.     protected $order_id;
  34.     protected NumDiscount $NumDiscount;
  35.     protected SumDiscount $SumDiscount;
  36.     protected UserDiscount $UserDiscount;
  37.     //Repository
  38.     protected ProdRepository $Prods;
  39.     protected CartUnsavedRepository $CartUnsaved;
  40.     protected CartRepository $Carts;
  41.     public function __construct(EntityManagerInterface $emAppDTO $appAuth $AuthNumDiscount $NumDiscountSumDiscount $SumDiscountUserDiscount $UserDiscountProdColor $prodColorRequestStack $rsSecurity $security)
  42.     {
  43.         $this->em $em;
  44.         $this->app $app;
  45.         $this->Auth $Auth;
  46.         $this->Auth->setUser($security->getUser());
  47.         $this->prodColor $prodColor;
  48.         $this->rs $rs;
  49.         $this->Session $rs->getSession();
  50.         $this->Prods $this->em->getRepository(Prod::class);
  51.         $this->CartUnsaved $this->em->getRepository(CartUnsaved::class);
  52.         $this->Carts $this->em->getRepository(EntityCart::class);
  53.         $this->NumDiscount $NumDiscount;
  54.         $this->SumDiscount $SumDiscount;
  55.         $this->UserDiscount $UserDiscount;
  56.         $this->cart $this->Session->get('cart');
  57.         
  58.         if (empty($this->cart)) {
  59.             $this->cart = [];
  60.         }
  61.         if (empty($this->cart)) {
  62.             $this->load_session();
  63.         }
  64.         $this->recount();
  65.         $this->flush();
  66.     }
  67.     public function getCart(): array
  68.     {
  69.         $deleted 0;
  70.         foreach ($this->cart as $k => $v) {
  71.             $prod $this->Prods->find($v['id']);
  72.             if ($prod == null) {
  73.                 $deleted 1;
  74.                 unset ($this->cart[$k]);
  75.             }
  76.         }
  77.         if ($deleted) {
  78.             $this->save_session();
  79.             $this->flush();
  80.         }
  81.         return $this->cart;
  82.     }
  83.     public function isFreeDelivery(float $free_delivery_min): bool
  84.     {
  85.         $freedelivery false;
  86.         if ($this->getAmount() >= $free_delivery_min && !$this->Auth->isOpt()) {
  87.             $freedelivery true;
  88.         }
  89.         return $freedelivery;
  90.     }
  91.     public function getDeliveryIndicatorData(float $free_delivery_min): array
  92.     {
  93.         $percent round($this->getAmount()/$free_delivery_min*100);
  94.         $percent 100 $percent 100 null;
  95.         $remainder $free_delivery_min $this->getAmount();
  96.         $remainder $remainder null;
  97.         $data = [
  98.             'freedelivery' => $this->isFreeDelivery($free_delivery_min),
  99.             'freedelivery_min' => $free_delivery_min,
  100.             'amount' => $this->getAmount(),
  101.             'remainder' => round($remainderEnv::price_precission()),
  102.             'percent' => $percent,
  103.         ];
  104.         return $data;
  105.     }
  106.     public function getFromOrder(int $order_id): array
  107.     {
  108.         $Prods $this->em->getRepository(Prod::class);
  109.         $cart $this->loadFromOrder2($order_id);
  110.         // $cart = $this->getCart();
  111.         if (empty($cart)) {
  112.             return [];
  113.         }
  114.         
  115.         foreach ($cart as $k => $v) {
  116.             $cart[$k]['prod'] = $Prods->find($v['id']);
  117.         }
  118.         
  119.         return $cart;
  120.     }
  121.     public function loadFromOrder(int $order_id)
  122.     {
  123.         $this->order_id $order_id;
  124.         /** @var \App\Entity\Cart[] $prods */
  125.         $prods $this->em->createQuery("SELECT c FROM App\Entity\Cart c WHERE c.order_id = ".$order_id)->getResult();
  126.                 
  127.         foreach($prods as $prod) {
  128.             $this->cart[$this->getCartId($prod->getProd()->getId(), 0)] = [
  129.                 'cid' => $prod->getId(),
  130.                 'id' => $prod->getProd()->getId(),
  131.                 'var' => $prod->getVar(),
  132.                 'num' => $prod->getNum(),
  133.                 'baseprice' => (new Money($prod->getPrice()))->getAmount(),
  134.                 'price' => 0,
  135.                 'skidka' => $prod->getSkidka(),
  136.                 'numdiscount' => $prod->getNumdiscount(),
  137.                 'userdiscount' => $prod->getUserdiscount(),
  138.             ];
  139.         }
  140.         $this->flush();
  141.     }
  142.     public function loadFromOrder2(int $order_id)
  143.     {
  144.         $cart = [];
  145.         $this->order_id $order_id;
  146.         /** @var \App\Entity\Cart[] $prods */
  147.         $prods $this->em->createQuery("SELECT c FROM App\Entity\Cart c WHERE c.order_id = ".$order_id)->getResult();
  148.                 
  149.         foreach($prods as $prod) {
  150.             if ($prod->getProd() == null) {
  151.                 continue;
  152.             }
  153.             $cart[$this->getCartId($prod->getProd()->getId(), 0)] = [
  154.                 'cid' => $prod->getId(),
  155.                 'id' => $prod->getProd()->getId(),
  156.                 'var' => $prod->getVar(),
  157.                 'num' => $prod->getNum(),
  158.                 'baseprice' => (new Money($prod->getPrice()))->getAmount(),
  159.                 'price' => (new Money($prod->getPrice()))->getAmount(),
  160.                 'skidka' => $prod->getSkidka(),
  161.                 'numdiscount' => $prod->getNumdiscount(),
  162.                 'userdiscount' => $prod->getUserdiscount(),
  163.             ];                       
  164.         }
  165.         $cart $this->recount($cart);
  166.         return $cart;
  167.     }
  168.     public function getCartId(int $prod_idint $var 0, array $chars = [], int $user_id 0) {
  169.         $id $prod_id."_".$var;
  170.             
  171.         if (!empty($chars)) {
  172.             ksort($chars);
  173.             $id .= "_".json_encode($chars);                
  174.         }
  175.             
  176.         if ($user_id) {
  177.             $id .= "_".$user_id;
  178.         }
  179.             
  180.         return md5($id);
  181.     }
  182.     public function addItem($id 0$var 0$num 1$price 0$skidka 0$numdiscount = [], $weight 0){
  183.         $cart_id $this->getCartId($id$var);
  184.             
  185.         if(isset($this->cart[$cart_id])){
  186.             $this->cart[$cart_id]['num'] += $num;
  187.             if($this->cart[$cart_id]['skidka'] == 0){
  188.                 $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  189.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  190.             }else{
  191.                 $this->cart[$cart_id]['numdiscount'] = 0;
  192.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  193.             }
  194.         }else{
  195. //            array_unshift($this->cart, array($cart_id => array('id' => intval($id), 'var' => intval($var), 'num' => intval($num), 'baseprice' => floatval($price), 'price' => floatval($price), 'skidka' => floatval($skidka), 'weight' => floatval($weight))));
  196.             $this->cart[$cart_id] = array('id' => intval($id), 'var' => intval($var), 'num' => intval($num), 'baseprice' => floatval($price), 'price' => floatval($price), 'skidka' => floatval($skidka), 'weight' => floatval($weight));
  197.     
  198.             if($this->cart[$cart_id]['skidka'] == 0){
  199.                 $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  200.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  201.             }else{
  202.                 $this->cart[$cart_id]['numdiscount'] = 0;
  203.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  204.             }
  205.         }
  206.         $this->recount();
  207.         $this->save_session();
  208.         $this->flush();
  209.     }
  210.     public function updateItem($cart_id ''$num 0$numdiscount = []){
  211.         if($num == 0){
  212.             $prod $this->cart[$cart_id]['id'];
  213.             $prodvar $this->cart[$cart_id]['var'];
  214.             unset($this->cart[$cart_id]);
  215.         }else{
  216.             $this->cart[$cart_id]['num'] = intval($num);
  217.             if($this->order_id == 0) {
  218.                 if($this->cart[$cart_id]['skidka'] == 0){
  219.                     $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  220.                     $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  221.                 }else{
  222.                     $this->cart[$cart_id]['numdiscount'] = 0;
  223.                     $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  224.                 }
  225.             } else {
  226.                 if($this->cart[$cart_id]['skidka'] == 0){
  227.                     $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  228.                     $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  229.                 }else{
  230.                     $this->cart[$cart_id]['numdiscount'] = 0;
  231.                     $this->cart[$cart_id]['userdiscount'] = 0;
  232.                 }
  233.             }
  234.                 
  235.             $this->recount();
  236.             $prod intval($this->cart[$cart_id]['id']);
  237.             $prodvar intval($this->cart[$cart_id]['var']);
  238.         }
  239.         $this->save_session();
  240.         $this->flush();
  241.     }
  242.     public function deleteItem(string $cart_id)
  243.     {
  244.         $prod $this->cart[$cart_id]['id'];
  245.         $prodvar $this->cart[$cart_id]['var'];
  246.         unset($this->cart[$cart_id]);
  247.         $this->recount();
  248.         $this->save_session();
  249.         $this->flush();
  250.     }
  251.     public function deleteAll()
  252.     {
  253.         $this->cart = [];
  254.         $this->delete_session();
  255.         $this->flush();
  256.     }    
  257.     public function cart_id($prod 0$var 0$chars = array(), $user_id 0)
  258.     {
  259.         $this->getCartId($prod$var$chars$user_id);        
  260.     }
  261.                 
  262.     public function getAmount(): float
  263.     {
  264.         $amount 0;
  265.         foreach($this->cart as $k => $v)
  266.             $amount += round($v['price'], Env::price_precission(), PHP_ROUND_HALF_UP) * $v['num'];
  267.             
  268.         return $amount;
  269.     }
  270.     public function getBaseAmount(): float 
  271.     {
  272.         $amount 0;
  273.         foreach($this->cart as $k => $v)
  274.             $amount += round($v['baseprice'], Env::price_precission(), PHP_ROUND_HALF_UP) * $v['num'];
  275.             
  276.         return $amount;
  277.     }
  278.     public function getAmountWithoutDiscount()
  279.     {
  280.         $amount 0;
  281.             
  282.         foreach ($this->cart as $k => $v) {
  283.             $amount += round($v['baseprice'], Env::price_precission(), PHP_ROUND_HALF_UP) * $v['num'];
  284.         }
  285.             
  286.         return $amount;
  287.     }
  288.     public function getAmountDelivery()
  289.     {
  290.         return (float)@$_SESSION['_sf2_attributes']['checkout']['delivery_cost'];
  291.     }
  292.     public function getAmountWithDelivery()
  293.     {
  294.         if (($this->getAmount() < $this->app->sett->get('free_delivery_amount')) || ($this->Auth->isOpt())) {
  295.             return $this->getAmount() + $this->getAmountDelivery();
  296.         } else {
  297.             return $this->getAmount();
  298.         }
  299.     }
  300.     public function userLogin($user_id)
  301.     {
  302.         $this->load_session($user_id);
  303.         $discount $this->UserDiscount->getValue();
  304.         if ($discount >= 0) {
  305.             foreach ($this->cart as $k => $v) {
  306.                 $prod $this->Prods->find((int)$v['id']);
  307.                 $numdiscount $prod->getNumdiscount();
  308.         
  309.                 if($v['var'] == 2){
  310.                     $numdiscount $prod->getNumdiscount2();
  311.                 }
  312.     
  313.                 if($v['var'] == 3){
  314.                     $numdiscount $prod->getNumdiscount3();
  315.                 }
  316.                 
  317.                 $this->cart[$k]['userdiscount'] = $discount;
  318.                 if($this->Auth->isOpt()) {
  319.                     $this->cart[$k]['numdiscount'] = $this->NumDiscount->getDiscount((int) $this->cart[$k]['num'], $numdiscount);
  320.                 }
  321.             }
  322.         }
  323.         $this->recount();
  324.         $this->save_session();
  325.         $this->em->createQuery("DELETE App\Entity\CartUnsaved c WHERE c.user_id = '".$this->Auth->guestId()."'")->getResult();
  326.         $this->flush();
  327.     }
  328.         
  329.     public function setUserDiscount($discount){
  330.         if($discount){
  331.             foreach($this->cart as $k => $v){
  332.                 $this->cart[$k]['userdiscount'] = $discount;
  333.             }
  334.         }
  335.         $this->recount();
  336.         $this->save_session();
  337.         $this->flush();
  338.     }
  339.         
  340.     protected function recount($cart = [])
  341.     {
  342.         if (!empty($cart)) {
  343.             foreach ($cart as $k => $v) {
  344.                 if (!isset($v['userdiscount'])) $cart[$k]['userdiscount'] = 0;
  345.                 if (!isset($v['numdiscount'])) $cart[$k]['numdiscount'] = 0;
  346.                 if (!isset($v['skidka'])) $cart[$k]['skidka'] = 0;                
  347.                 
  348.                 $cart[$k]['baseprice'] = (new Money($v['baseprice']))->getAmount();
  349.                 if ($v['skidka']) {
  350.                     $cart[$k]['price'] = (new Money(($v['baseprice']) * (100 $v['skidka']) / 100))->getAmount();
  351.                 } else {
  352.                     $cart[$k]['price'] = (new Money((($v['baseprice']) * (100 $v['userdiscount']) * (100 $v['numdiscount']) / 100 100)))->getAmount();
  353.                 }                
  354.             }
  355.             return $cart;
  356.         }
  357.         foreach ($this->cart as $k => $v) {
  358.             if (!isset($v['userdiscount'])) $this->cart[$k]['userdiscount'] = 0;
  359.             if (!isset($v['numdiscount'])) $this->cart[$k]['numdiscount'] = 0;
  360.             if (!isset($v['skidka'])) $this->cart[$k]['skidka'] = 0;
  361.             
  362.             if ($this->order_id == 0) {
  363.                 $prod $this->Prods->find((int) $v['id']);
  364.                 if ($prod) {
  365.                     $skidka $prod->getSkidka();
  366.             
  367.                     if ($v['var'] == 2) {
  368.                         $skidka $prod->getSkidka2();
  369.                     }
  370.     
  371.                     if ($v['var'] == 3) {
  372.                         $skidka $prod->getSkidka3();
  373.                     }
  374.                 
  375.                     $this->cart[$k]['skidka'] = $skidka;
  376.                 }                
  377.             }
  378.             
  379.             $this->cart[$k]['baseprice'] = (new Money($v['baseprice']))->getAmount();
  380.             if ($v['skidka']) {
  381.                 $this->cart[$k]['price'] = (new Money(($v['baseprice']) * (100 $v['skidka']) / 100))->getAmount();
  382.             } else {
  383.                 $this->cart[$k]['price'] = (new Money((($v['baseprice']) * (100 $v['userdiscount']) * (100 $v['numdiscount']) / 100 100)))->getAmount();
  384.             }                
  385.         }    
  386.     }
  387.         
  388.     public function getProdNum()
  389.     {
  390.         return (empty($this->cart)) ? count($this->cart);
  391.     }
  392.     public function getPackNum()
  393.     {
  394.         $num 0;
  395.         foreach($this->cart as $k => $v)
  396.             $num += $v['num'];
  397.         return $num;
  398.     }
  399.     public function getWeight()
  400.     {
  401.         $weight 0;
  402.         foreach($this->cart as $k => $v)
  403.         {
  404.             $n $v['num'] ?? 0;
  405.             $w $v['weight'] ?? 0;
  406.             $weight += $n $w;
  407.         }
  408.             
  409.         return round($weight 10002);
  410.     }
  411.     protected function load_session()
  412.     {
  413.         $uid $this->Auth->getUserId() ? $this->Auth->getUserId(): $this->Auth->guestId();
  414.         $unsaved_cart $this->CartUnsaved->findOneBy(["user_id" => $uid]);
  415.         if ($unsaved_cart) {
  416.             $cart json_decode($unsaved_cart->getCart(), true);    
  417.             foreach ($cart as $k => $v) {
  418.                 $prod $this->Prods->find((int) $v['id']);
  419.                 
  420.                 $v['baseprice'] = $prod->getPrice();
  421.                 if ($v['var'] == 2) { 
  422.                     $v['baseprice'] = $prod->getPrice2();
  423.                 } elseif ($v['var'] == 3) {
  424.                     $v['baseprice'] = $prod->getPrice3();
  425.                 }
  426.                 
  427.                 if (!isset($this->cart[$k])) {
  428.                     $this->cart[$k] = $v;
  429.                 }                
  430.             }
  431.         }
  432.         $this->flush();
  433.     }
  434.     private function flush()
  435.     {
  436.         $this->Session->set('cart'$this->cart);
  437.     }
  438.     public function save_session()
  439.     {
  440.         $uid $this->Auth->getUserId() ? $this->Auth->getUserId(): $this->Auth->guestId();
  441.         $cart json_encode($this->cartJSON_UNESCAPED_UNICODE);
  442.         $unsaved_cart $this->CartUnsaved->findOneBy(["user_id" => $uid]);
  443.         if ($unsaved_cart) {
  444.             $unsaved_cart->setCart($cart);
  445.         } else {
  446.             $unsaved_cart = new CartUnsaved();
  447.             $unsaved_cart->setUserId($uid);
  448.             $unsaved_cart->setCart($cart);
  449.             $this->em->persist($unsaved_cart);
  450.         }
  451.         $this->em->flush();
  452.     }
  453.     public function delete_session()
  454.     {
  455.         $uid $this->Auth->getUserId() ? $this->Auth->getUserId(): $this->Auth->guestId();
  456.         $unsaved_cart $this->CartUnsaved->findOneBy(["user_id" => $uid]);
  457.         if ($unsaved_cart) {
  458.             $this->em->remove($unsaved_cart);
  459.             $this->em->flush();
  460.         }
  461.     }
  462.         
  463.     public function saveCart(int $order_id) {
  464.         // if ($this->Auth->isAuth() || !$this->Auth->isOpt()) {
  465.         //     $userdiscount = $this->UserDiscount->calculateUserDiscount(new Model_Discount, new Model_Order(), new Model_User(), Auth::userid());
  466.         // } else {
  467.         //     $userdiscount = 0;
  468.         // }
  469.         
  470.         foreach ($this->cart as $k => $v) {
  471.             $prod $this->Prods->find((int) $v['id']);
  472.             $price $prod->getPrice();
  473.             $num $prod->getNum();
  474.             
  475.             if ($v['var'] == 2) {
  476.                 $price $prod->getPrice2();
  477.             } elseif($v['var'] == 3) {
  478.                 $price $prod->getPrice3();
  479.             }
  480.             if($v['skidka']){
  481.                 $v['numdiscount'] = 0;
  482.             }
  483.                 
  484.             if ($v['skidka']) {
  485.                 $v['numdiscount'] = 0;
  486.             }
  487.                 
  488.             $Cart = new EntityCart();
  489.             $Cart->setOrderId($order_id);
  490.             $Cart->setProd($prod);
  491.             $Cart->setVar((int) $v['var']);
  492.             $Cart->setNum((int) $v['num']);
  493.             $Cart->setPrice(round($priceEnv::price_precission(), PHP_ROUND_HALF_UP));
  494.             $Cart->setSkidka((int) $v['skidka']);
  495.             $Cart->setNumdiscount((int) $v['numdiscount']);
  496.             $Cart->setUserdiscount((int) $v['userdiscount']);
  497.             //$Cart->setSumdiscount((int) $v['sumdiscount']);
  498.             $this->em->persist($Cart);                
  499.         }
  500.         $this->em->flush();
  501.         $this->flush();
  502.     }
  503.     //Удалить товары с нулевыми остатками из цветов
  504.     public function deleteNullFromColors()
  505.     {
  506.         foreach ($this->cart as $k => $v) {
  507.             $prod $this->Prods->find((int) $v['id']);
  508.             $prod_num $prod->getNum();
  509.             if ($v['var'] == 2$prod_num $prod->getNum2();
  510.             if ($v['var'] == 3$prod_num $prod->getNum3();
  511.             if ($prod->getId() == $v['id'] && $prod_num && $prod_num $v['num']) {
  512.                 $this->prods_limited[] = $v['id'];
  513.                 $this->cart[$k]['num'] = $prod_num;
  514.             }
  515.             if ($prod->getId() == $v['id'] && $prod_num <= 0) {
  516.                 $this->prodColor->deleteColor($prod->getId());
  517.             }
  518.         }
  519.         $this->flush();
  520.     }
  521.     public function save_cart_admin($order_id) {
  522.         $this->em->createQuery("DELETE App\Entity\Cart c WHERE c.order = ".$order_id)->getResult();
  523.         
  524.         foreach ($this->cart as $v) {
  525.             $prod $this->Prods->find((int) $v['id']);
  526.             if ($v['skidka']) {
  527.                 $v['numdiscount'] = 0;
  528.             }
  529.             $Cart = new EntityCart();
  530.             $Cart->setOrderId($order_id);
  531.             $Cart->setProd($prod);
  532.             $Cart->setVar((int) $v['var']);
  533.             $Cart->setNum((int) $v['num']);
  534.             $Cart->setPrice(round($v['baseprice'], Env::price_precission(), PHP_ROUND_HALF_UP));
  535.             $Cart->setSkidka((int) $v['skidka']);
  536.             $Cart->setNumdiscount((int) $v['numdiscount']);
  537.             $Cart->setUserdiscount((int) $v['userdiscount']);
  538.             $Cart->setSumdiscount((int) $v['sumdiscount']);
  539.             $this->em->persist($Cart);
  540.         }
  541.         $this->em->flush();
  542.         $this->flush();
  543.     }
  544.     
  545.     public function prods_limited() {
  546.         foreach ($this->cart as $k => $v) {
  547.             $prod $this->Prods->find((int) $v['id']);
  548.             $prod_num $prod->getNum();
  549.             if ($v['var'] == 2$prod_num $prod->getNum2();
  550.             if ($v['var'] == 3$prod_num $prod->getNum3();
  551.         
  552.             if ($prod->getId() == $v['id'] && $prod_num && $prod_num $v['num']) {
  553.                 $this->prods_limited[] = $v['id'];
  554.                 $this->cart[$k]['num'] = $prod_num;
  555.             }
  556.             if ($prod->getId() == $v['id'] && $prod_num <= 0) {
  557.                 unset($this->cart[$k]);
  558.             }
  559.         }
  560.         $this->flush();
  561.         $this->save_session();
  562.         if (!empty($this->prods_limited)) return true;
  563.         else return false;
  564.     }
  565.     public function getProdsLimited (): array
  566.     {
  567.         return $this->prods_limited;
  568.     }
  569. }