Skip to content

Commit b7ad582

Browse files
committed
ft: added customization details in email
1 parent d4fefd9 commit b7ad582

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

functions/admin/settings.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ function print_app_create_settings() {
88

99
function settings_api_init() {
1010
add_settings_section('print_app_settings_section', 'PrintApp Settings', 'printapp\\functions\\admin\\print_app_create_settings', 'print_app');
11-
add_settings_field('print_app_domain_key', 'Domain Key', 'printapp\\functions\\admin\\print_app_domain_key', 'print_app', 'print_app_settings_section', array());
12-
add_settings_field('print_app_secret_key', 'Auth Key', 'printapp\\functions\\admin\\print_app_secret_key', 'print_app', 'print_app_settings_section', array());
11+
add_settings_field('print_app_domain_key', 'Domain Key:', 'printapp\\functions\\admin\\print_app_domain_key', 'print_app', 'print_app_settings_section', array());
12+
add_settings_field('print_app_secret_key', 'Auth Key:', 'printapp\\functions\\admin\\print_app_secret_key', 'print_app', 'print_app_settings_section', array());
13+
add_settings_field('print_app_cust_download_link', 'Include PDF Link in Customer Email:', 'printapp\\functions\\admin\\print_app_cust_download_link', 'print_app', 'print_app_settings_section', array());
1314
register_setting('print_app', 'print_app_domain_key');
1415
register_setting('print_app', 'print_app_secret_key');
16+
register_setting('print_app', 'print_app_cust_download_link');
1517
}
1618

1719
// input for capturing the PrintApp Domain Key
@@ -24,6 +26,10 @@ function print_app_secret_key() {
2426
echo '<input class="regular-text" id="print_app_secret_key" name="print_app_secret_key" type="text" value="' . esc_html( get_option('print_app_secret_key') ) . '" />';
2527
}
2628

29+
function print_app_cust_download_link() {
30+
echo '<input class="regular-text" id="print_app_cust_download_link" name="print_app_cust_download_link" type="checkbox" '. ( get_option('print_app_cust_download_link') == 'on' ? 'checked' : '' ) . ' />';
31+
}
32+
2733
// creates the PrintApp settings link in admin
2834
function add_settings_link($links) {
2935
$settings_link = array(

functions/general/emails.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace printapp\functions\general;
4+
5+
function order_email($order, $sent_to_admin, $plain_text, $email) {
6+
7+
$items = $order->get_items();
8+
9+
foreach ($items as $item_id => $item) {
10+
$product = $item->get_product();
11+
$print_app_customization = $item->get_meta(PRINT_APP_CUSTOMIZATION_KEY, true);
12+
if (empty($print_app_customization)) continue;
13+
14+
foreach ($print_app_customization['previews'] as $preview) {
15+
echo '<tr><td colspan="2" style="text-align:left; padding: 10px 0;"><img src="' . $preview['url'] . '" width="180px; margin-right:10px;"/></td></tr>';
16+
}
17+
18+
$include_download_link = get_option('print_app_cust_download_link') == 'on';
19+
20+
if ($sent_to_admin || $include_download_link) {
21+
$post_fix = $print_app_customization['projectId'];
22+
echo '<tr><td colspan="2" style="text-align:left; padding: 10px 0;"><a href="https://pdf.print.app/' . $post_fix . '">Download Customization PDF</a></td></tr>';
23+
}
24+
25+
}
26+
}

functions/general/init_hooks.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ function init_hooks() {
5050
add_action('wp_ajax_print_app_save_project', 'printapp\\functions\\front\\save_project_sess');
5151
add_action('wp_ajax_nopriv_print_app_reset_project', 'printapp\\functions\\front\\reset_project_sess');
5252
add_action('wp_ajax_print_app_reset_project', 'printapp\\functions\\front\\reset_project_sess');
53+
54+
// add the customization info to the order email
55+
add_action('woocommerce_email_order_details', 'printapp\\functions\\general\\order_email', 10, 4);
5356
}
5457

5558

0 commit comments

Comments
 (0)