/**
  * Prepare data for email.
  *
  * @param AB_CustomerAppointment $ca
  * @return array
  */
 private static function _prepareData(AB_CustomerAppointment $ca)
 {
     $appointment = new AB_Appointment();
     $appointment->load($ca->get('appointment_id'));
     $customer = new AB_Customer();
     $customer->load($ca->get('customer_id'));
     $staff = new AB_Staff();
     $staff->load($appointment->get('staff_id'));
     $service = new AB_Service();
     $service->load($appointment->get('service_id'));
     $staff_service = new AB_StaffService();
     $staff_service->loadBy(array('staff_id' => $staff->get('id'), 'service_id' => $service->get('id')));
     $price = $staff_service->get('price');
     if ($ca->get('coupon_discount') or $ca->get('coupon_deduction')) {
         $coupon = new AB_Coupon();
         $coupon->set('discount', $ca->get('coupon_discount'));
         $coupon->set('deduction', $ca->get('coupon_deduction'));
         $price = $coupon->apply($price);
     }
     $codes = new AB_NotificationCodes();
     $codes->set('appointment_datetime', $appointment->get('start_date'));
     $codes->set('appointment_token', $ca->get('token'));
     $codes->set('category_name', $service->getCategoryName());
     $codes->set('client_name', $customer->get('name'));
     $codes->set('client_phone', $customer->get('phone'));
     $codes->set('client_email', $customer->get('email'));
     $codes->set('custom_fields', $ca->getFormattedCustomFields('text'));
     $codes->set('custom_fields_2c', $ca->getFormattedCustomFields('html'));
     $codes->set('number_of_persons', $ca->get('number_of_persons'));
     $codes->set('service_name', $service->getTitle());
     $codes->set('service_price', $price);
     $codes->set('staff_name', $staff->get('full_name'));
     $codes->set('staff_email', $staff->get('email'));
     $codes->set('staff_phone', $staff->get('phone'));
     $codes->set('staff_photo', $staff->get('avatar_url'));
     return array($codes, $staff, $appointment, $customer);
 }
 /**
  * Get item data for cart.
  *
  * @param $other_data
  * @param $cart_item
  *
  * @return array
  */
 function getItemData($other_data, $cart_item)
 {
     if (isset($cart_item['bookly'])) {
         $info_name = get_option('ab_woocommerce_cart_info_name');
         $info_value = get_option('ab_woocommerce_cart_info_value');
         $staff = new AB_Staff();
         $staff->load($cart_item['bookly']['staff_ids'][0]);
         $service = new AB_Service();
         $service->load($cart_item['bookly']['service_id']);
         $info_value = strtr($info_value, array('[[APPOINTMENT_TIME]]' => AB_DateTimeUtils::formatTime($cart_item['bookly']['appointment_datetime']), '[[APPOINTMENT_DATE]]' => AB_DateTimeUtils::formatDate($cart_item['bookly']['appointment_datetime']), '[[CATEGORY_NAME]]' => $service->getCategoryName(), '[[SERVICE_NAME]]' => $service->getTitle(), '[[SERVICE_PRICE]]' => $service->get('price'), '[[STAFF_NAME]]' => $staff->get('full_name')));
         $other_data[] = array('name' => $info_name, 'value' => $info_value);
     }
     return $other_data;
 }