public static function prepareReplaceText($order, $orderId, $common, $bas)
{
$pC = PhocacartUtils::getComponentParameters();
$config = Factory::getConfig();
$price = new PhocacartPrice();
$price->setCurrency($common->currency_code, $orderId);
$totalBrutto = $order->getItemTotal($orderId, 0, 'brutto');
$download_guest_access = $pC->get('download_guest_access', 0);
$r = array();
$r['ordertoken'] = '';
if ($common->user_id > 0) {
// Standard User get standard download page and order page
$r['orderlink'] = PhocacartPath::getRightPathLink(PhocacartRoute::getOrdersRoute());
$r['downloadlink'] = PhocacartPath::getRightPathLink(PhocacartRoute::getDownloadRoute());
// Possible variables in email
if (isset($common->order_token) && $common->order_token != '') {
$r['orderlinktoken'] = PhocacartPath::getRightPathLink(PhocacartRoute::getOrdersRoute() . '&o=' . $common->order_token);
$r['ordertoken'] = $common->order_token;
}
} else {
// Guests
if (isset($common->order_token) && $common->order_token != '') {
$r['orderlinktoken'] = PhocacartPath::getRightPathLink(PhocacartRoute::getOrdersRoute() . '&o=' . $common->order_token);
$r['ordertoken'] = $common->order_token;
$r['orderlink'] = $r['orderlinktoken'];
}
$products = $order->getItemProducts($orderId);
$downloadO = '';
if (!empty($products) && isset($common->order_token) && $common->order_token != '' && $download_guest_access > 0) {
$downloadO = '<p> </p><h4>' . Text::_('COM_PHOCACART_DOWNLOAD_LINKS') . '</h4>';
foreach ($products as $k => $v) {
if (!empty($v->downloads)) {
$downloadO .= '<div><strong>' . $v->title . '</strong></div>';
foreach ($v->downloads as $k2 => $v2) {
// Main Product Download File
if (isset($v2->published) && $v2->published == 1 && isset($v2->download_file) && $v2->download_file != '' && isset($v2->download_folder) && $v2->download_folder != '' && isset($v2->download_token) && $v2->download_token != '') {
$title = str_replace($v2->download_folder, '', $v2->download_file);
$title = str_replace('/', '', $title);
$downloadLink = PhocacartPath::getRightPathLink(PhocacartRoute::getDownloadRoute() . '&o=' . $common->order_token . '&d=' . $v2->download_token);
$downloadO .= '<div>' . Text::_('COM_PHOCACART_DOWNLOAD') . ': <a href="' . $downloadLink . '">' . $title . '</a></div>';
$downloadO .= '<div><small>' . Text::_('COM_PHOCACART_DOWNLOAD_LINK') . ': <a href="' . $downloadLink . '">' . $downloadLink . '</a></small><hr></div>';
}
}
}
// Product Attribute Option Download File
if (!empty($v->attributes)) {
foreach ($v->attributes as $k2 => $v2) {
if (isset($v2->download_published) && $v2->download_published == 1 && isset($v2->download_file) && $v2->download_file != '' && isset($v2->download_folder) && $v2->download_folder != '') {
$title = str_replace($v2->download_folder, '', $v2->download_file);
$title = str_replace('/', '', $title);
$downloadO .= '<div><strong>' . $v->title . '(' . $v2->attribute_title . ': ' . $v2->option_title . ')</strong></div>';
$downloadLink = PhocacartPath::getRightPathLink(PhocacartRoute::getDownloadRoute() . '&o=' . $common->order_token . '&d=' . $v2->download_token);
$downloadO .= '<div>' . Text::_('COM_PHOCACART_DOWNLOAD') . ': <a href="' . $downloadLink . '">' . $title . '</a></div>';
$downloadO .= '<div><small>' . Text::_('COM_PHOCACART_DOWNLOAD_LINK') . ': <a href="' . $downloadLink . '">' . $downloadLink . '</a></small><hr></div>';
}
}
}
}
$downloadO .= '<p> </p>';
}
$r['downloadlink'] = $downloadO;
}
// --- name and email as additional info here, all other user information can be accessed through: PhocacartText::completeTextFormFields ... b_name_first, b_name_middle
$r['name'] = '';
if (isset($bas['b']['name_first']) && isset($bas['b']['name_last'])) {
$r['name'] = PhocacartUser::buildName($bas['b']['name_first'], $bas['b']['name_last']);
}
$r['email'] = '';
if (isset($bas['b']['email'])) {
$r['email'] = $bas['b']['email'];
}
if ($r['email'] == '' && isset($bas['s']['email'])) {
$r['email'] = $bas['s']['email'];
}
// ---
$r['trackingnumber'] = PhocacartOrderView::getTrackingNumber($common);
$r['trackinglink'] = PhocacartOrderView::getTrackingLink($common);
$r['trackingdescription'] = PhocacartOrderView::getTrackingDescription($common);
$r['shippingtitle'] = PhocacartOrderView::getShippingTitle($common);
$r['shippingdescriptioninfo'] = PhocacartOrderView::getShippingDescriptionInfo($common);
$r['dateshipped'] = PhocacartOrderView::getDateShipped($common);
$r['customercomment'] = $common->comment;
$r['currencycode'] = $common->currency_code;
$r['websitename'] = $config->get('sitename');
$r['websiteurl'] = Uri::root();
$r['orderid'] = $orderId;
$r['ordernumber'] = PhocacartOrder::getOrderNumber($orderId, $common->date, $common->order_number);
$r['invoicenumber'] = PhocacartOrder::getInvoiceNumber($orderId, $common->date, $common->invoice_number);
$r['receiptnumber'] = PhocacartOrder::getReceiptNumber($orderId, $common->date, $common->receipt_number);
$r['queuenumber'] = PhocacartOrder::getQueueNumber($orderId, $common->date, $common->queue_number);
$r['paymentreferencenumber'] = PhocacartOrder::getPaymentReferenceNumber($orderId, $common->date, $common->invoice_prn);
$r['invoiceduedate'] = PhocacartOrder::getInvoiceDueDate($orderId, $common->date, $common->invoice_due_date, 'Y-m-d');
//$r['invoiceduedateyear'] = PhocacartOrder::getInvoiceDueDate($orderId, $common->date, $common->invoice_due_date, 'Y');
//$r['invoiceduedatemonth'] = PhocacartOrder::getInvoiceDueDate($orderId, $common->date, $common->invoice_due_date, 'm');
//$r['invoiceduedateday'] = PhocacartOrder::getInvoiceDueDate($orderId, $common->date, $common->invoice_due_date, 'd');
$dateIdd = PhocacartDate::splitDate($r['invoiceduedate']);
$r['invoicedueyear'] = $dateIdd['year'];
$r['invoiceduemonth'] = $dateIdd['month'];
$r['invoicedueday'] = $dateIdd['day'];
$r['invoicedate'] = PhocacartOrder::getInvoiceDate($orderId, $common->invoice_date, 'Y-m-d');
$dateId = PhocacartDate::splitDate($r['invoicedate']);
$r['invoiceyear'] = $dateId['year'];
$r['invoicemonth'] = $dateId['month'];
$r['invoiceday'] = $dateId['day'];
$r['invoicetimeofsupply'] = PhocacartOrder::getInvoiceDate($orderId, $common->invoice_time_of_supply, 'Y-m-d');
$totalToPay = isset($totalBrutto[0]->amount) ? $totalBrutto[0]->amount : 0;
$r['totaltopaynoformat'] = number_format($totalToPay, 2, '.', '');
$r['totaltopaynoformatcomma'] = number_format($totalToPay, 2, ',', '');
$r['totaltopay'] = $price->getPriceFormat($totalToPay, 0, 1);
$r['paymenttitle'] = PhocacartOrderView::getPaymentTitle($common);
$r['paymentdescriptioninfo'] = PhocacartOrderView::getPaymentDescriptionInfo($common);
$dateO = PhocacartDate::splitDate($common->date);
$r['orderdate'] = $common->date;
$r['orderyear'] = $dateO['year'];
$r['ordermonth'] = $dateO['month'];
$r['orderday'] = $dateO['day'];
$r['ordernumbertxt'] = Text::_('COM_PHOCACART_ORDER_NR');
$r['bankaccountnumber'] = $pC->get('bank_account_number', '');
$r['iban'] = $pC->get('iban', '');
$r['bicswift'] = $pC->get('bic_swift', '');
$r['openingtimesinfo'] = PhocacartTime::getOpeningTimesMessage();
$r['vendorname'] = '';
$r['venderusername'] = '';
if ((int) $common->vendor_id > 0) {
$vendor = Factory::getUser((int) $common->vendor_id);
$r['vendorname'] = $vendor->name;
$r['venderusername'] = $vendor->username;
}
return $r;
}