|
- <?php
-
- namespace Lc\CaracoleBundle\Solver\Reduction;
-
- use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
- use Lc\CaracoleBundle\Model\Reduction\ReductionCartModel;
- use Lc\SovBundle\Model\User\UserInterface;
-
- class ReductionCartSolver
- {
-
- // isReductionCartMatchWithUser
- public function matchWithUser(ReductionCartInterface $reductionCart, UserInterface $user)
- {
- $conditionUser = false;
-
- if ($user) {
- if ($reductionCart->getUsers()->isEmpty() || $reductionCart->getUsers()->contains($user)) {
- $conditionUser = true;
- }
- }
-
- return $conditionUser;
- }
-
- // isReductionCartMatchWithGroupUser
- public function matchWithGroupUser(ReductionCartInterface $reductionCart, UserInterface $user)
- {
- $conditionGroupUser = false;
-
- if ($user) {
- if ($user->getGroupUsers() && count($user->getGroupUsers()) > 0) {
- foreach ($user->getGroupUsers() as $groupUser) {
- if ($reductionCart->getGroupUsers()->isEmpty() || $reductionCart->getGroupUsers()->contains($groupUser)) {
- $conditionGroupUser = true;
- }
- }
- } else {
- if ($reductionCart->getGroupUsers()->isEmpty()) {
- $conditionGroupUser = true;
- }
- }
- }
-
- return $conditionGroupUser;
- }
-
-
- public static function getAppliedToChoices()
- {
- return [
- // ReductionCartModel::APPLIED_TO_DELIVERY,
- ReductionCartModel::APPLIED_TO_ORDER_PRODUCTS,
- ];
- }
-
- }
|