Доброго времени суток. Хотим реализовать возможность печати нескольких подарочных сертификатов с одной страницы/шаблона. На подобии “orders.bulk_print”, “orders.packing_slip”
Пробовал так
gift_certificates.post.php
if ($mode == 'm_certs_print' && !empty($_REQUEST['gift_certs_data'])) {
echo(fn_print_gift_cards($_REQUEST['gift_certs_data']));
return[CONTROLLER_STATUS_NO_CONTENT];
}
Создал функцию “fn_print_gift_cards” → addons/gift_certificates/func.php
function fn_print_gift_cards($gift_certs_data, $params = []) {
if(is_bool($params)) {
$args = func_get_args();
$params = [];
fn_set_hook('print_gift_certificates_normalize_parameters', $args, $params);
if(isset($args[2])) {
$params['land_code'] = $args[2];
}
}
$params = array_merge(
[
'area' => SiteArea::ADMIN_PANEL,
'land_code' => CART_LANGUAGE,
'add_page_break' => true,
],
$params
);
$gift_certs_data = (array) $gift_certs_data;
fn_set_hook('print_gift_certificates_pre', $gift_cert_data, $params);
$view = Tygh::$app['view'];
$html = [];
foreach ($gift_certs_data as $gift_cert_data) {
$templates = fn_get_gift_certificate_templates();
if (empty($gift_cert_data['template']) || !isset($templates[$gift_cert_data['template']])) {
$gift_cert_data['template'] = key($templates);
}
$gc_data = fn_get_gift_certificate_info($gift_cert_data, 'P', $stored_products);
if (Registry::get('settings.Appearance.email_templates') == 'old') {
$company_id = !empty($gift_cert_data['company_id']) ? $gift_cert_data['company_id'] : Registry::get('runtime.company_id');
$view = Tygh::$app['view'];
$view->assign('gift_cert_data', $gc_data);
return $view->displayMail('addons/gift_certificates/templates/' . $gift_cert_data['template'], false, 'C', $company_id, $lang_code);
} else {
/** @var \Tygh\Addons\GiftCertificates\Documents\GiftCertificate\Type $gift_certificate */
$gift_certificate = Tygh::$app['template.document.gift_certificate.type'];
$template_code = isset($params['template_code']) ? $params['template_code'] : 'print';
return $gift_certificate->renderByData($gc_data, $template_code, $lang_code);
if (!$result) {
continue;
}
$view->assign('content', $result);
$result = $view->displayMail('common/wrap_document.tpl', false, $params['area']);
$html[] = $result;
}
if (
!$params['add_page_break']
|| $gift_cert_id === end($gift_cert_ids)
) {
continue;
}
$html[] = "<div style='page-break-before: always;'> </div>";
}
$output = implode(PHP_EOL, $html);
return $output;
}
Но все тщетно. Думаем, что не хваатет цикла в режиме контроллера. Будем рады любым советам.