Esempio n. 1
0
 /** Discounts by amount of money previously spent by this customer. */
 protected static function byCustomerTotal($order, $contact, $apply)
 {
     if (!$contact || !$contact->getId()) {
         return 0;
     }
     $cm = new shopCustomerModel();
     $customer = $cm->getById($contact->getId());
     if ($customer && $customer['total_spent'] > 0) {
         $dbsm = new shopDiscountBySumModel();
         return max(0.0, min(100.0, (double) $dbsm->getDiscount('customer_total', $customer['total_spent']))) * $order['total'] / 100.0;
     }
     return 0.0;
 }