Пример #1
0
 /**
  * Apply discount to CartItem position. If new prices is equal old price - return old price.
  * @param Cart $cart
  * @param CartItem $item
  * @return int|float new price with discount
  */
 public function applyDiscount(Cart $cart, CartItem $item)
 {
     if (Mindy::app()->user->isGuest === false) {
         // Дарим скидку зарегистрированным пользователям
         return $item->getPrice() - 200;
     } else {
         return $item->getPrice();
     }
 }
Пример #2
0
 public function applyDiscount(ICartItem $object, $quantity = 1, $type = null, array $data = [])
 {
     $item = new CartItem(['quantity' => $quantity, 'type' => $type, 'data' => $data, 'object' => $object]);
     $item->applyDiscount($this, $this->getDiscounts());
     return $item->getPrice();
 }