/** * @param $data */ protected function addService($data) { $item = $this->cart_model->getById($data['parent_id']); if (!$item) { $this->errors = _w('Error'); return; } unset($item['id']); $item['parent_id'] = $data['parent_id']; $item['type'] = 'service'; $item['service_id'] = $data['service_id']; if (isset($data['service_variant_id'])) { $item['service_variant_id'] = $data['service_variant_id']; } else { $service_model = new shopServiceModel(); $service = $service_model->getById($data['service_id']); $item['service_variant_id'] = $service['variant_id']; } $id = $this->cart->addItem($item); $total = $this->cart->total(); $discount = $this->cart->discount(); $this->response['id'] = $id; $this->response['total'] = $this->currencyFormat($total); $this->response['count'] = $this->cart->count(); $this->response['discount'] = $this->currencyFormat($discount); $item_total = $this->cart->getItemTotal($data['parent_id']); $this->response['item_total'] = $this->currencyFormat($item_total); if (shopAffiliate::isEnabled()) { $add_affiliate_bonus = shopAffiliate::calculateBonus(array('total' => $total, 'discount' => $discount, 'items' => $this->cart->items(false))); $this->response['add_affiliate_bonus'] = sprintf(_w("This order will add +%s points to your affiliate bonus."), round($add_affiliate_bonus, 2)); } }