| 1 |
<?php |
| 2 |
|
| 3 |
class WooMailerLiteAdminMetaBoxController extends WooMailerLiteController |
| 4 |
{ |
| 5 |
public function addMetaBoxes() |
| 6 |
{ |
| 7 |
$screen = 'shop_order'; |
| 8 |
if (class_exists('CustomOrdersTableController') && wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled()) { |
| 9 |
$screen = wc_get_page_screen_id( 'shop-order' ); |
| 10 |
} |
| 11 |
// if hpos is enabled |
| 12 |
if (get_current_screen()->id == 'woocommerce_page_wc-orders') { |
| 13 |
$screen = 'woocommerce_page_wc-orders'; |
| 14 |
} |
| 15 |
|
| 16 |
add_meta_box( |
| 17 |
'woo-ml-order', |
| 18 |
'<span class="woo-ml-icon"></span> ' . __('MailerLite', 'woo-mailerlite'), |
| 19 |
[$this, 'metaBoxOutput'], |
| 20 |
$screen, |
| 21 |
'side', |
| 22 |
'low' |
| 23 |
); |
| 24 |
} |
| 25 |
|
| 26 |
public function metaBoxOutput($post) |
| 27 |
{ |
| 28 |
wp_nonce_field(basename(__FILE__), 'woo_ml_order_meta_box_nonce'); |
| 29 |
|
| 30 |
$order = ($post instanceof WP_Post) ? wc_get_order($post->ID) : $post; |
| 31 |
|
| 32 |
$orderId = $order->get_id(); |
| 33 |
$iconYes = '<span class="dashicons dashicons-yes" style="color: #00A153;right: 7px;position: absolute;"></span>'; |
| 34 |
$iconNo = '<span class="dashicons dashicons-no-alt" style="color: #a00;right: 7px;position: absolute;"></span>'; |
| 35 |
$iconNA = '<span class="dashicons dashicons-minus" style="color: #ffb900; right: 7px; position: absolute;"></span>'; |
| 36 |
?> |
| 37 |
<?php $subscribe = $order->get_meta('_woo_ml_subscribe'); ?> |
| 38 |
<p> |
| 39 |
<?php echo _e('Signed up for emails', |
| 40 |
'woo-mailerlite') . wc_help_tip("Customer ticked the Subscribe box at the checkout stage to receive newsletters."); ?><?php echo ($subscribe) ? $iconYes : $iconNo; ?> |
| 41 |
</p> |
| 42 |
<?php $subscribed = $order->get_meta('_woo_ml_subscribed'); ?> |
| 43 |
<?php $already_subscribed = $order->get_meta('_woo_ml_already_subscribed'); ?> |
| 44 |
<?php $subscriber_updated = $order->get_meta('_woo_ml_subscriber_updated'); ?> |
| 45 |
<p> |
| 46 |
<?php echo _e('Subscribed to email list', |
| 47 |
'woo-mailerlite') . wc_help_tip("Customer was successfully added to the subscriber list in MailerLite."); ?><?php echo ($subscribed) ? $iconYes : ($already_subscribed && $subscriber_updated ? $iconNA : $iconNo); ?> |
| 48 |
</p> |
| 49 |
<p> |
| 50 |
<?php echo _e('Previously subscribed', |
| 51 |
'woo-mailerlite') . wc_help_tip("Customer was already an existing subscriber."); ?><?php echo ($already_subscribed) ? $iconYes : ($subscribe && $subscribed ? $iconNA : $iconNo); ?> |
| 52 |
</p> |
| 53 |
<p> |
| 54 |
<?php echo _e('Updated subscriber data', |
| 55 |
'woo-mailerlite') . wc_help_tip("Checkout data including purchases and contact information was successfully updated in MailerLite."); ?><?php echo ($subscriber_updated) ? $iconYes : ($subscribe && $subscribed ? $iconNA : $iconNo); ?> |
| 56 |
</p> |
| 57 |
<?php $order_data_submitted = $order->get_meta('_woo_ml_order_data_submitted'); ?> |
| 58 |
<p> |
| 59 |
<?php echo _e('Order data submitted', |
| 60 |
'woo-mailerlite') . wc_help_tip("Order data is uploaded to MailerLite once the payment is processed."); ?><?php echo ($order_data_submitted) ? $iconYes : $iconNo; ?> |
| 61 |
</p> |
| 62 |
<?php $order_tracking_completed = $order->get_meta('_woo_ml_order_tracked'); ?> |
| 63 |
<p> |
| 64 |
<?php echo _e('Order tracking completed', |
| 65 |
'woo-mailerlite') . wc_help_tip("All stages of the tracking process on this order have been completed."); ?><?php echo ($order_tracking_completed) ? $iconYes : $iconNo; ?> |
| 66 |
</p> |
| 67 |
<?php |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Saves the custom meta input |
| 72 |
*/ |
| 73 |
function woo_ml_order_meta_box_save($post_id) |
| 74 |
{ |
| 75 |
|
| 76 |
// Checks save status |
| 77 |
$is_autosave = wp_is_post_autosave($post_id); |
| 78 |
$is_revision = wp_is_post_revision($post_id); |
| 79 |
$is_valid_nonce = (isset($_POST['woo_ml_order_meta_box_nonce']) && wp_verify_nonce($_POST['woo_ml_order_meta_box_nonce'], |
| 80 |
basename(__FILE__))) ? 'true' : 'false'; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
} |