Version Description
- Enhancement - Updated Settings page design
- Enhancement - Moved TrackShip menu to a new page under WooCommerce and updated its design
- Dev - Added compatibility with WordPress 5.7 and WooCommerce 5.1.0
- Fix - Fixed Trackship Late Shipments variable issue
- Fix - Fixed compatibility with PHP 8
Download this release
Release Info
Developer | zorem |
Plugin | Advanced Shipment Tracking for WooCommerce |
Version | 3.2.2 |
Comparing to | |
See all releases |
Code changes from version 3.2.1.5 to 3.2.2
- assets/css/admin.css +135 -59
- assets/css/front.css +8 -8
- assets/css/icons/Branded-Tracking-Page.png +0 -0
- assets/css/icons/Delivered-512.png +0 -0
- assets/css/icons/Delivered-o.png +0 -0
- assets/css/icons/In-Transit--o.png +0 -0
- assets/css/icons/In-Transit-512.png +0 -0
- assets/css/icons/Late-Shipments-512.png +0 -0
- assets/css/icons/Multi-Carrier-Support.png +0 -0
- assets/css/icons/On-hold-v1.png +0 -0
- assets/css/icons/Out-for-Delivery-512.png +0 -0
- assets/css/icons/Pre-Transit-512.png +0 -0
- assets/css/icons/ast-icon.png +0 -0
- assets/css/icons/available-for-picup-512.png +0 -0
- assets/css/icons/available-for-picup-o.png +0 -0
- assets/css/icons/available-for-picup-v3.png +0 -0
- assets/css/icons/available-for-picup-v4.png +0 -0
- assets/css/icons/available-for-picup.png +0 -0
- assets/css/icons/cancel-o.png +0 -0
- assets/css/icons/cancel-v3.png +0 -0
- assets/css/icons/cancel-v4.png +0 -0
- assets/css/icons/carrier-unsupported-o.png +0 -0
- assets/css/icons/carrier-unsupported-v4.png +0 -0
- assets/css/icons/{carrier-unsupported-v3.png → carrier-unsupported.png} +0 -0
- assets/css/icons/customer-support.png +0 -0
- assets/css/icons/delivered-grey-v3.png +0 -0
- assets/css/icons/delivered-o.png +0 -0
- assets/css/icons/delivered-v3.png +0 -0
- assets/css/icons/delivered-v4.png +0 -0
- assets/css/icons/delivered.png +0 -0
- assets/css/icons/delivery-email-2.png +0 -0
- assets/css/icons/failure-512.png +0 -0
- assets/css/icons/failure-o.png +0 -0
- assets/css/icons/failure-v3.png +0 -0
- assets/css/icons/failure-v4.png +0 -0
- assets/css/icons/failure.png +0 -0
- assets/css/icons/in-transit-grey-v3.png +0 -0
- assets/css/icons/in-transit-o.png +0 -0
- assets/css/icons/in-transit-v3.png +0 -0
- assets/css/icons/in-transit-v4.png +0 -0
- assets/css/icons/in-transit.png +0 -0
- assets/css/icons/invalid-o.png +0 -0
- assets/css/icons/invalid-tracking-number-o.png +0 -0
- assets/css/icons/invalid-tracking-number.png +0 -0
- assets/css/icons/invalid-user-key-o.png +0 -0
- assets/css/icons/invalid-user-key-v4.png +0 -0
- assets/css/icons/{invalid-v3.png → invalid-user-key.png} +0 -0
- assets/css/icons/invalid.png +0 -0
- assets/css/icons/label_cancelled-o.png +0 -0
- assets/css/icons/label_cancelled.png +0 -0
- assets/css/icons/late-shipment-v3.png +0 -0
- assets/css/icons/on-hold-o.png +0 -0
- assets/css/icons/{On-hold-v3.png → on-hold.png} +0 -0
- assets/css/icons/out-for-delivery-grey-v3.png +0 -0
- assets/css/icons/out-for-delivery-o.png +0 -0
- assets/css/icons/out-for-delivery-v3.png +0 -0
- assets/css/icons/out-for-delivery-v4.png +0 -0
- assets/css/icons/out-for-delivery.png +0 -0
- assets/css/icons/partial-shipped-icon.png +0 -0
- assets/css/icons/pending-trackship-o.png +0 -0
- assets/css/icons/pending-trackship-v4.png +0 -0
- assets/css/icons/pending-trackship.png +0 -0
- assets/css/icons/pre-transit-o.png +0 -0
- assets/css/icons/pre-transit-v3.png +0 -0
- assets/css/icons/pre-transit-v4.png +0 -0
- assets/css/icons/pre-transit.png +0 -0
- assets/css/icons/return-to-sender-512.png +0 -0
- assets/css/icons/return-to-sender-o.png +0 -0
- assets/css/icons/return-to-sender-v3.png +0 -0
- assets/css/icons/return-to-sender-v4.png +0 -0
- assets/css/icons/return-to-sender.png +0 -0
- assets/css/icons/shipped-o.png +0 -0
- assets/css/icons/unknown-o.png +0 -0
- assets/css/icons/unknown-v4.png +0 -0
- assets/css/icons/unknown.png +0 -0
- assets/css/icons/updated-tracking-icon.png +0 -0
- assets/css/icons/wrong-shipiing-provider-o.png +0 -0
- assets/css/icons/wrong-shipiing-provider.png +0 -0
- assets/css/trackship.css +54 -27
- assets/images/AOSM-addons-icon.jpg +0 -0
- assets/images/AOSM-banner.png +0 -0
- assets/images/CSV-Import-Tracking-info.png +0 -0
- assets/images/SMSWOO-sidebar-banner.png +0 -0
- assets/images/Tracking-Per-Item-addon.jpg +0 -0
- assets/images/addon-icon.png +0 -0
- assets/images/ajax-login-register-icon.png +0 -0
- assets/images/alp-icon.png +0 -0
- assets/images/ast-addons-notice-image.jpg +0 -0
- assets/images/ast-logo.png +0 -0
- assets/images/ast-pro-banner.png +0 -0
- assets/images/ast.png +0 -0
- assets/images/cbr-banner.png +0 -0
- assets/images/cbr-icon.png +0 -0
- assets/images/cev-icon.png +0 -0
- assets/images/paypal-addon-banner.jpg +0 -0
- assets/images/paypal-addon-banner.png +0 -0
- assets/images/readytoship-addon-banner.jpg +0 -0
- assets/images/shipstations-addon-banner.jpg +0 -0
- assets/images/sma-icon.png +0 -0
- assets/images/sms-woo-icon.png +0 -0
- assets/images/smswoo-icon.png +0 -0
- assets/images/smswoo.png +0 -0
- assets/images/src-icon.png +0 -0
- assets/images/sre-banner.png +0 -0
- assets/images/sre-icon.png +0 -0
- assets/images/t_layout_1.jpg +0 -0
- assets/images/t_layout_2.jpg +0 -0
- assets/images/tpi-addon-icon.jpg +0 -0
- assets/images/tpi-addon-icon.png +0 -0
- assets/images/tpi-icon.png +0 -0
- assets/images/tpi-icon_license.png +0 -0
- assets/images/tracking-per-item-sidebar-banner.png +0 -0
- assets/images/trackship-ast-banner.png +0 -0
- assets/images/trackship-banner.png +0 -0
- assets/images/trackship-sidebar-banner.png +0 -0
- assets/images/ts-100-supported-carriers.png +0 -0
- assets/images/ts-banner.jpg +0 -0
- assets/images/ts-home-better-customer-support.png +0 -0
- assets/images/ts-home-email-notifications.png +0 -0
- assets/images/ts-home-tracking-delivery-analytics.png +0 -0
- assets/images/ts-home-tracking-page.png +0 -0
- assets/images/ts-woocommerce-integration.png +0 -0
- assets/images/ts_bg.png +0 -0
- assets/images/wc-addon-banner.jpg +0 -0
- assets/images/zorem-logo.png +0 -0
- assets/js/admin.js +1 -0
- assets/js/customizer-scripts.js +13 -1
- assets/js/shipping_row.js +17 -11
- assets/js/trackship.js +47 -78
- includes/api/class-wc-advanced-shipment-tracking-rest-api-controller.php +1 -1
- includes/class-wc-admin-notices.php +10 -50
- includes/class-wc-advanced-shipment-tracking-admin-notice.php +17 -118
- includes/class-wc-advanced-shipment-tracking-admin.php +787 -765
- includes/class-wc-advanced-shipment-tracking-api-call.php +65 -47
- includes/class-wc-advanced-shipment-tracking-cron.php +0 -43
- includes/class-wc-advanced-shipment-tracking-front.php +183 -302
- includes/class-wc-advanced-shipment-tracking-install.php +80 -68
- includes/class-wc-advanced-shipment-tracking-late-shipments.php +77 -65
- includes/class-wc-advanced-shipment-tracking-license.php +5 -5
- includes/class-wc-advanced-shipment-tracking-settings.php +230 -235
- includes/class-wc-advanced-shipment-tracking-trackship.php +526 -549
- includes/class-wc-advanced-shipment-tracking.php +542 -643
- includes/customizer/class-wc-availableforpickup-email-customizer.php +31 -164
- includes/customizer/class-wc-delivered-email-customizer.php +26 -155
- includes/customizer/class-wc-email-customizer.php +0 -610
- includes/customizer/class-wc-exception-email-customizer.php +402 -0
- includes/customizer/class-wc-failure-email-customizer.php +27 -157
- includes/customizer/class-wc-intransit-email-customizer.php +39 -145
- includes/customizer/class-wc-late-shipments-email-customizer.php +3 -5
- includes/customizer/class-wc-onhold-email-customizer.php +27 -160
- includes/customizer/class-wc-outfordelivery-email-customizer.php +24 -158
- includes/customizer/class-wc-partial-shipped-email-customizer.php +49 -76
- includes/customizer/class-wc-returntosender-email-customizer.php +27 -159
- includes/customizer/class-wc-tracking-info-customizer.php +59 -71
- includes/customizer/class-wc-tracking-page-customizer.php +16 -37
- includes/customizer/class-wc-updated-tracking-email-customizer.php +42 -68
- includes/customizer/class-wcast-customizer.php +109 -128
- includes/customizer/custom-controls.php +13 -29
- includes/customizer/delivered_preview.php +0 -22
- includes/customizer/preview/availableforpickup_preview.php +2 -4
- includes/customizer/preview/delivered_status_preview.php +2 -4
- includes/customizer/preview/{delivered_preview.php → exception_preview.php} +2 -4
- includes/customizer/preview/failure_preview.php +3 -6
- includes/customizer/preview/intransit_preview.php +3 -6
- includes/customizer/preview/onhold_preview.php +5 -12
- includes/customizer/preview/outfordelivery_preview.php +3 -6
- includes/customizer/preview/returntosender_preview.php +1 -3
- includes/customizer/preview/updated_tracking_preview.php +1 -3
- includes/email-manager.php +19 -18
- includes/emails/class-shipment-partial-shipped-email.php +15 -2
- includes/tracking-info.php +4 -5
- includes/trackship-email-manager.php +151 -264
- includes/views/admin_options_addons.php +50 -133
- includes/views/admin_options_osm.php +69 -104
- includes/views/admin_options_settings.php +19 -53
- includes/views/admin_options_shipping_provider.php +8 -8
- includes/views/admin_options_trackship_integration.php +4 -3
- includes/views/admin_status_notifications.php +137 -217
- includes/views/admin_tracking_page_settings.php +0 -129
- includes/views/admin_trackship_dashboard.php +141 -37
- includes/views/front/preview_tracking_page.php +2 -2
- includes/views/front/tracking_page_header.php +8 -8
- includes/views/trackship_settings.php +0 -126
- readme.txt +8 -1
- templates/emails/customer-delivered-order.php +0 -53
- templates/emails/customer-partial-shipped-order.php +3 -23
- templates/emails/customer-updated-tracking-order.php +3 -23
- templates/emails/plain/tracking-info.php +1 -2
- templates/emails/tracking-info.php +135 -202
- templates/emails/wcast-billing-email-addresses.php +4 -6
- templates/emails/wcast-shipping-email-addresses.php +10 -11
- templates/myaccount/tracking-info.php +166 -221
- woocommerce-advanced-shipment-tracking.php +120 -110
assets/css/admin.css
CHANGED
@@ -29,9 +29,10 @@ body.shipment_tracking_admin_settings{
|
|
29 |
}
|
30 |
.zorem-layout__header .zorem-layout__header-breadcrumbs a{
|
31 |
color: #005b9a;
|
|
|
32 |
}
|
33 |
.zorem-layout__header .zorem-layout__header-breadcrumbs span+span:before {
|
34 |
-
content: "
|
35 |
color: #555d66;
|
36 |
margin: 0 2px;
|
37 |
}
|
@@ -43,15 +44,30 @@ body.shipment_tracking_admin_settings{
|
|
43 |
height: 56px;
|
44 |
padding: 0 30px 0 0;
|
45 |
}
|
46 |
-
.ast-
|
47 |
-
|
48 |
-
border: 1px solid #e0e0e0;
|
49 |
-
padding: 8px 6px 8px 8px;
|
50 |
-
text-decoration: none;
|
51 |
-
border-radius: 3px;
|
52 |
}
|
53 |
-
.ast-
|
54 |
margin-left: 2px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
#woocommerce-advanced-shipment-tracking .inside {
|
57 |
padding: 0 12px 12px;
|
@@ -134,22 +150,23 @@ input.tab_input,input.inner_tab_input {
|
|
134 |
}
|
135 |
label.tab_label {
|
136 |
text-decoration: none;
|
137 |
-
padding:
|
138 |
font-size: 14px;
|
139 |
color: #005b9a;
|
140 |
display: inline-block;
|
141 |
margin-left: 0;
|
142 |
line-height: 1;
|
143 |
outline: none;
|
|
|
144 |
}
|
145 |
label.tab_label.first_label {
|
146 |
margin-left: 15px;
|
147 |
}
|
148 |
label.inner_tab_label {
|
149 |
text-decoration: none;
|
150 |
-
padding:
|
151 |
font-size: 14px;
|
152 |
-
color: #
|
153 |
display: inline-block;
|
154 |
line-height: 1;
|
155 |
outline: none;
|
@@ -170,13 +187,10 @@ label.tab_label:hover {
|
|
170 |
cursor: pointer;
|
171 |
}
|
172 |
input.tab_input:checked + label {
|
173 |
-
color: #
|
174 |
-
border-bottom: 3px solid #005b9a;
|
175 |
-
padding: 10px 15px 10px;
|
176 |
}
|
177 |
input.inner_tab_input:checked + label{
|
178 |
-
|
179 |
-
padding: 15px 12px 5px;
|
180 |
}
|
181 |
input.inner_tab_input:checked + label.ts_tabs_label{
|
182 |
border-bottom: 3px solid #59c889;
|
@@ -306,6 +320,9 @@ input.tab_input_1:checked + label{
|
|
306 |
height: 35px;
|
307 |
padding: 0 10px;
|
308 |
}
|
|
|
|
|
|
|
309 |
|
310 |
.wp-core-ui .btn_red {
|
311 |
background: red;
|
@@ -472,52 +489,52 @@ input.tab_input_1:checked + label{
|
|
472 |
vertical-align: text-bottom;
|
473 |
}
|
474 |
.ast-shipment-status .icon-default:before{
|
475 |
-
background-image: url(icons/invalid
|
476 |
}
|
477 |
.ast-shipment-status .icon-INVALID_TRACKING_NUM:before{
|
478 |
-
background-image: url(icons/invalid-
|
479 |
}
|
480 |
.ast-shipment-status .icon-wrong_shipping_provider:before{
|
481 |
-
background-image: url(icons/
|
482 |
}
|
483 |
.ast-shipment-status .icon-carrier_unsupported:before{
|
484 |
-
background-image: url(icons/
|
485 |
}
|
486 |
.ast-shipment-status .icon-delivered:before{
|
487 |
-
background-image: url(icons/delivered
|
488 |
}
|
489 |
.ast-shipment-status .icon-in_transit:before{
|
490 |
-
background-image: url(icons/in-transit
|
491 |
}
|
492 |
.ast-shipment-status .icon-on_hold:before{
|
493 |
-
background-image: url(icons/
|
494 |
}
|
495 |
.ast-shipment-status .icon-pre_transit:before{
|
496 |
-
background-image: url(icons/pre-transit
|
497 |
}
|
498 |
.ast-shipment-status .icon-out_for_delivery:before{
|
499 |
-
background-image: url(icons/out-for-delivery
|
500 |
}
|
501 |
.ast-shipment-status .icon-available_for_pickup:before{
|
502 |
-
background-image: url(icons/available-for-picup
|
503 |
}
|
504 |
.ast-shipment-status .icon-return_to_sender:before{
|
505 |
-
background-image: url(icons/return-to-sender
|
506 |
}
|
507 |
.ast-shipment-status .icon-failure:before{
|
508 |
-
background-image: url(icons/failure
|
509 |
}
|
510 |
.ast-shipment-status .icon-exception:before{
|
511 |
-
background-image: url(icons/failure
|
512 |
}
|
513 |
.ast-shipment-status .icon-unknown:before{
|
514 |
-
background-image: url(icons/unknown
|
515 |
}
|
516 |
.ast-shipment-status .icon-pending_trackship:before{
|
517 |
-
background-image: url(icons/pending-trackship
|
518 |
}
|
519 |
.ast-shipment-status .icon-invalid_user_key:before{
|
520 |
-
background-image: url(icons/invalid-user-key
|
521 |
}
|
522 |
.wcast-shipment-status-list .wcast-shipment-est-delivery {
|
523 |
display: block;
|
@@ -996,6 +1013,9 @@ a.reset_default_provider {
|
|
996 |
margin-top: 0;
|
997 |
margin-bottom: 0px;
|
998 |
}
|
|
|
|
|
|
|
999 |
.woocommerce.zorem_admin_layout table.form-table.order-status-table{
|
1000 |
table-layout: auto;
|
1001 |
}
|
@@ -1045,7 +1065,7 @@ a.reset_default_provider {
|
|
1045 |
margin: 10px 0 0;
|
1046 |
}
|
1047 |
.woocommerce.zorem_admin_layout table.form-table th{
|
1048 |
-
padding: 20px
|
1049 |
}
|
1050 |
.woocommerce.zorem_admin_layout table.form-table.settings-form-table th.titledesc{
|
1051 |
padding: 5px 20px 0 0;
|
@@ -1085,10 +1105,10 @@ a.reset_default_provider {
|
|
1085 |
padding: 10px 15px 15px;
|
1086 |
}
|
1087 |
.woocommerce.zorem_admin_layout table.form-table.order-status-table td{
|
1088 |
-
padding: 15px;
|
1089 |
}
|
1090 |
.woocommerce.zorem_admin_layout table.form-table.order-status-table td:first-child{
|
1091 |
-
padding:20px 15px 20px
|
1092 |
width: 37px;
|
1093 |
}
|
1094 |
.woocommerce.zorem_admin_layout table.form-table th label{
|
@@ -1099,9 +1119,6 @@ a.reset_default_provider {
|
|
1099 |
span.radio_section {
|
1100 |
margin-right: 10px;
|
1101 |
}
|
1102 |
-
.radio_section input{
|
1103 |
-
vertical-align: bottom;
|
1104 |
-
}
|
1105 |
span.multiple_checkbox {
|
1106 |
display: inline-block;
|
1107 |
line-height: 30px;
|
@@ -1122,13 +1139,14 @@ span.multiple_checkbox {
|
|
1122 |
margin: 0;
|
1123 |
}
|
1124 |
.settings_ul li> input[type=checkbox] {
|
1125 |
-
vertical-align:
|
1126 |
}
|
1127 |
.settings_ul>li{
|
1128 |
-
padding: 15px
|
1129 |
border-bottom: 1px solid #e0e0e0;
|
1130 |
-
margin: 0;
|
1131 |
-
min-height:
|
|
|
1132 |
position: relative;
|
1133 |
}
|
1134 |
.settings_ul li:last-child {
|
@@ -1154,8 +1172,17 @@ span.multiple_checkbox {
|
|
1154 |
vertical-align: top;
|
1155 |
width: 58%;
|
1156 |
}
|
|
|
|
|
|
|
1157 |
.setting_ul_tgl_checkbox_label{
|
1158 |
-
margin-left:
|
|
|
|
|
|
|
|
|
|
|
|
|
1159 |
}
|
1160 |
.multiple_checkbox_label {
|
1161 |
display: inline-block;
|
@@ -1315,7 +1342,8 @@ section.widget_tab_section {
|
|
1315 |
.woocommerce_page_woocommerce-advanced-shipment-tracking .zorem-layout .woocommerce-help-tip{
|
1316 |
color: #005B9A;
|
1317 |
font-size: 20px;
|
1318 |
-
|
|
|
1319 |
}
|
1320 |
.woocommerce_page_woocommerce-advanced-shipment-tracking #tiptip_content{
|
1321 |
background:#005B9A;
|
@@ -1411,6 +1439,30 @@ section.widget_tab_section {
|
|
1411 |
border-radius: 3px;
|
1412 |
background: #fff;
|
1413 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1414 |
#wc_ast_upload_csv_form .outer_form_table{
|
1415 |
margin-top: 20px;
|
1416 |
background-color: #fff;
|
@@ -1836,6 +1888,9 @@ input[type=checkbox].ast-tgl {
|
|
1836 |
border: 1px solid #ccc;
|
1837 |
border-radius: 2em;
|
1838 |
}
|
|
|
|
|
|
|
1839 |
.ast-tgl-flat + .ast-tgl-btn:after {
|
1840 |
-webkit-transition: all .2s ease;
|
1841 |
transition: all .2s ease;
|
@@ -1929,38 +1984,44 @@ table.ast-license-form{
|
|
1929 |
padding: 16px 20px 16px 0;
|
1930 |
vertical-align: middle;
|
1931 |
}
|
1932 |
-
.ast-license-form .wp-list-table__row td.wp-list-table__ext-details {
|
1933 |
-
display: -webkit-box;
|
1934 |
-
display: flex;
|
1935 |
padding: 26px 20px;
|
1936 |
}
|
1937 |
.ast-license-form .wp-list-table__ext-actions {
|
1938 |
min-width: 150px;
|
1939 |
-
position: relative;
|
1940 |
-
width: 35%;
|
1941 |
text-align: right;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1942 |
}
|
1943 |
.ast-license-form .wp-list-table__row td .wp-list-table__ext-title {
|
1944 |
color: #005b9a;
|
1945 |
-
font-size:
|
1946 |
line-height: 25px;
|
1947 |
-
font-weight: 600;
|
1948 |
-
width: 45%;
|
1949 |
-
}
|
1950 |
-
.ast-license-form .wp-list-table__row td.wp-list-table__ext-details input{
|
1951 |
-
width: 100%;
|
1952 |
}
|
1953 |
.ast-license-form .wp-list-table__row td .wp-list-table__ext-description {
|
1954 |
color: #333;
|
1955 |
-
padding-left:
|
1956 |
-
|
|
|
1957 |
}
|
1958 |
.ast_admin_content .ast-license-form div.submit{
|
1959 |
margin: 0;
|
|
|
1960 |
}
|
1961 |
.ast_admin_content .ast-license-form div.submit .pesan{
|
1962 |
display:none;
|
1963 |
-
margin-bottom: 0;
|
|
|
|
|
|
|
|
|
1964 |
}
|
1965 |
.ast_admin_content .ast-license-form div.submit .button-primary{
|
1966 |
vertical-align: middle;
|
@@ -2059,7 +2120,7 @@ ul.csv_error_details_ul li:before{
|
|
2059 |
.trackship_addon_section{
|
2060 |
background: #fff;
|
2061 |
border: 1px solid #e0e0e0;
|
2062 |
-
padding:
|
2063 |
margin: 20px 0 0;
|
2064 |
}
|
2065 |
.ast_ts_landing_banner{
|
@@ -2078,6 +2139,21 @@ ul.csv_error_details_ul li:before{
|
|
2078 |
overflow: hidden;
|
2079 |
text-overflow: ellipsis;
|
2080 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2081 |
.multiple_select_container {
|
2082 |
display: inline-block;
|
2083 |
}
|
29 |
}
|
30 |
.zorem-layout__header .zorem-layout__header-breadcrumbs a{
|
31 |
color: #005b9a;
|
32 |
+
text-decoration: none;
|
33 |
}
|
34 |
.zorem-layout__header .zorem-layout__header-breadcrumbs span+span:before {
|
35 |
+
content: " > ";
|
36 |
color: #555d66;
|
37 |
margin: 0 2px;
|
38 |
}
|
44 |
height: 56px;
|
45 |
padding: 0 30px 0 0;
|
46 |
}
|
47 |
+
.wp-core-ui .button-primary.ast-pro-btn {
|
48 |
+
line-height: 34px;
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
+
.ast-pro-btn span.dashicons{
|
51 |
margin-left: 2px;
|
52 |
+
vertical-align: middle;
|
53 |
+
height: 22px;
|
54 |
+
}
|
55 |
+
.nav_doc_section {
|
56 |
+
float: right;
|
57 |
+
padding: 11px 0;
|
58 |
+
margin-right: 15px;
|
59 |
+
}
|
60 |
+
.nav_doc_section a {
|
61 |
+
color: #005b9a;
|
62 |
+
text-decoration: none;
|
63 |
+
font-size: 14px;
|
64 |
+
}
|
65 |
+
.nav_doc_section a:hover{
|
66 |
+
color: #212121;
|
67 |
+
}
|
68 |
+
.nav_doc_section a:focus{
|
69 |
+
outline: none;
|
70 |
+
box-shadow: none;
|
71 |
}
|
72 |
#woocommerce-advanced-shipment-tracking .inside {
|
73 |
padding: 0 12px 12px;
|
150 |
}
|
151 |
label.tab_label {
|
152 |
text-decoration: none;
|
153 |
+
padding: 13px 15px 13px;
|
154 |
font-size: 14px;
|
155 |
color: #005b9a;
|
156 |
display: inline-block;
|
157 |
margin-left: 0;
|
158 |
line-height: 1;
|
159 |
outline: none;
|
160 |
+
font-weight: 500;
|
161 |
}
|
162 |
label.tab_label.first_label {
|
163 |
margin-left: 15px;
|
164 |
}
|
165 |
label.inner_tab_label {
|
166 |
text-decoration: none;
|
167 |
+
padding: 12px 12px 8px;
|
168 |
font-size: 14px;
|
169 |
+
color: #005b9a;
|
170 |
display: inline-block;
|
171 |
line-height: 1;
|
172 |
outline: none;
|
187 |
cursor: pointer;
|
188 |
}
|
189 |
input.tab_input:checked + label {
|
190 |
+
color: #212121;
|
|
|
|
|
191 |
}
|
192 |
input.inner_tab_input:checked + label{
|
193 |
+
color: #000;
|
|
|
194 |
}
|
195 |
input.inner_tab_input:checked + label.ts_tabs_label{
|
196 |
border-bottom: 3px solid #59c889;
|
320 |
height: 35px;
|
321 |
padding: 0 10px;
|
322 |
}
|
323 |
+
.wp-core-ui .btn_full{
|
324 |
+
width: 100%;
|
325 |
+
}
|
326 |
|
327 |
.wp-core-ui .btn_red {
|
328 |
background: red;
|
489 |
vertical-align: text-bottom;
|
490 |
}
|
491 |
.ast-shipment-status .icon-default:before{
|
492 |
+
background-image: url(icons/invalid.png);
|
493 |
}
|
494 |
.ast-shipment-status .icon-INVALID_TRACKING_NUM:before{
|
495 |
+
background-image: url(icons/invalid-tracking-number.png);
|
496 |
}
|
497 |
.ast-shipment-status .icon-wrong_shipping_provider:before{
|
498 |
+
background-image: url(icons/wrong-shipiing-provider.png);
|
499 |
}
|
500 |
.ast-shipment-status .icon-carrier_unsupported:before{
|
501 |
+
background-image: url(icons/carrier-unsupported.png);
|
502 |
}
|
503 |
.ast-shipment-status .icon-delivered:before{
|
504 |
+
background-image: url(icons/delivered.png);
|
505 |
}
|
506 |
.ast-shipment-status .icon-in_transit:before{
|
507 |
+
background-image: url(icons/in-transit.png);
|
508 |
}
|
509 |
.ast-shipment-status .icon-on_hold:before{
|
510 |
+
background-image: url(icons/on-hold.png);
|
511 |
}
|
512 |
.ast-shipment-status .icon-pre_transit:before{
|
513 |
+
background-image: url(icons/pre-transit.png);
|
514 |
}
|
515 |
.ast-shipment-status .icon-out_for_delivery:before{
|
516 |
+
background-image: url(icons/out-for-delivery.png);
|
517 |
}
|
518 |
.ast-shipment-status .icon-available_for_pickup:before{
|
519 |
+
background-image: url(icons/available-for-picup.png);
|
520 |
}
|
521 |
.ast-shipment-status .icon-return_to_sender:before{
|
522 |
+
background-image: url(icons/return-to-sender.png);
|
523 |
}
|
524 |
.ast-shipment-status .icon-failure:before{
|
525 |
+
background-image: url(icons/failure.png);
|
526 |
}
|
527 |
.ast-shipment-status .icon-exception:before{
|
528 |
+
background-image: url(icons/failure.png);
|
529 |
}
|
530 |
.ast-shipment-status .icon-unknown:before{
|
531 |
+
background-image: url(icons/unknown.png);
|
532 |
}
|
533 |
.ast-shipment-status .icon-pending_trackship:before{
|
534 |
+
background-image: url(icons/pending-trackship.png);
|
535 |
}
|
536 |
.ast-shipment-status .icon-invalid_user_key:before{
|
537 |
+
background-image: url(icons/invalid-user-key.png);
|
538 |
}
|
539 |
.wcast-shipment-status-list .wcast-shipment-est-delivery {
|
540 |
display: block;
|
1013 |
margin-top: 0;
|
1014 |
margin-bottom: 0px;
|
1015 |
}
|
1016 |
+
.custom_order_status_section {
|
1017 |
+
margin: 0 20px;
|
1018 |
+
}
|
1019 |
.woocommerce.zorem_admin_layout table.form-table.order-status-table{
|
1020 |
table-layout: auto;
|
1021 |
}
|
1065 |
margin: 10px 0 0;
|
1066 |
}
|
1067 |
.woocommerce.zorem_admin_layout table.form-table th{
|
1068 |
+
padding: 20px;
|
1069 |
}
|
1070 |
.woocommerce.zorem_admin_layout table.form-table.settings-form-table th.titledesc{
|
1071 |
padding: 5px 20px 0 0;
|
1105 |
padding: 10px 15px 15px;
|
1106 |
}
|
1107 |
.woocommerce.zorem_admin_layout table.form-table.order-status-table td{
|
1108 |
+
padding: 15px 0 15px 15px;
|
1109 |
}
|
1110 |
.woocommerce.zorem_admin_layout table.form-table.order-status-table td:first-child{
|
1111 |
+
padding:20px 15px 20px 0;
|
1112 |
width: 37px;
|
1113 |
}
|
1114 |
.woocommerce.zorem_admin_layout table.form-table th label{
|
1119 |
span.radio_section {
|
1120 |
margin-right: 10px;
|
1121 |
}
|
|
|
|
|
|
|
1122 |
span.multiple_checkbox {
|
1123 |
display: inline-block;
|
1124 |
line-height: 30px;
|
1139 |
margin: 0;
|
1140 |
}
|
1141 |
.settings_ul li> input[type=checkbox] {
|
1142 |
+
vertical-align: -webkit-baseline-middle;
|
1143 |
}
|
1144 |
.settings_ul>li{
|
1145 |
+
padding: 15px 0;
|
1146 |
border-bottom: 1px solid #e0e0e0;
|
1147 |
+
margin: 0 20px;
|
1148 |
+
min-height: 30px;
|
1149 |
+
line-height: 25px;
|
1150 |
position: relative;
|
1151 |
}
|
1152 |
.settings_ul li:last-child {
|
1172 |
vertical-align: top;
|
1173 |
width: 58%;
|
1174 |
}
|
1175 |
+
span.ast-tgl-btn-parent {
|
1176 |
+
vertical-align: middle;
|
1177 |
+
}
|
1178 |
.setting_ul_tgl_checkbox_label{
|
1179 |
+
margin-left: 15px;
|
1180 |
+
display: inline-block;
|
1181 |
+
vertical-align: middle;
|
1182 |
+
width: calc(100% - 100px);
|
1183 |
+
}
|
1184 |
+
.tgl_checkbox_desc {
|
1185 |
+
line-height: 18px;
|
1186 |
}
|
1187 |
.multiple_checkbox_label {
|
1188 |
display: inline-block;
|
1342 |
.woocommerce_page_woocommerce-advanced-shipment-tracking .zorem-layout .woocommerce-help-tip{
|
1343 |
color: #005B9A;
|
1344 |
font-size: 20px;
|
1345 |
+
height: 20px;
|
1346 |
+
vertical-align: middle;
|
1347 |
}
|
1348 |
.woocommerce_page_woocommerce-advanced-shipment-tracking #tiptip_content{
|
1349 |
background:#005B9A;
|
1439 |
border-radius: 3px;
|
1440 |
background: #fff;
|
1441 |
}
|
1442 |
+
.tabs_outer_form_table{
|
1443 |
+
border: 1px solid #e0e0e0;
|
1444 |
+
margin-top: 25px;
|
1445 |
+
border-radius: 3px;
|
1446 |
+
background: #fff;
|
1447 |
+
padding: 10px 15px 0;
|
1448 |
+
position: relative;
|
1449 |
+
}
|
1450 |
+
.tabs_inner_section {
|
1451 |
+
margin: 10px -15px 0;
|
1452 |
+
border-top: 1px solid #e0e0e0;
|
1453 |
+
display:none;
|
1454 |
+
}
|
1455 |
+
#tab_general_settings:checked ~ #content_general_settings,#tab_order_status:checked ~ #content_osm_settings{
|
1456 |
+
display: block !important;
|
1457 |
+
}
|
1458 |
+
.tabs_submit {
|
1459 |
+
position: absolute;
|
1460 |
+
top: 10px;
|
1461 |
+
right: 15px;
|
1462 |
+
}
|
1463 |
+
.tabs_submit .spinner{
|
1464 |
+
float:none;
|
1465 |
+
}
|
1466 |
#wc_ast_upload_csv_form .outer_form_table{
|
1467 |
margin-top: 20px;
|
1468 |
background-color: #fff;
|
1888 |
border: 1px solid #ccc;
|
1889 |
border-radius: 2em;
|
1890 |
}
|
1891 |
+
.ast-tgl-flat:disabled + .ast-tgl-btn {
|
1892 |
+
opacity: 0.5;
|
1893 |
+
}
|
1894 |
.ast-tgl-flat + .ast-tgl-btn:after {
|
1895 |
-webkit-transition: all .2s ease;
|
1896 |
transition: all .2s ease;
|
1984 |
padding: 16px 20px 16px 0;
|
1985 |
vertical-align: middle;
|
1986 |
}
|
1987 |
+
.ast-license-form .wp-list-table__row td.wp-list-table__ext-details {
|
|
|
|
|
1988 |
padding: 26px 20px;
|
1989 |
}
|
1990 |
.ast-license-form .wp-list-table__ext-actions {
|
1991 |
min-width: 150px;
|
1992 |
+
position: relative;
|
|
|
1993 |
text-align: right;
|
1994 |
+
position: relative;
|
1995 |
+
}
|
1996 |
+
.ast-license-form .wp-list-table__ext-actions .ast_licence_key{
|
1997 |
+
width: 100%;
|
1998 |
+
height: 35px;
|
1999 |
+
vertical-align: middle;
|
2000 |
+
border: 1px solid #e0e0e0;
|
2001 |
}
|
2002 |
.ast-license-form .wp-list-table__row td .wp-list-table__ext-title {
|
2003 |
color: #005b9a;
|
2004 |
+
font-size: 15px;
|
2005 |
line-height: 25px;
|
2006 |
+
font-weight: 600;
|
|
|
|
|
|
|
|
|
2007 |
}
|
2008 |
.ast-license-form .wp-list-table__row td .wp-list-table__ext-description {
|
2009 |
color: #333;
|
2010 |
+
padding-left: 0;
|
2011 |
+
display: inline-block;
|
2012 |
+
width: calc(100% - 100px);
|
2013 |
}
|
2014 |
.ast_admin_content .ast-license-form div.submit{
|
2015 |
margin: 0;
|
2016 |
+
display: inline-block;
|
2017 |
}
|
2018 |
.ast_admin_content .ast-license-form div.submit .pesan{
|
2019 |
display:none;
|
2020 |
+
margin-bottom: 0;
|
2021 |
+
position: absolute;
|
2022 |
+
width: 100%;
|
2023 |
+
left: 0;
|
2024 |
+
text-align: left;
|
2025 |
}
|
2026 |
.ast_admin_content .ast-license-form div.submit .button-primary{
|
2027 |
vertical-align: middle;
|
2120 |
.trackship_addon_section{
|
2121 |
background: #fff;
|
2122 |
border: 1px solid #e0e0e0;
|
2123 |
+
padding: 25px 20px;
|
2124 |
margin: 20px 0 0;
|
2125 |
}
|
2126 |
.ast_ts_landing_banner{
|
2139 |
overflow: hidden;
|
2140 |
text-overflow: ellipsis;
|
2141 |
}
|
2142 |
+
.ast_pro_features_list{
|
2143 |
+
margin: 20px 0;
|
2144 |
+
}
|
2145 |
+
.ast_pro_features_list li{
|
2146 |
+
margin: 0 0 10px;
|
2147 |
+
}
|
2148 |
+
.ast_pro_features_list li:before{
|
2149 |
+
content: "\f147";
|
2150 |
+
font-family: dashicons;
|
2151 |
+
font-size: 28px;
|
2152 |
+
vertical-align: middle;
|
2153 |
+
color: #59c889;
|
2154 |
+
padding-right: 5px;
|
2155 |
+
}
|
2156 |
+
|
2157 |
.multiple_select_container {
|
2158 |
display: inline-block;
|
2159 |
}
|
assets/css/front.css
CHANGED
@@ -127,35 +127,35 @@ form.order_track_form input {
|
|
127 |
height: 30px;
|
128 |
}
|
129 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.pre_transit:before{
|
130 |
-
content: url(icons/pre-transit-
|
131 |
left: 2%;
|
132 |
}
|
133 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.in_transit:before{
|
134 |
-
content: url(icons/in-transit-
|
135 |
left: 33%;
|
136 |
}
|
137 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.available_for_pickup:before{
|
138 |
-
content: url(icons/available-for-picup-
|
139 |
left: 64%;
|
140 |
}
|
141 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.on_hold:before{
|
142 |
-
content: url(icons/
|
143 |
left: 33%;
|
144 |
}
|
145 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.out_for_delivery:before{
|
146 |
-
content: url(icons/out-for-delivery-
|
147 |
left: 64%;
|
148 |
}
|
149 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.delivered:before{
|
150 |
-
content: url(icons/delivered-
|
151 |
right: 2.5%;
|
152 |
}
|
153 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.return_to_sender:before{
|
154 |
-
content: url(icons/return-to-sender-
|
155 |
left: 64%;
|
156 |
}
|
157 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.failure:before{
|
158 |
-
content: url(icons/failure-
|
159 |
left: 4%;
|
160 |
}
|
161 |
|
127 |
height: 30px;
|
128 |
}
|
129 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.pre_transit:before{
|
130 |
+
content: url(icons/pre-transit-o.png);
|
131 |
left: 2%;
|
132 |
}
|
133 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.in_transit:before{
|
134 |
+
content: url(icons/in-transit-o.png);
|
135 |
left: 33%;
|
136 |
}
|
137 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.available_for_pickup:before{
|
138 |
+
content: url(icons/available-for-picup-o.png);
|
139 |
left: 64%;
|
140 |
}
|
141 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.on_hold:before{
|
142 |
+
content: url(icons/on-hold-o.png);
|
143 |
left: 33%;
|
144 |
}
|
145 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.out_for_delivery:before{
|
146 |
+
content: url(icons/out-for-delivery-o.png);
|
147 |
left: 64%;
|
148 |
}
|
149 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.delivered:before{
|
150 |
+
content: url(icons/delivered-o.png);
|
151 |
right: 2.5%;
|
152 |
}
|
153 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.return_to_sender:before{
|
154 |
+
content: url(icons/return-to-sender-o.png);
|
155 |
left: 64%;
|
156 |
}
|
157 |
.tracker-progress-bar.tracking_layout_1 .progress .progress-bar.failure:before{
|
158 |
+
content: url(icons/failure-o.png);
|
159 |
left: 4%;
|
160 |
}
|
161 |
|
assets/css/icons/Branded-Tracking-Page.png
DELETED
Binary file
|
assets/css/icons/Delivered-512.png
DELETED
Binary file
|
assets/css/icons/Delivered-o.png
DELETED
Binary file
|
assets/css/icons/In-Transit--o.png
DELETED
Binary file
|
assets/css/icons/In-Transit-512.png
DELETED
Binary file
|
assets/css/icons/Late-Shipments-512.png
DELETED
Binary file
|
assets/css/icons/Multi-Carrier-Support.png
DELETED
Binary file
|
assets/css/icons/On-hold-v1.png
DELETED
Binary file
|
assets/css/icons/Out-for-Delivery-512.png
DELETED
Binary file
|
assets/css/icons/Pre-Transit-512.png
DELETED
Binary file
|
assets/css/icons/ast-icon.png
CHANGED
Binary file
|
assets/css/icons/available-for-picup-512.png
DELETED
Binary file
|
assets/css/icons/available-for-picup-o.png
CHANGED
Binary file
|
assets/css/icons/available-for-picup-v3.png
DELETED
Binary file
|
assets/css/icons/available-for-picup-v4.png
DELETED
Binary file
|
assets/css/icons/available-for-picup.png
ADDED
Binary file
|
assets/css/icons/cancel-o.png
DELETED
Binary file
|
assets/css/icons/cancel-v3.png
DELETED
Binary file
|
assets/css/icons/cancel-v4.png
DELETED
Binary file
|
assets/css/icons/carrier-unsupported-o.png
ADDED
Binary file
|
assets/css/icons/carrier-unsupported-v4.png
DELETED
Binary file
|
assets/css/icons/{carrier-unsupported-v3.png → carrier-unsupported.png}
RENAMED
File without changes
|
assets/css/icons/customer-support.png
DELETED
Binary file
|
assets/css/icons/delivered-grey-v3.png
DELETED
Binary file
|
assets/css/icons/delivered-o.png
ADDED
Binary file
|
assets/css/icons/delivered-v3.png
DELETED
Binary file
|
assets/css/icons/delivered-v4.png
DELETED
Binary file
|
assets/css/icons/delivered.png
ADDED
Binary file
|
assets/css/icons/delivery-email-2.png
DELETED
Binary file
|
assets/css/icons/failure-512.png
DELETED
Binary file
|
assets/css/icons/failure-o.png
CHANGED
Binary file
|
assets/css/icons/failure-v3.png
DELETED
Binary file
|
assets/css/icons/failure-v4.png
DELETED
Binary file
|
assets/css/icons/failure.png
ADDED
Binary file
|
assets/css/icons/in-transit-grey-v3.png
DELETED
Binary file
|
assets/css/icons/in-transit-o.png
ADDED
Binary file
|
assets/css/icons/in-transit-v3.png
DELETED
Binary file
|
assets/css/icons/in-transit-v4.png
DELETED
Binary file
|
assets/css/icons/in-transit.png
ADDED
Binary file
|
assets/css/icons/invalid-o.png
ADDED
Binary file
|
assets/css/icons/invalid-tracking-number-o.png
ADDED
Binary file
|
assets/css/icons/invalid-tracking-number.png
ADDED
Binary file
|
assets/css/icons/invalid-user-key-o.png
ADDED
Binary file
|
assets/css/icons/invalid-user-key-v4.png
DELETED
Binary file
|
assets/css/icons/{invalid-v3.png → invalid-user-key.png}
RENAMED
File without changes
|
assets/css/icons/invalid.png
ADDED
Binary file
|
assets/css/icons/label_cancelled-o.png
ADDED
Binary file
|
assets/css/icons/label_cancelled.png
ADDED
Binary file
|
assets/css/icons/late-shipment-v3.png
DELETED
Binary file
|
assets/css/icons/on-hold-o.png
ADDED
Binary file
|
assets/css/icons/{On-hold-v3.png → on-hold.png}
RENAMED
File without changes
|
assets/css/icons/out-for-delivery-grey-v3.png
DELETED
Binary file
|
assets/css/icons/out-for-delivery-o.png
ADDED
Binary file
|
assets/css/icons/out-for-delivery-v3.png
DELETED
Binary file
|
assets/css/icons/out-for-delivery-v4.png
DELETED
Binary file
|
assets/css/icons/out-for-delivery.png
ADDED
Binary file
|
assets/css/icons/partial-shipped-icon.png
DELETED
Binary file
|
assets/css/icons/pending-trackship-o.png
ADDED
Binary file
|
assets/css/icons/pending-trackship-v4.png
DELETED
Binary file
|
assets/css/icons/pending-trackship.png
ADDED
Binary file
|
assets/css/icons/pre-transit-o.png
ADDED
Binary file
|
assets/css/icons/pre-transit-v3.png
DELETED
Binary file
|
assets/css/icons/pre-transit-v4.png
DELETED
Binary file
|
assets/css/icons/pre-transit.png
ADDED
Binary file
|
assets/css/icons/return-to-sender-512.png
DELETED
Binary file
|
assets/css/icons/return-to-sender-o.png
ADDED
Binary file
|
assets/css/icons/return-to-sender-v3.png
DELETED
Binary file
|
assets/css/icons/return-to-sender-v4.png
DELETED
Binary file
|
assets/css/icons/return-to-sender.png
ADDED
Binary file
|
assets/css/icons/shipped-o.png
DELETED
Binary file
|
assets/css/icons/unknown-o.png
ADDED
Binary file
|
assets/css/icons/unknown-v4.png
DELETED
Binary file
|
assets/css/icons/unknown.png
ADDED
Binary file
|
assets/css/icons/updated-tracking-icon.png
DELETED
Binary file
|
assets/css/icons/wrong-shipiing-provider-o.png
ADDED
Binary file
|
assets/css/icons/wrong-shipiing-provider.png
ADDED
Binary file
|
assets/css/trackship.css
CHANGED
@@ -5,11 +5,14 @@
|
|
5 |
padding: 30px;
|
6 |
margin-top: 30px;
|
7 |
text-align: center;
|
|
|
|
|
8 |
}
|
9 |
.ts_landing_header{
|
10 |
-
|
11 |
line-height: 28px;
|
12 |
-
|
|
|
13 |
}
|
14 |
.ts_landing_description{
|
15 |
font-size: 15px;
|
@@ -39,17 +42,24 @@
|
|
39 |
background: #fff;
|
40 |
cursor: pointer;
|
41 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
.trackship_admin_content section.inner_tab_section {
|
44 |
display: none;
|
45 |
padding: 0;
|
46 |
border-top: 1px solid #ddd;
|
47 |
}
|
48 |
-
.woocommerce.zorem_admin_layout table.form-table th, .woocommerce.zorem_admin_layout table.form-table td{
|
49 |
-
padding: 15px 25px 15px;
|
50 |
-
border-bottom: 1px solid #e0e0e0;
|
51 |
-
vertical-align: middle;
|
52 |
-
}
|
53 |
.woocommerce.zorem_admin_layout table.form-table th label {
|
54 |
font-weight: 500;
|
55 |
color: #444;
|
@@ -71,11 +81,8 @@
|
|
71 |
content: '';
|
72 |
clear: both;
|
73 |
}
|
74 |
-
|
75 |
-
|
76 |
-
padding: 12px 25px;
|
77 |
-
border-bottom: 1px solid #e0e0e0;
|
78 |
-
height: 40px;
|
79 |
}
|
80 |
.woocommerce.zorem_admin_layout .border_0 table.form-table.heading-table td{
|
81 |
padding: 0 0 5px;
|
@@ -158,22 +165,27 @@ ul.trackship_dashboard_ul li strong{
|
|
158 |
}
|
159 |
.trackship-notice{
|
160 |
background: #fff;
|
161 |
-
border: 1px solid #
|
162 |
-
|
163 |
-
|
|
|
164 |
}
|
165 |
.trackship-notice p{
|
166 |
margin: 0;
|
167 |
}
|
|
|
|
|
|
|
168 |
.menu_trackship_link{
|
169 |
text-decoration: none;
|
170 |
-
padding:
|
171 |
font-size: 14px;
|
172 |
color: #005b9a;
|
173 |
display: inline-block;
|
174 |
line-height: 1;
|
175 |
outline: none;
|
176 |
vertical-align: middle;
|
|
|
177 |
}
|
178 |
|
179 |
.post-type-shop_order .wp-list-table .column-shipment_status {
|
@@ -268,12 +280,14 @@ ul.wcast-shipment-status-list {
|
|
268 |
}
|
269 |
.woocommerce.zorem_admin_layout table.form-table.shipment-status-email-table td:first-child {
|
270 |
width: 240px;
|
|
|
271 |
}
|
272 |
span.shipment_status_toggle {
|
273 |
margin-right: 15px;
|
274 |
}
|
275 |
.woocommerce.zorem_admin_layout table.form-table.shipment-status-email-table td {
|
276 |
border-bottom: 1px solid #e0e0e0;
|
|
|
277 |
}
|
278 |
.shipment-status-email-table tr td.status-label-column {
|
279 |
width: 130px;
|
@@ -310,6 +324,9 @@ span.shipment_status_toggle {
|
|
310 |
.shipment-status-email-table .shipment-status-label.failed-attempt{
|
311 |
background: #CD2128;
|
312 |
}
|
|
|
|
|
|
|
313 |
.shipment-status-email-table .shipment-status-label.out-for-delivery{
|
314 |
background: #95CB65;
|
315 |
}
|
@@ -408,8 +425,14 @@ p.delivered_message {
|
|
408 |
height: 80px;
|
409 |
margin-bottom: 10px;
|
410 |
}
|
411 |
-
.zorem_admin_layout table.form-table.late-shipments-email-content-table tr
|
412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
}
|
414 |
.zorem_admin_layout table.form-table.late-shipments-email-content-table tr:last-child{
|
415 |
border-top: 1px solid #e0e0e0;
|
@@ -525,19 +548,10 @@ p.delivered_message {
|
|
525 |
.ts-widget-footer a{
|
526 |
color: #2196f3;
|
527 |
}
|
528 |
-
|
529 |
-
.tracking_page_select {
|
530 |
-
margin: 0 10px 0 20px;
|
531 |
-
}
|
532 |
.tracking_page_desc {
|
533 |
display: inline-block;
|
534 |
margin: 0;
|
535 |
}
|
536 |
-
.ts_customizer_btn{
|
537 |
-
position: absolute;
|
538 |
-
right: 25px;
|
539 |
-
bottom: 10px;
|
540 |
-
}
|
541 |
.disable_ts_btn{
|
542 |
background: transparent;
|
543 |
opacity: 0.7;
|
@@ -549,6 +563,19 @@ p.delivered_message {
|
|
549 |
.ast-tgl-flat:checked + .ast-tgl-btn.ast-tgl-btn-green:after {
|
550 |
background: #59c889;
|
551 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
|
553 |
.rtl.trackship_admin_settings #wpcontent {
|
554 |
padding-right: 0;
|
5 |
padding: 30px;
|
6 |
margin-top: 30px;
|
7 |
text-align: center;
|
8 |
+
max-width: 930px;
|
9 |
+
margin: 30px auto;
|
10 |
}
|
11 |
.ts_landing_header{
|
12 |
+
font-size: 26px;
|
13 |
line-height: 28px;
|
14 |
+
margin: 0;
|
15 |
+
font-weight: 700;
|
16 |
}
|
17 |
.ts_landing_description{
|
18 |
font-size: 15px;
|
42 |
background: #fff;
|
43 |
cursor: pointer;
|
44 |
}
|
45 |
+
#ts_dashboard:checked ~ #content_trackship_dashboard,#ts_settings:checked ~ #content_trackship_settings, #ts_tracking_page:checked ~ #content_tracking_page, #ts_notifications:checked ~ #content_status_notifications{
|
46 |
+
display: block !important;
|
47 |
+
}
|
48 |
+
.woocommerce_page_trackship-for-woocommerce #wpcontent {
|
49 |
+
padding-left: 0;
|
50 |
+
}
|
51 |
+
.ts_nav_div label.tab_label{
|
52 |
+
color: #59c889;
|
53 |
+
}
|
54 |
+
input.tab_input:checked + label {
|
55 |
+
color: #3c4758;
|
56 |
+
}
|
57 |
|
58 |
.trackship_admin_content section.inner_tab_section {
|
59 |
display: none;
|
60 |
padding: 0;
|
61 |
border-top: 1px solid #ddd;
|
62 |
}
|
|
|
|
|
|
|
|
|
|
|
63 |
.woocommerce.zorem_admin_layout table.form-table th label {
|
64 |
font-weight: 500;
|
65 |
color: #444;
|
81 |
content: '';
|
82 |
clear: both;
|
83 |
}
|
84 |
+
.woocommerce.zorem_admin_layout #trackship_late_shipments_form table.form-table.heading-table td{
|
85 |
+
padding: 12px 0;
|
|
|
|
|
|
|
86 |
}
|
87 |
.woocommerce.zorem_admin_layout .border_0 table.form-table.heading-table td{
|
88 |
padding: 0 0 5px;
|
165 |
}
|
166 |
.trackship-notice{
|
167 |
background: #fff;
|
168 |
+
border: 1px solid #59c889;
|
169 |
+
border-radius: 3px;
|
170 |
+
padding: 15px;
|
171 |
+
margin: 10px 0 -10px;
|
172 |
}
|
173 |
.trackship-notice p{
|
174 |
margin: 0;
|
175 |
}
|
176 |
+
.wp-core-ui .button-primary.bulk_shipment_status_button {
|
177 |
+
margin-top: 10px;
|
178 |
+
}
|
179 |
.menu_trackship_link{
|
180 |
text-decoration: none;
|
181 |
+
padding: 13px 15px 13px;
|
182 |
font-size: 14px;
|
183 |
color: #005b9a;
|
184 |
display: inline-block;
|
185 |
line-height: 1;
|
186 |
outline: none;
|
187 |
vertical-align: middle;
|
188 |
+
font-weight: 500;
|
189 |
}
|
190 |
|
191 |
.post-type-shop_order .wp-list-table .column-shipment_status {
|
280 |
}
|
281 |
.woocommerce.zorem_admin_layout table.form-table.shipment-status-email-table td:first-child {
|
282 |
width: 240px;
|
283 |
+
padding: 15px 0;
|
284 |
}
|
285 |
span.shipment_status_toggle {
|
286 |
margin-right: 15px;
|
287 |
}
|
288 |
.woocommerce.zorem_admin_layout table.form-table.shipment-status-email-table td {
|
289 |
border-bottom: 1px solid #e0e0e0;
|
290 |
+
padding: 15px 0 15px 15px;
|
291 |
}
|
292 |
.shipment-status-email-table tr td.status-label-column {
|
293 |
width: 130px;
|
324 |
.shipment-status-email-table .shipment-status-label.failed-attempt{
|
325 |
background: #CD2128;
|
326 |
}
|
327 |
+
.shipment-status-email-table .shipment-status-label.exception{
|
328 |
+
background: #CD2128;
|
329 |
+
}
|
330 |
.shipment-status-email-table .shipment-status-label.out-for-delivery{
|
331 |
background: #95CB65;
|
332 |
}
|
425 |
height: 80px;
|
426 |
margin-bottom: 10px;
|
427 |
}
|
428 |
+
.zorem_admin_layout table.form-table.late-shipments-email-content-table tr{
|
429 |
+
border-bottom: 1px solid #e0e0e0;
|
430 |
+
}
|
431 |
+
.zorem_admin_layout table.form-table.late-shipments-email-content-table tr:last-child{
|
432 |
+
border-bottom: 0;
|
433 |
+
}
|
434 |
+
.zorem_admin_layout table.form-table.late-shipments-email-content-table tr td,.zorem_admin_layout table.form-table.late-shipments-email-content-table tr th{
|
435 |
+
padding: 15px 0;
|
436 |
}
|
437 |
.zorem_admin_layout table.form-table.late-shipments-email-content-table tr:last-child{
|
438 |
border-top: 1px solid #e0e0e0;
|
548 |
.ts-widget-footer a{
|
549 |
color: #2196f3;
|
550 |
}
|
|
|
|
|
|
|
|
|
551 |
.tracking_page_desc {
|
552 |
display: inline-block;
|
553 |
margin: 0;
|
554 |
}
|
|
|
|
|
|
|
|
|
|
|
555 |
.disable_ts_btn{
|
556 |
background: transparent;
|
557 |
opacity: 0.7;
|
563 |
.ast-tgl-flat:checked + .ast-tgl-btn.ast-tgl-btn-green:after {
|
564 |
background: #59c889;
|
565 |
}
|
566 |
+
ul.settings_ul li label.left_label{
|
567 |
+
width: 22%;
|
568 |
+
display: inline-block;
|
569 |
+
}
|
570 |
+
.wp-core-ui .disconnect_ts{
|
571 |
+
color: #f44336;
|
572 |
+
margin: 0 20px;
|
573 |
+
}
|
574 |
+
.wp-core-ui .disconnect_ts:hover{
|
575 |
+
color: #f44336;
|
576 |
+
margin: 0 20px;
|
577 |
+
border: 1px solid #f44336;
|
578 |
+
}
|
579 |
|
580 |
.rtl.trackship_admin_settings #wpcontent {
|
581 |
padding-right: 0;
|
assets/images/AOSM-addons-icon.jpg
CHANGED
Binary file
|
assets/images/AOSM-banner.png
DELETED
Binary file
|
assets/images/CSV-Import-Tracking-info.png
DELETED
Binary file
|
assets/images/SMSWOO-sidebar-banner.png
DELETED
Binary file
|
assets/images/Tracking-Per-Item-addon.jpg
DELETED
Binary file
|
assets/images/addon-icon.png
DELETED
Binary file
|
assets/images/ajax-login-register-icon.png
DELETED
Binary file
|
assets/images/alp-icon.png
CHANGED
Binary file
|
assets/images/ast-addons-notice-image.jpg
DELETED
Binary file
|
assets/images/ast-logo.png
DELETED
Binary file
|
assets/images/ast-pro-banner.png
ADDED
Binary file
|
assets/images/ast.png
DELETED
Binary file
|
assets/images/cbr-banner.png
DELETED
Binary file
|
assets/images/cbr-icon.png
CHANGED
Binary file
|
assets/images/cev-icon.png
CHANGED
Binary file
|
assets/images/paypal-addon-banner.jpg
DELETED
Binary file
|
assets/images/paypal-addon-banner.png
CHANGED
Binary file
|
assets/images/readytoship-addon-banner.jpg
DELETED
Binary file
|
assets/images/shipstations-addon-banner.jpg
DELETED
Binary file
|
assets/images/sma-icon.png
DELETED
Binary file
|
assets/images/sms-woo-icon.png
DELETED
Binary file
|
assets/images/smswoo-icon.png
CHANGED
Binary file
|
assets/images/smswoo.png
DELETED
Binary file
|
assets/images/src-icon.png
DELETED
Binary file
|
assets/images/sre-banner.png
DELETED
Binary file
|
assets/images/sre-icon.png
CHANGED
Binary file
|
assets/images/t_layout_1.jpg
DELETED
Binary file
|
assets/images/t_layout_2.jpg
DELETED
Binary file
|
assets/images/tpi-addon-icon.jpg
DELETED
Binary file
|
assets/images/tpi-addon-icon.png
CHANGED
Binary file
|
assets/images/tpi-icon.png
DELETED
Binary file
|
assets/images/tpi-icon_license.png
DELETED
Binary file
|
assets/images/tracking-per-item-sidebar-banner.png
DELETED
Binary file
|
assets/images/trackship-ast-banner.png
CHANGED
Binary file
|
assets/images/trackship-banner.png
DELETED
Binary file
|
assets/images/trackship-sidebar-banner.png
DELETED
Binary file
|
assets/images/ts-100-supported-carriers.png
DELETED
Binary file
|
assets/images/ts-banner.jpg
DELETED
Binary file
|
assets/images/ts-home-better-customer-support.png
DELETED
Binary file
|
assets/images/ts-home-email-notifications.png
DELETED
Binary file
|
assets/images/ts-home-tracking-delivery-analytics.png
DELETED
Binary file
|
assets/images/ts-home-tracking-page.png
DELETED
Binary file
|
assets/images/ts-woocommerce-integration.png
DELETED
Binary file
|
assets/images/ts_bg.png
DELETED
Binary file
|
assets/images/wc-addon-banner.jpg
DELETED
Binary file
|
assets/images/zorem-logo.png
DELETED
Binary file
|
assets/js/admin.js
CHANGED
@@ -109,6 +109,7 @@ jQuery( function( $ ) {
|
|
109 |
type: 'POST',
|
110 |
success: function(response) {
|
111 |
$( '#advanced-shipment-tracking-form' ).unblock();
|
|
|
112 |
if ( response == 'reload' ) {
|
113 |
location.reload(true);
|
114 |
return false;
|
109 |
type: 'POST',
|
110 |
success: function(response) {
|
111 |
$( '#advanced-shipment-tracking-form' ).unblock();
|
112 |
+
|
113 |
if ( response == 'reload' ) {
|
114 |
location.reload(true);
|
115 |
return false;
|
assets/js/customizer-scripts.js
CHANGED
@@ -66,7 +66,10 @@ jQuery('#customize-footer-actions .preview-tablet').click(function(e) {
|
|
66 |
} else if(order_status == 'updated_tracking'){
|
67 |
url = wcast_customizer.updated_tracking_email_preview_url;
|
68 |
api.previewer.previewUrl.set( url );
|
69 |
-
}
|
|
|
|
|
|
|
70 |
}
|
71 |
} );
|
72 |
} );
|
@@ -101,6 +104,9 @@ jQuery('#customize-footer-actions .preview-tablet').click(function(e) {
|
|
101 |
} else if(shipment_status == 'failure'){
|
102 |
url = wcast_customizer.customer_failure_preview_url;
|
103 |
api.previewer.previewUrl.set( url );
|
|
|
|
|
|
|
104 |
}
|
105 |
}
|
106 |
} );
|
@@ -161,6 +167,9 @@ wp.customize( 'wcast_order_status_email_type', function( value ) {
|
|
161 |
} else if(wcast_order_status_email_type == 'updated_tracking'){
|
162 |
wp.customize.previewer.previewUrl(wcast_customizer.updated_tracking_email_preview_url);
|
163 |
wp.customize.previewer.refresh();
|
|
|
|
|
|
|
164 |
}
|
165 |
});
|
166 |
});
|
@@ -196,6 +205,9 @@ wp.customize( 'wcast_shipment_status_type', function( value ) {
|
|
196 |
} else if(wcast_shipment_status_type == 'failure'){
|
197 |
wp.customize.previewer.previewUrl(wcast_customizer.customer_failure_preview_url);
|
198 |
wp.customize.previewer.refresh();
|
|
|
|
|
|
|
199 |
}
|
200 |
});
|
201 |
});
|
66 |
} else if(order_status == 'updated_tracking'){
|
67 |
url = wcast_customizer.updated_tracking_email_preview_url;
|
68 |
api.previewer.previewUrl.set( url );
|
69 |
+
} else if(order_status == 'shipped'){
|
70 |
+
url = wcast_customizer.shipped_email_preview_url;
|
71 |
+
api.previewer.previewUrl.set( url );
|
72 |
+
}
|
73 |
}
|
74 |
} );
|
75 |
} );
|
104 |
} else if(shipment_status == 'failure'){
|
105 |
url = wcast_customizer.customer_failure_preview_url;
|
106 |
api.previewer.previewUrl.set( url );
|
107 |
+
} else if(shipment_status == 'exception'){
|
108 |
+
url = wcast_customizer.customer_exception_preview_url;
|
109 |
+
api.previewer.previewUrl.set( url );
|
110 |
}
|
111 |
}
|
112 |
} );
|
167 |
} else if(wcast_order_status_email_type == 'updated_tracking'){
|
168 |
wp.customize.previewer.previewUrl(wcast_customizer.updated_tracking_email_preview_url);
|
169 |
wp.customize.previewer.refresh();
|
170 |
+
} else if(wcast_order_status_email_type == 'shipped'){
|
171 |
+
wp.customize.previewer.previewUrl(wcast_customizer.shipped_email_preview_url);
|
172 |
+
wp.customize.previewer.refresh();
|
173 |
}
|
174 |
});
|
175 |
});
|
205 |
} else if(wcast_shipment_status_type == 'failure'){
|
206 |
wp.customize.previewer.previewUrl(wcast_customizer.customer_failure_preview_url);
|
207 |
wp.customize.previewer.refresh();
|
208 |
+
} else if(wcast_shipment_status_type == 'exception'){
|
209 |
+
wp.customize.previewer.previewUrl(wcast_customizer.customer_exception_preview_url);
|
210 |
+
wp.customize.previewer.refresh();
|
211 |
}
|
212 |
});
|
213 |
});
|
assets/js/shipping_row.js
CHANGED
@@ -673,6 +673,7 @@ jQuery(document).on("click", ".edit_provider", function(){
|
|
673 |
jQuery('.edit_provider_popup').removeClass('default_provider');
|
674 |
jQuery('.edit_provider_popup').removeClass('custom_provider');
|
675 |
jQuery('.edit_provider_popup').addClass(provider);
|
|
|
676 |
if(provider == 'custom_provider'){
|
677 |
jQuery('.edit_provider_popup .shipping_provider').val(provider_name);
|
678 |
jQuery('.edit_provider_popup .shipping_display_name').val(custom_provider_name);
|
@@ -683,9 +684,9 @@ jQuery(document).on("click", ".edit_provider", function(){
|
|
683 |
jQuery('.edit_provider_popup #provider_id').val(id);
|
684 |
jQuery(".edit_provider_popup .shipping_country").val(shipping_country);
|
685 |
jQuery('.edit_provider_popup #provider_type').val(provider);
|
686 |
-
jQuery('.edit_provider_popup .tracking_url').show();
|
687 |
-
jQuery(".edit_provider_popup .shipping_country").show();
|
688 |
-
jQuery(".edit_provider_popup .shipping_provider").show();
|
689 |
jQuery('.edit_provider_popup').show();
|
690 |
jQuery('.api_provider_name_container').hide();
|
691 |
jQuery('.reset_default_provider').hide();
|
@@ -721,9 +722,9 @@ jQuery(document).on("click", ".edit_provider", function(){
|
|
721 |
jQuery('.edit_provider_popup .thumb_id').val(custom_thumb_id);
|
722 |
jQuery('.edit_provider_popup #provider_id').val(id);
|
723 |
jQuery('.edit_provider_popup #provider_type').val(provider);
|
724 |
-
jQuery('.edit_provider_popup .tracking_url').hide();
|
725 |
-
jQuery(".edit_provider_popup .shipping_country").hide();
|
726 |
-
jQuery(".edit_provider_popup .shipping_provider").hide();
|
727 |
jQuery('.edit_provider_popup').show();
|
728 |
jQuery('.reset_default_provider').show();
|
729 |
jQuery('.custom_provider_instruction').hide();
|
@@ -1086,7 +1087,7 @@ jQuery(document).on("change", "#wc_ast_status_shipped", function(){
|
|
1086 |
jQuery(document).on("click", ".tab_input", function(){
|
1087 |
var tab = jQuery(this).data('tab');
|
1088 |
var label = jQuery(this).data('label');
|
1089 |
-
jQuery('.zorem-layout__header-breadcrumbs .header-breadcrumbs-last').text(label);
|
1090 |
var url = window.location.protocol + "//" + window.location.host + window.location.pathname+"?page=woocommerce-advanced-shipment-tracking&tab="+tab;
|
1091 |
window.history.pushState({path:url},'',url);
|
1092 |
});
|
@@ -1102,6 +1103,11 @@ jQuery(document).on("click", ".inner_tab_input", function(){
|
|
1102 |
var url = window.location.protocol + "//" + window.location.host + window.location.pathname+"?page=woocommerce-advanced-shipment-tracking&tab="+tab+"&addons="+addons;
|
1103 |
}
|
1104 |
|
|
|
|
|
|
|
|
|
|
|
1105 |
var type = jQuery(this).data('type');
|
1106 |
if( type !== undefined){
|
1107 |
var subtab = jQuery('input[name="ts_inner_tabs"]:checked').data('subtab');
|
@@ -1173,7 +1179,7 @@ jQuery('#wc_ast_status_partial_shipped_label_color').wpColorPicker({
|
|
1173 |
},
|
1174 |
});
|
1175 |
|
1176 |
-
jQuery('body').click( function(){
|
1177 |
if ( jQuery('.partial_shipped_row button.button.wp-color-result').hasClass( 'wp-picker-open' ) ) {
|
1178 |
save_custom_order_status();
|
1179 |
}
|
@@ -1181,7 +1187,7 @@ jQuery('body').click( function(){
|
|
1181 |
|
1182 |
jQuery('.partial_shipped_row button.button.wp-color-result').click( function(){
|
1183 |
if ( jQuery(this).hasClass( 'wp-picker-open' ) ) {}else{save_custom_order_status();}
|
1184 |
-
})
|
1185 |
|
1186 |
jQuery('#wc_ast_status_updated_tracking_label_color').wpColorPicker({
|
1187 |
change: function(e, ui) {
|
@@ -1191,12 +1197,12 @@ jQuery('#wc_ast_status_updated_tracking_label_color').wpColorPicker({
|
|
1191 |
});
|
1192 |
|
1193 |
jQuery('body').click( function(){
|
1194 |
-
if ( jQuery('.
|
1195 |
save_custom_order_status();
|
1196 |
}
|
1197 |
});
|
1198 |
|
1199 |
-
jQuery('.
|
1200 |
if ( jQuery(this).hasClass( 'wp-picker-open' ) ) {}else{save_custom_order_status();}
|
1201 |
});
|
1202 |
|
673 |
jQuery('.edit_provider_popup').removeClass('default_provider');
|
674 |
jQuery('.edit_provider_popup').removeClass('custom_provider');
|
675 |
jQuery('.edit_provider_popup').addClass(provider);
|
676 |
+
|
677 |
if(provider == 'custom_provider'){
|
678 |
jQuery('.edit_provider_popup .shipping_provider').val(provider_name);
|
679 |
jQuery('.edit_provider_popup .shipping_display_name').val(custom_provider_name);
|
684 |
jQuery('.edit_provider_popup #provider_id').val(id);
|
685 |
jQuery(".edit_provider_popup .shipping_country").val(shipping_country);
|
686 |
jQuery('.edit_provider_popup #provider_type').val(provider);
|
687 |
+
jQuery('.edit_provider_popup .tracking_url').parent('div').show();
|
688 |
+
jQuery(".edit_provider_popup .shipping_country").parent('div').show();
|
689 |
+
jQuery(".edit_provider_popup .shipping_provider").parent('div').show();
|
690 |
jQuery('.edit_provider_popup').show();
|
691 |
jQuery('.api_provider_name_container').hide();
|
692 |
jQuery('.reset_default_provider').hide();
|
722 |
jQuery('.edit_provider_popup .thumb_id').val(custom_thumb_id);
|
723 |
jQuery('.edit_provider_popup #provider_id').val(id);
|
724 |
jQuery('.edit_provider_popup #provider_type').val(provider);
|
725 |
+
jQuery('.edit_provider_popup .tracking_url').parent('div').hide();
|
726 |
+
jQuery(".edit_provider_popup .shipping_country").parent('div').hide();
|
727 |
+
jQuery(".edit_provider_popup .shipping_provider").parent('div').hide();
|
728 |
jQuery('.edit_provider_popup').show();
|
729 |
jQuery('.reset_default_provider').show();
|
730 |
jQuery('.custom_provider_instruction').hide();
|
1087 |
jQuery(document).on("click", ".tab_input", function(){
|
1088 |
var tab = jQuery(this).data('tab');
|
1089 |
var label = jQuery(this).data('label');
|
1090 |
+
//jQuery('.zorem-layout__header-breadcrumbs .header-breadcrumbs-last').text(label);
|
1091 |
var url = window.location.protocol + "//" + window.location.host + window.location.pathname+"?page=woocommerce-advanced-shipment-tracking&tab="+tab;
|
1092 |
window.history.pushState({path:url},'',url);
|
1093 |
});
|
1103 |
var url = window.location.protocol + "//" + window.location.host + window.location.pathname+"?page=woocommerce-advanced-shipment-tracking&tab="+tab+"&addons="+addons;
|
1104 |
}
|
1105 |
|
1106 |
+
var settings = jQuery(this).data('settings');
|
1107 |
+
if( settings !== undefined){
|
1108 |
+
var url = window.location.protocol + "//" + window.location.host + window.location.pathname+"?page=woocommerce-advanced-shipment-tracking&tab="+tab+"&settings="+settings;
|
1109 |
+
}
|
1110 |
+
|
1111 |
var type = jQuery(this).data('type');
|
1112 |
if( type !== undefined){
|
1113 |
var subtab = jQuery('input[name="ts_inner_tabs"]:checked').data('subtab');
|
1179 |
},
|
1180 |
});
|
1181 |
|
1182 |
+
/*jQuery('body').click( function(){
|
1183 |
if ( jQuery('.partial_shipped_row button.button.wp-color-result').hasClass( 'wp-picker-open' ) ) {
|
1184 |
save_custom_order_status();
|
1185 |
}
|
1187 |
|
1188 |
jQuery('.partial_shipped_row button.button.wp-color-result').click( function(){
|
1189 |
if ( jQuery(this).hasClass( 'wp-picker-open' ) ) {}else{save_custom_order_status();}
|
1190 |
+
});*/
|
1191 |
|
1192 |
jQuery('#wc_ast_status_updated_tracking_label_color').wpColorPicker({
|
1193 |
change: function(e, ui) {
|
1197 |
});
|
1198 |
|
1199 |
jQuery('body').click( function(){
|
1200 |
+
if ( jQuery('.order-status-table button.button.wp-color-result').hasClass( 'wp-picker-open' ) ) {
|
1201 |
save_custom_order_status();
|
1202 |
}
|
1203 |
});
|
1204 |
|
1205 |
+
jQuery('.order-status-table button.button.wp-color-result').click( function(){
|
1206 |
if ( jQuery(this).hasClass( 'wp-picker-open' ) ) {}else{save_custom_order_status();}
|
1207 |
});
|
1208 |
|
assets/js/trackship.js
CHANGED
@@ -135,13 +135,13 @@ jQuery( document ).ready(function() {
|
|
135 |
jQuery(document).on("click", ".tab_input", function(){
|
136 |
var tab = jQuery(this).data('tab');
|
137 |
var label = jQuery(this).data('label');
|
138 |
-
jQuery('.zorem-layout__header-breadcrumbs .header-breadcrumbs-last').text(label);
|
139 |
var url = window.location.protocol + "//" + window.location.host + window.location.pathname+"?page=trackship-for-woocommerce&tab="+tab;
|
140 |
window.history.pushState({path:url},'',url);
|
141 |
});
|
142 |
|
143 |
jQuery(document).on("click", ".bulk_shipment_status_button", function(){
|
144 |
-
jQuery("
|
145 |
message: null,
|
146 |
overlayCSS: {
|
147 |
background: "#fff",
|
@@ -156,10 +156,11 @@ jQuery(document).on("click", ".bulk_shipment_status_button", function(){
|
|
156 |
data: ajax_data,
|
157 |
type: 'POST',
|
158 |
success: function(response) {
|
159 |
-
jQuery("
|
|
|
160 |
jQuery( '.bulk_shipment_status_success' ).show();
|
161 |
jQuery( '.bulk_shipment_status_button' ).attr("disabled", true)
|
162 |
-
|
163 |
},
|
164 |
error: function(response) {
|
165 |
console.log(response);
|
@@ -168,59 +169,6 @@ jQuery(document).on("click", ".bulk_shipment_status_button", function(){
|
|
168 |
return false;
|
169 |
});
|
170 |
|
171 |
-
jQuery(document).on("click", ".bulk_shipment_status_button_for_empty_balance", function(){
|
172 |
-
jQuery("#content3").block({
|
173 |
-
message: null,
|
174 |
-
overlayCSS: {
|
175 |
-
background: "#fff",
|
176 |
-
opacity: .6
|
177 |
-
}
|
178 |
-
});
|
179 |
-
var ajax_data = {
|
180 |
-
action: 'bulk_shipment_status_for_empty_balance_from_settings',
|
181 |
-
};
|
182 |
-
jQuery.ajax({
|
183 |
-
url: ajaxurl,
|
184 |
-
data: ajax_data,
|
185 |
-
type: 'POST',
|
186 |
-
success: function(response) {
|
187 |
-
jQuery("#content3").unblock();
|
188 |
-
jQuery( '.bulk_shipment_status_button_for_empty_balance' ).after( "<div class='bulk_shipment_status_success'>Tracking info sent to Trackship for all Orders.</div>" );
|
189 |
-
jQuery( '.bulk_shipment_status_button_for_empty_balance' ).attr("disabled", true);
|
190 |
-
},
|
191 |
-
error: function(response) {
|
192 |
-
console.log(response);
|
193 |
-
}
|
194 |
-
});
|
195 |
-
return false;
|
196 |
-
});
|
197 |
-
|
198 |
-
jQuery(document).on("click", ".bulk_shipment_status_button_for_connection_issue", function(){
|
199 |
-
jQuery("#content3").block({
|
200 |
-
message: null,
|
201 |
-
overlayCSS: {
|
202 |
-
background: "#fff",
|
203 |
-
opacity: .6
|
204 |
-
}
|
205 |
-
});
|
206 |
-
var ajax_data = {
|
207 |
-
action: 'bulk_shipment_status_for_do_connection_from_settings',
|
208 |
-
};
|
209 |
-
jQuery.ajax({
|
210 |
-
url: ajaxurl,
|
211 |
-
data: ajax_data,
|
212 |
-
type: 'POST',
|
213 |
-
success: function(response) {
|
214 |
-
jQuery("#content3").unblock();
|
215 |
-
jQuery( '.bulk_shipment_status_button_for_connection_issue' ).after( "<div class='bulk_shipment_status_success'>Tracking info sent to Trackship for all Orders.</div>" );
|
216 |
-
jQuery( '.bulk_shipment_status_button_for_connection_issue' ).attr("disabled", true);
|
217 |
-
},
|
218 |
-
error: function(response) {
|
219 |
-
console.log(response);
|
220 |
-
}
|
221 |
-
});
|
222 |
-
return false;
|
223 |
-
});
|
224 |
jQuery(document).on("click", ".open_ts_video", function(){
|
225 |
jQuery('.ts_video_popup').show();
|
226 |
});
|
@@ -261,6 +209,7 @@ jQuery(document).on("change", ".shipment_status_toggle input", function(){
|
|
261 |
jQuery(this).closest('tr').addClass('enable');
|
262 |
jQuery(this).closest('tr').removeClass('disable');
|
263 |
} else{
|
|
|
264 |
jQuery(this).closest('tr').addClass('disable');
|
265 |
jQuery(this).closest('tr').removeClass('enable');
|
266 |
if( settings_data == 'late_shipments_email_settings') jQuery('.late-shipments-email-content-table').hide();
|
@@ -308,17 +257,7 @@ jQuery('.delivered_row button.button.wp-color-result').click( function(){
|
|
308 |
if ( jQuery(this).hasClass( 'wp-picker-open' ) ) {}else{save_automation_form();}
|
309 |
});
|
310 |
|
311 |
-
jQuery(document).on("change", ".ts_custom_order_color_select, #wc_ast_status_change_to_delivered", function(){
|
312 |
-
save_automation_form();
|
313 |
-
});
|
314 |
-
jQuery(document).on("change", ".ts_order_status_toggle", function(){
|
315 |
-
|
316 |
-
if(jQuery(this).prop("checked") == true){
|
317 |
-
jQuery('.status_change_to_delivered_tr').fadeIn();
|
318 |
-
} else{
|
319 |
-
jQuery('.status_change_to_delivered_tr').fadeOut();
|
320 |
-
}
|
321 |
-
|
322 |
save_automation_form();
|
323 |
});
|
324 |
|
@@ -350,32 +289,36 @@ function save_automation_form(){
|
|
350 |
return false;
|
351 |
}
|
352 |
|
353 |
-
jQuery(document).on("change", "#wc_ast_show_shipment_status_filter
|
354 |
save_trackship_form();
|
355 |
});
|
356 |
|
|
|
|
|
|
|
|
|
357 |
jQuery(document).on( "input", "#wc_ast_trackship_other_page", function(){
|
358 |
-
|
359 |
});
|
360 |
|
361 |
jQuery(document).on("change", "#wc_ast_use_tracking_page", function(){
|
362 |
if(jQuery(this).prop("checked") == true){
|
363 |
jQuery('.ts_customizer_btn').removeClass('disable_ts_btn');
|
364 |
-
jQuery(this).parent('li').
|
365 |
} else{
|
366 |
jQuery('.ts_customizer_btn').addClass('disable_ts_btn');
|
367 |
-
jQuery(this).parent('li').
|
368 |
}
|
369 |
-
|
370 |
});
|
371 |
|
372 |
jQuery( document ).ready(function() {
|
373 |
if(jQuery('#wc_ast_use_tracking_page').prop("checked") == true){
|
374 |
jQuery('.ts_customizer_btn').removeClass('disable_ts_btn');
|
375 |
-
jQuery('#wc_ast_use_tracking_page').parent('li').
|
376 |
} else{
|
377 |
jQuery('.ts_customizer_btn').addClass('disable_ts_btn');
|
378 |
-
jQuery('#wc_ast_use_tracking_page').parent('li').
|
379 |
}
|
380 |
});
|
381 |
|
@@ -394,9 +337,35 @@ function save_trackship_form(){
|
|
394 |
type: 'POST',
|
395 |
success: function(response) {
|
396 |
jQuery("#wc_ast_trackship_form").unblock();
|
397 |
-
jQuery("#
|
398 |
-
jQuery("#
|
399 |
-
setTimeout(function(){ jQuery("#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
},
|
401 |
error: function(response) {
|
402 |
console.log(response);
|
135 |
jQuery(document).on("click", ".tab_input", function(){
|
136 |
var tab = jQuery(this).data('tab');
|
137 |
var label = jQuery(this).data('label');
|
138 |
+
//jQuery('.zorem-layout__header-breadcrumbs .header-breadcrumbs-last').text(label);
|
139 |
var url = window.location.protocol + "//" + window.location.host + window.location.pathname+"?page=trackship-for-woocommerce&tab="+tab;
|
140 |
window.history.pushState({path:url},'',url);
|
141 |
});
|
142 |
|
143 |
jQuery(document).on("click", ".bulk_shipment_status_button", function(){
|
144 |
+
jQuery(".trackship-notice").block({
|
145 |
message: null,
|
146 |
overlayCSS: {
|
147 |
background: "#fff",
|
156 |
data: ajax_data,
|
157 |
type: 'POST',
|
158 |
success: function(response) {
|
159 |
+
jQuery(".trackship-notice").unblock();
|
160 |
+
jQuery('.bulk_shipment_status_button').closest(".trackship-notice").hide();
|
161 |
jQuery( '.bulk_shipment_status_success' ).show();
|
162 |
jQuery( '.bulk_shipment_status_button' ).attr("disabled", true)
|
163 |
+
|
164 |
},
|
165 |
error: function(response) {
|
166 |
console.log(response);
|
169 |
return false;
|
170 |
});
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
jQuery(document).on("click", ".open_ts_video", function(){
|
173 |
jQuery('.ts_video_popup').show();
|
174 |
});
|
209 |
jQuery(this).closest('tr').addClass('enable');
|
210 |
jQuery(this).closest('tr').removeClass('disable');
|
211 |
} else{
|
212 |
+
var wcast_enable_status_email = 0;
|
213 |
jQuery(this).closest('tr').addClass('disable');
|
214 |
jQuery(this).closest('tr').removeClass('enable');
|
215 |
if( settings_data == 'late_shipments_email_settings') jQuery('.late-shipments-email-content-table').hide();
|
257 |
if ( jQuery(this).hasClass( 'wp-picker-open' ) ) {}else{save_automation_form();}
|
258 |
});
|
259 |
|
260 |
+
jQuery(document).on("change", ".ts_custom_order_color_select, #wc_ast_status_change_to_delivered, .ts_order_status_toggle", function(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
save_automation_form();
|
262 |
});
|
263 |
|
289 |
return false;
|
290 |
}
|
291 |
|
292 |
+
jQuery(document).on("change", "#wc_ast_show_shipment_status_filter", function(){
|
293 |
save_trackship_form();
|
294 |
});
|
295 |
|
296 |
+
jQuery(document).on("change", "#wc_ast_trackship_page_id", function(){
|
297 |
+
save_tracking_page_form();
|
298 |
+
});
|
299 |
+
|
300 |
jQuery(document).on( "input", "#wc_ast_trackship_other_page", function(){
|
301 |
+
save_tracking_page_form();
|
302 |
});
|
303 |
|
304 |
jQuery(document).on("change", "#wc_ast_use_tracking_page", function(){
|
305 |
if(jQuery(this).prop("checked") == true){
|
306 |
jQuery('.ts_customizer_btn').removeClass('disable_ts_btn');
|
307 |
+
jQuery(this).parent('li').nextAll('li').fadeIn();
|
308 |
} else{
|
309 |
jQuery('.ts_customizer_btn').addClass('disable_ts_btn');
|
310 |
+
jQuery(this).parent('li').nextAll('li').fadeOut();
|
311 |
}
|
312 |
+
save_tracking_page_form();
|
313 |
});
|
314 |
|
315 |
jQuery( document ).ready(function() {
|
316 |
if(jQuery('#wc_ast_use_tracking_page').prop("checked") == true){
|
317 |
jQuery('.ts_customizer_btn').removeClass('disable_ts_btn');
|
318 |
+
jQuery('#wc_ast_use_tracking_page').parent('li').nextAll('li').fadeIn();
|
319 |
} else{
|
320 |
jQuery('.ts_customizer_btn').addClass('disable_ts_btn');
|
321 |
+
jQuery('#wc_ast_use_tracking_page').parent('li').nextAll('li').fadeOut();
|
322 |
}
|
323 |
});
|
324 |
|
337 |
type: 'POST',
|
338 |
success: function(response) {
|
339 |
jQuery("#wc_ast_trackship_form").unblock();
|
340 |
+
jQuery("#trackship_settings_snackbar").addClass('show_snackbar');
|
341 |
+
jQuery("#trackship_settings_snackbar").text(trackship_script.i18n.data_saved);
|
342 |
+
setTimeout(function(){ jQuery("#trackship_settings_snackbar").removeClass('show_snackbar'); }, 3000);
|
343 |
+
},
|
344 |
+
error: function(response) {
|
345 |
+
console.log(response);
|
346 |
+
}
|
347 |
+
});
|
348 |
+
return false;
|
349 |
+
}
|
350 |
+
|
351 |
+
function save_tracking_page_form(){
|
352 |
+
jQuery("#trackship_tracking_page_form").block({
|
353 |
+
message: null,
|
354 |
+
overlayCSS: {
|
355 |
+
background: "#fff",
|
356 |
+
opacity: .6
|
357 |
+
}
|
358 |
+
});
|
359 |
+
var form = jQuery('#trackship_tracking_page_form');
|
360 |
+
jQuery.ajax({
|
361 |
+
url: ajaxurl,
|
362 |
+
data: form.serialize(),
|
363 |
+
type: 'POST',
|
364 |
+
success: function(response) {
|
365 |
+
jQuery("#trackship_tracking_page_form").unblock();
|
366 |
+
jQuery("#trackship_settings_snackbar").addClass('show_snackbar');
|
367 |
+
jQuery("#trackship_settings_snackbar").text(trackship_script.i18n.data_saved);
|
368 |
+
setTimeout(function(){ jQuery("#trackship_settings_snackbar").removeClass('show_snackbar'); }, 3000);
|
369 |
},
|
370 |
error: function(response) {
|
371 |
console.log(response);
|
includes/api/class-wc-advanced-shipment-tracking-rest-api-controller.php
CHANGED
@@ -534,7 +534,7 @@ class WC_Advanced_Shipment_Tracking_REST_API_Controller extends WC_REST_Controll
|
|
534 |
$data = array(
|
535 |
'tracking_id' => $tracking_item['tracking_id'],
|
536 |
'tracking_provider' => $tracking_item['formatted_tracking_provider'],
|
537 |
-
'tracking_link' => $tracking_item['
|
538 |
'tracking_number' => $tracking_item['tracking_number'],
|
539 |
'date_shipped' => $date_shipped,
|
540 |
);
|
534 |
$data = array(
|
535 |
'tracking_id' => $tracking_item['tracking_id'],
|
536 |
'tracking_provider' => $tracking_item['formatted_tracking_provider'],
|
537 |
+
'tracking_link' => $tracking_item['ast_tracking_link'],
|
538 |
'tracking_number' => $tracking_item['tracking_number'],
|
539 |
'date_shipped' => $date_shipped,
|
540 |
);
|
includes/class-wc-admin-notices.php
CHANGED
@@ -27,7 +27,7 @@ class WC_AST_Admin_Notices_Under_WC_Admin {
|
|
27 |
public static function get_instance() {
|
28 |
|
29 |
if ( null === self::$instance ) {
|
30 |
-
self::$instance = new self;
|
31 |
}
|
32 |
|
33 |
return self::$instance;
|
@@ -37,13 +37,14 @@ class WC_AST_Admin_Notices_Under_WC_Admin {
|
|
37 |
* init from parent mail class
|
38 |
*/
|
39 |
public function init(){
|
40 |
-
//add_action('init', array( $this, 'admin_notices_for_shippstation_tracking_add_on' ) );
|
41 |
-
//add_action('init', array( $this, 'admin_notices_for_wc_shipping_tracking_add_on' ) );
|
42 |
}
|
43 |
|
44 |
-
public function admin_notices_for_shippstation_tracking_add_on(){
|
45 |
|
46 |
-
if ( !is_plugin_active( 'woocommerce-shipstation-integration/woocommerce-shipstation.php' ) )
|
|
|
|
|
47 |
|
48 |
if ( ! class_exists( 'Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes' ) ) {
|
49 |
return;
|
@@ -51,7 +52,9 @@ class WC_AST_Admin_Notices_Under_WC_Admin {
|
|
51 |
|
52 |
$already_set = get_transient( 'shippstation_tracking_add_on_wc_admin' );
|
53 |
|
54 |
-
if(
|
|
|
|
|
55 |
|
56 |
set_transient( 'shippstation_tracking_add_on_wc_admin', 'yes' );
|
57 |
|
@@ -81,50 +84,7 @@ class WC_AST_Admin_Notices_Under_WC_Admin {
|
|
81 |
'settings', 'Get this add-on', 'https://www.zorem.com/product/shipstation-tracking-add-on/'
|
82 |
);
|
83 |
$note->save();
|
84 |
-
}
|
85 |
-
|
86 |
-
public function admin_notices_for_wc_shipping_tracking_add_on(){
|
87 |
-
|
88 |
-
if ( !is_plugin_active( 'woocommerce-services/woocommerce-services.php' ) )return;
|
89 |
-
|
90 |
-
if ( ! class_exists( 'Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes' ) ) {
|
91 |
-
return;
|
92 |
-
}
|
93 |
-
|
94 |
-
$already_set = get_transient( 'wc_shipping_tracking_add_on_wc_admin' );
|
95 |
-
|
96 |
-
if($already_set == 'yes')return;
|
97 |
-
|
98 |
-
set_transient( 'wc_shipping_tracking_add_on_wc_admin', 'yes' );
|
99 |
-
|
100 |
-
$note_name = 'wc_shipping_tracking_add_on';
|
101 |
-
$data_store = WC_Data_Store::load( 'admin-note' );
|
102 |
-
|
103 |
-
// Otherwise, add the note
|
104 |
-
$activated_time = current_time( 'timestamp', 0 );
|
105 |
-
$activated_time_formatted = date( 'F jS', $activated_time );
|
106 |
-
$note = new Automattic\WooCommerce\Admin\Notes\WC_Admin_Note();
|
107 |
-
$note->set_title( 'Auto-sync Tracking from WooCommerce Shipping to AST' );
|
108 |
-
$note->set_content( 'We noticed that you use the WooCommerce Shipping & Tax plugin and the Advanced Shipment Tracking (AST) plugins. You can use the WC Shipping Tracking add-on for AST to auto-sync the tracking numbers created by WC Shipping into the AST shipment tracking order meta!' );
|
109 |
-
$note->set_content_data( (object) array(
|
110 |
-
'getting_started' => true,
|
111 |
-
'activated' => $activated_time,
|
112 |
-
'activated_formatted' => $activated_time_formatted,
|
113 |
-
) );
|
114 |
-
$note->set_type( 'info' );
|
115 |
-
$note->set_layout('plain');
|
116 |
-
$note->set_image('');
|
117 |
-
$note->set_name( $note_name );
|
118 |
-
$note->set_source( 'WC Shipping Tracking Add-on' );
|
119 |
-
$note->set_layout('plain');
|
120 |
-
$note->set_image('');
|
121 |
-
// This example has two actions. A note can have 0 or 1 as well.
|
122 |
-
$note->add_action(
|
123 |
-
'settings', 'Get this add-on', 'https://www.zorem.com/product/wc-shipping-tracking-add-on/'
|
124 |
-
);
|
125 |
-
$note->save();
|
126 |
-
}
|
127 |
-
|
128 |
}
|
129 |
|
130 |
/**
|
27 |
public static function get_instance() {
|
28 |
|
29 |
if ( null === self::$instance ) {
|
30 |
+
self::$instance = new self();
|
31 |
}
|
32 |
|
33 |
return self::$instance;
|
37 |
* init from parent mail class
|
38 |
*/
|
39 |
public function init(){
|
40 |
+
//add_action('init', array( $this, 'admin_notices_for_shippstation_tracking_add_on' ) );
|
|
|
41 |
}
|
42 |
|
43 |
+
public function admin_notices_for_shippstation_tracking_add_on() {
|
44 |
|
45 |
+
if ( !is_plugin_active( 'woocommerce-shipstation-integration/woocommerce-shipstation.php' ) ) {
|
46 |
+
return;
|
47 |
+
}
|
48 |
|
49 |
if ( ! class_exists( 'Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes' ) ) {
|
50 |
return;
|
52 |
|
53 |
$already_set = get_transient( 'shippstation_tracking_add_on_wc_admin' );
|
54 |
|
55 |
+
if( 'yes' == $already_set ){
|
56 |
+
return;
|
57 |
+
}
|
58 |
|
59 |
set_transient( 'shippstation_tracking_add_on_wc_admin', 'yes' );
|
60 |
|
84 |
'settings', 'Get this add-on', 'https://www.zorem.com/product/shipstation-tracking-add-on/'
|
85 |
);
|
86 |
$note->save();
|
87 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
|
90 |
/**
|
includes/class-wc-advanced-shipment-tracking-admin-notice.php
CHANGED
@@ -27,7 +27,7 @@ class WC_Advanced_Shipment_Tracking_Admin_notice {
|
|
27 |
public static function get_instance() {
|
28 |
|
29 |
if ( null === self::$instance ) {
|
30 |
-
self::$instance = new self;
|
31 |
}
|
32 |
|
33 |
return self::$instance;
|
@@ -36,26 +36,24 @@ class WC_Advanced_Shipment_Tracking_Admin_notice {
|
|
36 |
/*
|
37 |
* init from parent mail class
|
38 |
*/
|
39 |
-
public function init(){
|
40 |
-
//add_action( 'ast_settings_admin_notice', array( $this, 'ast_compatibility_with_shipstation_notice' ) );
|
41 |
-
//add_action('admin_init', array( $this, 'ast_compatibility_with_shipstation_notice_ignore' ) );
|
42 |
-
//
|
43 |
-
//add_action( 'ast_settings_admin_notice', array( $this, 'ast_compatibility_with_wc_services_notice' ) );
|
44 |
-
//add_action('admin_init', array( $this, 'ast_compatibility_with_wc_services_notice_ignore' ) );
|
45 |
-
//
|
46 |
//add_action( 'ast_settings_admin_notice', array( $this, 'trackship_admin_notice' ) );
|
47 |
-
//add_action('admin_init', array( $this, 'trackship_admin_notice_ignore' ) );
|
48 |
}
|
49 |
|
50 |
/*
|
51 |
* Display admin notice on plugin install or update
|
52 |
*/
|
53 |
-
public function trackship_admin_notice(){
|
54 |
|
55 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
56 |
-
if($wc_ast_api_key)
|
|
|
|
|
57 |
|
58 |
-
if ( get_option('trackship_admin_notice_ignore') )
|
|
|
|
|
59 |
|
60 |
$dismissable_url = esc_url( add_query_arg( 'trackship-ignore-notice', 'true' ) );
|
61 |
?>
|
@@ -85,120 +83,21 @@ class WC_Advanced_Shipment_Tracking_Admin_notice {
|
|
85 |
}
|
86 |
</style>
|
87 |
<div class="notice updated notice-success trakcship-dismissable-notice">
|
88 |
-
<a href="<?php
|
89 |
<h3>Automate your post-shipping workflow!</h3>
|
90 |
<p>Get ready to for the Shopping Season, TrackShip fully integrates into your store admin, auto-tracks your orders, automates your fulfillment workflow and allows you to provide Superior Post-Purchase experience to your customers!</p>
|
91 |
<a class="button-primary ts_notice_btn" target="blank" href="https://trackship.info/my-account/?register=1">Start Your Free Trial</a>
|
92 |
-
<a class="button-primary ts_notice_btn" href="<?php
|
93 |
</div>
|
94 |
<?php
|
95 |
}
|
96 |
-
|
97 |
-
public function trackship_admin_notice_ignore(){
|
98 |
-
if (isset($_GET['trackship-ignore-notice'])) {
|
99 |
-
update_option( 'trackship_admin_notice_ignore', 'true' );
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
/*
|
104 |
-
* Display admin notice if WooCommerce Shipstation plugin is active
|
105 |
-
*/
|
106 |
-
public function ast_compatibility_with_shipstation_notice(){
|
107 |
-
|
108 |
-
if ( !is_plugin_active( 'woocommerce-shipstation-integration/woocommerce-shipstation.php' ) )return;
|
109 |
-
if ( get_option('ast_compatibility_with_shipstation_notice_ignore') ) return;
|
110 |
-
|
111 |
-
$dismissable_url = esc_url( add_query_arg( 'ast-shipstation-ignore-notice', 'true' ) );
|
112 |
-
?>
|
113 |
-
<style>
|
114 |
-
.wp-core-ui .notice.ast-dismissable-notice{
|
115 |
-
position: relative;
|
116 |
-
padding-right: 38px;
|
117 |
-
border-left-color: #005B9A;
|
118 |
-
}
|
119 |
-
.wp-core-ui .notice.ast-dismissable-notice h3{
|
120 |
-
margin-bottom: 5px;
|
121 |
-
}
|
122 |
-
.wp-core-ui .notice.ast-dismissable-notice a.notice-dismiss{
|
123 |
-
padding: 9px;
|
124 |
-
text-decoration: none;
|
125 |
-
}
|
126 |
-
.wp-core-ui .button-primary.btn_review_notice {
|
127 |
-
background: transparent;
|
128 |
-
color: #005b9a;
|
129 |
-
border-color: #74c2e1;
|
130 |
-
text-transform: uppercase;
|
131 |
-
padding: 0 11px;
|
132 |
-
font-size: 12px;
|
133 |
-
height: 30px;
|
134 |
-
line-height: 28px;
|
135 |
-
margin: 5px 0 15px;
|
136 |
-
}
|
137 |
-
</style>
|
138 |
-
<div class="notice updated notice-success ast-dismissable-notice">
|
139 |
-
<a href="<?php echo $dismissable_url; ?>" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a>
|
140 |
-
<h3>Auto-sync Tracking from ShipStation to AST</h3>
|
141 |
-
<p>We noticed that you use the ShipStation Integration plugin and the Advanced Shipment Tracking (AST) plugins. You can use the ShipStation tracking add-on for AST to auto-sync the tracking numbers created by ShipStation into the AST shipment tracking order meta!</p>
|
142 |
-
<a class="button-primary btn_review_notice" target="blank" href="https://www.zorem.com/product/shipstation-tracking-add-on/">Get this add-on</a>
|
143 |
-
<a class="button-primary btn_review_notice" href="<?php echo $dismissable_url; ?>">No Thanks</a>
|
144 |
-
</div>
|
145 |
-
<?php
|
146 |
-
}
|
147 |
|
148 |
/*
|
149 |
-
*
|
150 |
*/
|
151 |
-
public function
|
152 |
-
|
153 |
-
|
154 |
-
if ( get_option('ast_compatibility_with_wc_services_notice_ignore') ) return;
|
155 |
-
|
156 |
-
$dismissable_url = esc_url( add_query_arg( 'ast-wc-services-ignore-notice', 'true' ) );
|
157 |
-
?>
|
158 |
-
<style>
|
159 |
-
.wp-core-ui .notice.ast-dismissable-notice{
|
160 |
-
position: relative;
|
161 |
-
padding-right: 38px;
|
162 |
-
border-left-color: #005B9A;
|
163 |
-
}
|
164 |
-
.wp-core-ui .notice.ast-dismissable-notice h3{
|
165 |
-
margin-bottom: 5px;
|
166 |
-
}
|
167 |
-
.wp-core-ui .notice.ast-dismissable-notice a.notice-dismiss{
|
168 |
-
padding: 9px;
|
169 |
-
text-decoration: none;
|
170 |
-
}
|
171 |
-
.wp-core-ui .button-primary.btn_review_notice {
|
172 |
-
background: transparent;
|
173 |
-
color: #005b9a;
|
174 |
-
border-color: #74c2e1;
|
175 |
-
text-transform: uppercase;
|
176 |
-
padding: 0 11px;
|
177 |
-
font-size: 12px;
|
178 |
-
height: 30px;
|
179 |
-
line-height: 28px;
|
180 |
-
margin: 5px 0 15px;
|
181 |
-
}
|
182 |
-
</style>
|
183 |
-
<div class="notice updated notice-success ast-dismissable-notice">
|
184 |
-
<a href="<?php echo $dismissable_url; ?>" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a>
|
185 |
-
<h3>Auto-sync Tracking from WooCommerce Shipping to AST</h3>
|
186 |
-
<p>We noticed that you use the WooCommerce Shipping & Tax plugin and the Advanced Shipment Tracking (AST) plugins. You can use the WC Shipping Tracking add-on for AST to auto-sync the tracking numbers created by WC Shipping into the AST shipment tracking order meta!</p>
|
187 |
-
<a class="button-primary btn_review_notice" target="blank" href="https://www.zorem.com/product/wc-shipping-tracking-add-on/">Get this add-on</a>
|
188 |
-
<a class="button-primary btn_review_notice" href="<?php echo $dismissable_url; ?>">No Thanks</a>
|
189 |
-
</div>
|
190 |
-
<?php
|
191 |
-
}
|
192 |
-
|
193 |
-
public function ast_compatibility_with_shipstation_notice_ignore(){
|
194 |
-
if (isset($_GET['ast-shipstation-ignore-notice'])) {
|
195 |
-
update_option( 'ast_compatibility_with_shipstation_notice_ignore', 'true' );
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
public function ast_compatibility_with_wc_services_notice_ignore(){
|
200 |
-
if (isset($_GET['ast-wc-services-ignore-notice'])) {
|
201 |
-
update_option( 'ast_compatibility_with_wc_services_notice_ignore', 'true' );
|
202 |
}
|
203 |
-
}
|
204 |
}
|
27 |
public static function get_instance() {
|
28 |
|
29 |
if ( null === self::$instance ) {
|
30 |
+
self::$instance = new self();
|
31 |
}
|
32 |
|
33 |
return self::$instance;
|
36 |
/*
|
37 |
* init from parent mail class
|
38 |
*/
|
39 |
+
public function init() {
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
//add_action( 'ast_settings_admin_notice', array( $this, 'trackship_admin_notice' ) );
|
41 |
+
//add_action( 'admin_init', array( $this, 'trackship_admin_notice_ignore' ) );
|
42 |
}
|
43 |
|
44 |
/*
|
45 |
* Display admin notice on plugin install or update
|
46 |
*/
|
47 |
+
public function trackship_admin_notice() {
|
48 |
|
49 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
50 |
+
if ( $wc_ast_api_key ) {
|
51 |
+
return;
|
52 |
+
}
|
53 |
|
54 |
+
if ( get_option('trackship_admin_notice_ignore') ) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
|
58 |
$dismissable_url = esc_url( add_query_arg( 'trackship-ignore-notice', 'true' ) );
|
59 |
?>
|
83 |
}
|
84 |
</style>
|
85 |
<div class="notice updated notice-success trakcship-dismissable-notice">
|
86 |
+
<a href="<?php esc_html_e( $dismissable_url ); ?>" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a>
|
87 |
<h3>Automate your post-shipping workflow!</h3>
|
88 |
<p>Get ready to for the Shopping Season, TrackShip fully integrates into your store admin, auto-tracks your orders, automates your fulfillment workflow and allows you to provide Superior Post-Purchase experience to your customers!</p>
|
89 |
<a class="button-primary ts_notice_btn" target="blank" href="https://trackship.info/my-account/?register=1">Start Your Free Trial</a>
|
90 |
+
<a class="button-primary ts_notice_btn" href="<?php esc_html_e( $dismissable_url ); ?>">No Thanks</a>
|
91 |
</div>
|
92 |
<?php
|
93 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
/*
|
96 |
+
* Dismiss admin notice for trackship
|
97 |
*/
|
98 |
+
public function trackship_admin_notice_ignore() {
|
99 |
+
if ( isset( $_GET['trackship-ignore-notice'] ) ) {
|
100 |
+
update_option( 'trackship_admin_notice_ignore', 'true' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
+
}
|
103 |
}
|
includes/class-wc-advanced-shipment-tracking-admin.php
CHANGED
@@ -4,36 +4,30 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
}
|
5 |
|
6 |
class WC_Advanced_Shipment_Tracking_Admin {
|
7 |
-
|
8 |
-
var $item_code = 'ast_per_product';
|
9 |
-
var $store_url = 'https://www.zorem.com/';
|
10 |
-
var $license_status;
|
11 |
-
var $license_key;
|
12 |
-
var $license_email;
|
13 |
var $zorem_pluginlist;
|
14 |
|
15 |
/**
|
16 |
* Initialize the main plugin function
|
17 |
*/
|
18 |
-
public function __construct() {
|
19 |
-
|
20 |
-
$this->license_status = 'ast_product_license_status';
|
21 |
-
$this->license_key = 'ast_product_license_key';
|
22 |
-
$this->license_email = 'ast_product_license_email';
|
23 |
|
24 |
global $wpdb;
|
25 |
-
if( is_multisite() ){
|
|
|
26 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
27 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
28 |
}
|
|
|
29 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
30 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
31 |
-
$this->table = $main_blog_prefix.
|
32 |
} else{
|
33 |
-
$this->table = $wpdb->prefix.
|
34 |
}
|
35 |
-
|
36 |
-
|
|
|
37 |
}
|
38 |
|
39 |
}
|
@@ -53,7 +47,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
53 |
public static function get_instance() {
|
54 |
|
55 |
if ( null === self::$instance ) {
|
56 |
-
self::$instance = new self;
|
57 |
}
|
58 |
|
59 |
return self::$instance;
|
@@ -62,7 +56,8 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
62 |
/*
|
63 |
* init from parent mail class
|
64 |
*/
|
65 |
-
public function init(){
|
|
|
66 |
//cron_schedules
|
67 |
add_filter( 'cron_schedules', array( $this, 'add_cron_interval') );
|
68 |
|
@@ -70,15 +65,14 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
70 |
add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'filter_orders_by_tracking_number_query' ) );
|
71 |
|
72 |
// add bulk order filter for exported / non-exported orders
|
73 |
-
add_action( 'restrict_manage_posts', array( $this, 'filter_orders_by_shipping_provider')
|
74 |
add_filter( 'request', array( $this, 'filter_orders_by_shipping_provider_query' ) );
|
75 |
|
76 |
add_filter( 'woocommerce_email_title', array( $this, 'change_completed_woocommerce_email_title'), 10, 2 );
|
77 |
|
78 |
-
|
79 |
add_action( 'wp_ajax_wc_ast_upload_csv_form_update', array( $this, 'upload_tracking_csv_fun') );
|
80 |
|
81 |
-
add_action( 'admin_footer', array( $this, 'footer_function'),1 );
|
82 |
|
83 |
add_action( 'wp_ajax_update_email_preview_order', array( $this, 'update_email_preview_order_fun') );
|
84 |
|
@@ -106,33 +100,41 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
106 |
|
107 |
add_action( 'wp_ajax_update_shipment_status', array( $this, 'update_shipment_status_fun') );
|
108 |
|
109 |
-
add_action( 'wp_ajax_update_custom_order_status_email_display', array( $this, 'update_custom_order_status_email_display_fun') );
|
|
|
|
|
110 |
}
|
111 |
|
112 |
/*
|
113 |
* add_cron_interval
|
114 |
*/
|
115 |
-
function add_cron_interval( $schedules ){
|
|
|
116 |
$schedules['wc_ast_1hr'] = array(
|
117 |
'interval' => 60*60,//1 hour
|
118 |
'display' => esc_html__( 'Every one hour' ),
|
119 |
);
|
|
|
120 |
$schedules['wc_ast_6hr'] = array(
|
121 |
'interval' => 60*60*6,//6 hour
|
122 |
'display' => esc_html__( 'Every six hour' ),
|
123 |
);
|
|
|
124 |
$schedules['wc_ast_12hr'] = array(
|
125 |
'interval' => 60*60*12,//6 hour
|
126 |
'display' => esc_html__( 'Every twelve hour' ),
|
127 |
);
|
|
|
128 |
$schedules['wc_ast_1day'] = array(
|
129 |
'interval' => 60*60*24*1,//1 days
|
130 |
'display' => esc_html__( 'Every one day' ),
|
131 |
);
|
|
|
132 |
$schedules['wc_ast_2day'] = array(
|
133 |
'interval' => 60*60*24*2,//2 days
|
134 |
'display' => esc_html__( 'Every two day' ),
|
135 |
);
|
|
|
136 |
$schedules['wc_ast_7day'] = array(
|
137 |
'interval' => 60*60*24*7,//7 days
|
138 |
'display' => esc_html__( 'Every Seven day' ),
|
@@ -143,6 +145,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
143 |
'interval' => 2*60,//1 hour
|
144 |
'display' => esc_html__( 'Every two min' ),
|
145 |
);
|
|
|
146 |
return $schedules;
|
147 |
}
|
148 |
|
@@ -150,31 +153,33 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
150 |
* get shipped orders
|
151 |
*/
|
152 |
function get_shipped_orders() {
|
153 |
-
$range = get_option('wc_ast_api_date_range', 30 );
|
154 |
$args = array(
|
155 |
'status' => 'wc-completed',
|
156 |
'limit' => -1,
|
157 |
);
|
158 |
-
|
159 |
-
|
160 |
-
$
|
|
|
161 |
$args['date_completed'] = $start.'...'.$end;
|
162 |
}
|
163 |
|
164 |
-
return
|
165 |
}
|
166 |
|
167 |
/**
|
168 |
* Load admin styles.
|
169 |
*/
|
170 |
-
public function admin_styles($hook) {
|
171 |
|
172 |
-
if(!isset($_GET['page'])) {
|
173 |
return;
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
178 |
|
179 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
180 |
|
@@ -192,8 +197,8 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
192 |
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
193 |
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
194 |
|
195 |
-
wp_enqueue_script( 'selectWoo');
|
196 |
-
wp_enqueue_script( 'wc-enhanced-select');
|
197 |
|
198 |
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
|
199 |
wp_enqueue_style( 'woocommerce_admin_styles' );
|
@@ -201,27 +206,27 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
201 |
|
202 |
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip.min.js', array( 'jquery' ), WC_VERSION, true );
|
203 |
|
204 |
-
|
205 |
wp_enqueue_script( 'jquery-tiptip' );
|
206 |
wp_enqueue_script( 'jquery-blockui' );
|
207 |
wp_enqueue_script( 'wp-color-picker' );
|
208 |
wp_enqueue_script( 'jquery-ui-sortable' );
|
209 |
-
wp_enqueue_script('media-upload');
|
210 |
-
wp_enqueue_script('thickbox');
|
211 |
-
wp_enqueue_style('thickbox');
|
212 |
wp_enqueue_style( 'trackship_styles' );
|
213 |
|
214 |
-
wp_enqueue_script( 'ajax-queue', wc_advanced_shipment_tracking()->plugin_dir_url().'assets/js/jquery.ajax.queue.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version);
|
215 |
|
216 |
-
wp_enqueue_script( '
|
217 |
|
218 |
-
wp_enqueue_script( '
|
219 |
|
220 |
-
wp_enqueue_script( '
|
221 |
|
222 |
-
wp_enqueue_script( 'front-js', wc_advanced_shipment_tracking()->plugin_dir_url().'assets/js/front.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version );
|
223 |
|
224 |
wp_register_script( 'shipment_tracking_table_rows', wc_advanced_shipment_tracking()->plugin_dir_url().'assets/js/shipping_row.js' , array( 'jquery', 'wp-util' ), wc_advanced_shipment_tracking()->version );
|
|
|
225 |
wp_localize_script( 'shipment_tracking_table_rows', 'shipment_tracking_table_rows', array(
|
226 |
'i18n' => array(
|
227 |
'data_saved' => __( 'Data saved successfully.', 'woo-advanced-shipment-tracking' ),
|
@@ -241,78 +246,66 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
241 |
*/
|
242 |
public function register_woocommerce_menu() {
|
243 |
add_submenu_page( 'woocommerce', 'Shipment Tracking', __( 'Shipment Tracking', 'woo-advanced-shipment-tracking' ), 'manage_woocommerce', 'woocommerce-advanced-shipment-tracking', array( $this, 'woocommerce_advanced_shipment_tracking_page_callback' ) );
|
244 |
-
}
|
245 |
-
|
246 |
-
/*
|
247 |
-
* Sort by Country ascending
|
248 |
-
*/
|
249 |
-
public function sortByCountryAsc($a, $b) {
|
250 |
-
return strcmp($a->country, $b->country);
|
251 |
-
}
|
252 |
-
|
253 |
-
/*
|
254 |
-
* Sort by Country descending
|
255 |
-
*/
|
256 |
-
public function sortByCountryDesc($a, $b) {
|
257 |
-
return strcmp($b->country, $a->country);
|
258 |
-
}
|
259 |
|
260 |
/*
|
261 |
* callback for Shipment Tracking page
|
262 |
*/
|
263 |
-
public function woocommerce_advanced_shipment_tracking_page_callback(){
|
264 |
-
|
|
|
265 |
$WC_Countries = new WC_Countries();
|
266 |
-
$countries = $WC_Countries->get_countries();
|
267 |
|
268 |
-
|
269 |
-
$woo_shippment_table_name = $this->table;
|
270 |
-
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
271 |
|
272 |
-
foreach($default_shippment_providers as $key => $value){
|
273 |
-
$search
|
274 |
$replace = array('', '');
|
275 |
-
|
276 |
-
|
277 |
-
$
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
}
|
282 |
-
$checked = '';
|
283 |
-
if(isset($_GET['tab'])){
|
284 |
-
if($_GET['tab'] == 'settings'){
|
285 |
-
|
286 |
}
|
287 |
-
}
|
288 |
|
289 |
-
wp_enqueue_script( 'shipment_tracking_table_rows' );
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
|
|
|
|
|
|
294 |
<div class="zorem-layout__docs-panel">
|
295 |
-
<a class="ast-
|
296 |
</div>
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
301 |
<div class="ast_nav_div">
|
302 |
-
|
303 |
-
|
304 |
-
|
|
|
|
|
305 |
require_once( 'views/admin_options_shipping_provider.php' );
|
306 |
require_once( 'views/admin_options_settings.php' );
|
307 |
require_once( 'views/admin_options_bulk_upload.php' );
|
308 |
-
do_action('ast_paypal_settings_panel');
|
309 |
-
|
|
|
310 |
</div>
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
<div id="ast_settings_snackbar" class="ast_snackbar"><?php _e( 'Data saved successfully.', 'woo-advanced-shipment-tracking' )?></div>
|
315 |
-
|
316 |
<div id="" class="popupwrapper ts_video_popup" style="display:none;">
|
317 |
<div class="popuprow">
|
318 |
<div class="videoWrapper">
|
@@ -330,16 +323,15 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
330 |
<div class="popupclose"></div>
|
331 |
</div>
|
332 |
</div>
|
333 |
-
<?php
|
334 |
-
if(isset( $_GET['tab'] ) && $_GET['tab'] == 'trackship'){ ?>
|
335 |
-
<script>
|
336 |
-
jQuery("#tab3").trigger('click');
|
337 |
-
</script>
|
338 |
-
<?php }
|
339 |
-
}
|
340 |
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
343 |
$setting_data = array(
|
344 |
'tab2' => array(
|
345 |
'title' => __( 'Settings', 'woo-advanced-shipment-tracking' ),
|
@@ -350,6 +342,17 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
350 |
'name' => 'tabs',
|
351 |
'position' => 1,
|
352 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
'tab1' => array(
|
354 |
'title' => __( 'Shipping Providers', 'woo-advanced-shipment-tracking' ),
|
355 |
'show' => true,
|
@@ -366,368 +369,266 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
366 |
'data-tab' => 'bulk-upload',
|
367 |
'data-label' => __( 'CSV Import', 'woo-advanced-shipment-tracking' ),
|
368 |
'name' => 'tabs',
|
369 |
-
'position' =>
|
370 |
),
|
371 |
'tab6' => array(
|
372 |
-
'title' =>
|
373 |
'show' => true,
|
374 |
'class' => 'tab_label',
|
375 |
'data-tab' => 'addons',
|
376 |
-
'data-label' =>
|
377 |
'name' => 'tabs',
|
378 |
-
'position' =>
|
379 |
),
|
380 |
);
|
381 |
-
|
382 |
-
return $setting_data;
|
383 |
}
|
384 |
|
385 |
-
public function get_html_menu_tab( $arrays ){
|
386 |
-
$tab = isset( $_GET['tab'] ) ? sanitize_text_field($_GET['tab']) : 'settings';
|
387 |
-
if( $tab == 'license')$tab = 'addons';
|
388 |
-
foreach( (array)$arrays as $id => $array ){ ?>
|
389 |
-
<input class="tab_input" id="<?php echo $id?>" name="<?php echo $array['name']; ?>" type="radio" data-tab="<?php echo $array['data-tab']; ?>" data-label="<?php echo $array['data-label']; ?>" <?php if($tab == $array['data-tab']){ echo 'checked'; } ?> />
|
390 |
-
<label class="<?php echo $array['class']; ?>" for="<?php echo $id?>"><?php echo $array['title']; ?></label>
|
391 |
-
<?php /*}*/ }
|
392 |
-
}
|
393 |
/*
|
394 |
-
*
|
395 |
*/
|
396 |
-
public function
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
if(isset($array['disabled']) && $array['disabled'] == true){
|
443 |
-
$disabled = 'disabled';
|
444 |
-
$checked = '';
|
445 |
-
} else{
|
446 |
-
$disabled = '';
|
447 |
-
}
|
448 |
-
?>
|
449 |
-
<input type="hidden" name="<?php echo $id?>" value="0"/>
|
450 |
-
<input class="ast-tgl ast-tgl-flat" id="<?php echo $id?>" name="<?php echo $id?>" type="checkbox" <?php echo $checked ?> value="1"/>
|
451 |
-
<label class="ast-tgl-btn" for="<?php echo $id?>"></label>
|
452 |
-
<?php }
|
453 |
-
elseif( isset( $array['type'] ) && $array['type'] == 'multiple_checkbox' ){
|
454 |
-
foreach((array)$array['options'] as $key => $val ){
|
455 |
-
$multi_checkbox_data = get_option($id);
|
456 |
-
if(isset($multi_checkbox_data[$key]) && $multi_checkbox_data[$key] == 1){
|
457 |
-
$checked="checked";
|
458 |
-
} else{
|
459 |
-
$checked="";
|
460 |
-
} ?>
|
461 |
-
<span class=" multiple_checkbox <?php if(isset($val['class'])){ echo $val['class']; } ?>">
|
462 |
-
<label class="" for="<?php echo $key?>">
|
463 |
-
<input type="hidden" name="<?php echo $id?>[<?php echo $key?>]" value="0"/>
|
464 |
-
<input type="checkbox" name="<?php echo $id?>[<?php echo $key?>]" class="" <?php echo $checked; ?> value="1"/>
|
465 |
-
<span class="multiple_label"><?php echo $val['status']; ?></span>
|
466 |
-
</label>
|
467 |
-
</span>
|
468 |
-
<?php }
|
469 |
-
}
|
470 |
-
elseif( isset( $array['type'] ) && $array['type'] == 'inline_checkbox' ){
|
471 |
-
|
472 |
-
$checkbox_array = $array['checkbox_array'];
|
473 |
-
foreach($checkbox_array as $c_name => $c_label){
|
474 |
-
|
475 |
-
if(get_option($c_name)){
|
476 |
-
$checked = 'checked';
|
477 |
-
} else{
|
478 |
-
$checked = '';
|
479 |
-
} ?>
|
480 |
-
<p class="inline_checkbox">
|
481 |
-
<input type="hidden" name="<?php echo $c_name?>" value="0"/>
|
482 |
-
<input id="<?php echo $c_name?>" name="<?php echo $c_name?>" type="checkbox" <?php echo $checked ?> value="1"/>
|
483 |
-
<label for="<?php echo $c_name?>"><?php echo $c_label?></label>
|
484 |
-
</p>
|
485 |
-
<?php } }
|
486 |
-
elseif( isset( $array['type'] ) && $array['type'] == 'dropdown' ){
|
487 |
-
|
488 |
-
if( isset($array['multiple']) ){
|
489 |
-
$multiple = 'multiple';
|
490 |
-
$field_id = $array['multiple'];
|
491 |
-
} else {
|
492 |
-
$multiple = '';
|
493 |
-
$field_id = $id;
|
494 |
-
}
|
495 |
-
?>
|
496 |
-
<fieldset>
|
497 |
-
<select class="select select2" id="<?php echo $field_id?>" name="<?php echo $id?>" <?php echo $multiple;?>> <?php foreach((array)$array['options'] as $key => $val ){?>
|
498 |
-
<?php $selected = '';
|
499 |
-
if( isset($array['multiple']) ){
|
500 |
-
if (in_array($key, (array)$this->data->$field_id ))$selected = 'selected';
|
501 |
-
} else {
|
502 |
-
if( get_option($id) == (string)$key )$selected = 'selected';
|
503 |
-
} ?>
|
504 |
-
<option value="<?php echo $key?>" <?php echo $selected?> ><?php echo $val?></option>
|
505 |
-
<?php } ?>
|
506 |
-
</select>
|
507 |
-
</fieldset>
|
508 |
-
<?php } elseif( isset( $array['type'] ) && $array['type'] == 'radio' ){ ?>
|
509 |
-
<fieldset>
|
510 |
-
<?php foreach((array)$array['options'] as $key => $val ){
|
511 |
-
$selected = '';
|
512 |
-
if( get_option($id,$array['default']) == (string)$key )$selected = 'checked'; ?>
|
513 |
-
<span class="radio_section multiple_checkbox">
|
514 |
-
<label class="" for="<?php echo $id?>_<?php echo $key?>">
|
515 |
-
<input type="radio" id="<?php echo $id?>_<?php echo $key?>" name="<?php echo $id?>" class="<?php echo $id?>" value="<?php echo $key?>" <?php echo $selected?>/>
|
516 |
-
<span class=""><?php echo $val; ?></span>
|
517 |
-
</br>
|
518 |
-
</label>
|
519 |
-
</span>
|
520 |
-
<?php } ?>
|
521 |
-
</fieldset>
|
522 |
-
<?php } elseif( $array['type'] == 'key_field' ){ ?>
|
523 |
-
<fieldset>
|
524 |
-
<?php if($array['connected'] == true){ ?>
|
525 |
-
<a href="https://my.trackship.info/" target="_blank">
|
526 |
-
<span class="api_connected"><label><?php _e( 'Connected', 'woo-advanced-shipment-tracking' ); ?></label><span class="dashicons dashicons-yes"></span></span></a>
|
527 |
-
<?php } ?>
|
528 |
-
</fieldset>
|
529 |
-
<?php }
|
530 |
-
elseif( $array['type'] == 'label' ){ ?>
|
531 |
-
<fieldset>
|
532 |
-
<label><?php echo $array['value']; ?></label>
|
533 |
-
</fieldset>
|
534 |
-
<?php }
|
535 |
-
elseif( $array['type'] == 'tooltip_button' ){ ?>
|
536 |
-
<fieldset>
|
537 |
-
<a href="<?php echo $array['link']; ?>" class="button-primary" target="<?php echo $array['target'];?>"><?php echo $array['link_label'];?></a>
|
538 |
-
</fieldset>
|
539 |
-
<?php }
|
540 |
-
elseif( $array['type'] == 'button' ){ ?>
|
541 |
-
<fieldset>
|
542 |
-
<button class="button-primary btn_green2 <?php echo $array['button_class'];?>" <?php if($array['disable'] == 1){ echo 'disabled'; }?>><?php echo $array['label'];?></button>
|
543 |
-
</fieldset>
|
544 |
-
<?php }
|
545 |
-
else { ?>
|
546 |
-
|
547 |
-
<fieldset>
|
548 |
-
<input class="input-text regular-input " type="text" name="<?php echo $id?>" id="<?php echo $id?>" style="" value="<?php echo get_option($id)?>" placeholder="<?php if(!empty($array['placeholder'])){echo $array['placeholder'];} ?>">
|
549 |
-
</fieldset>
|
550 |
-
<?php } ?>
|
551 |
-
|
552 |
-
</td>
|
553 |
-
</tr>
|
554 |
-
<?php } } ?>
|
555 |
-
</tbody>
|
556 |
-
</table>
|
557 |
-
<?php }
|
558 |
|
559 |
/*
|
560 |
-
* get html of fields
|
561 |
*/
|
562 |
-
public function get_html_ul( $arrays ){
|
563 |
-
|
564 |
-
|
|
|
|
|
565 |
|
566 |
-
if($array['show']){
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
$checked = '';
|
572 |
-
}
|
573 |
-
?>
|
574 |
<li>
|
575 |
-
<input type="hidden" name="<?php
|
576 |
-
<input class="" id="<?php
|
577 |
|
578 |
-
<label class="setting_ul_checkbox_label"><?php
|
579 |
-
<?php if( isset($array['tooltip']) ){?>
|
580 |
-
<span class="woocommerce-help-tip tipTip" title="<?php
|
581 |
<?php } ?>
|
582 |
</label>
|
583 |
</li>
|
584 |
-
<?php
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
if( isset($array['tgl_color']) ){
|
592 |
-
$tgl_class = 'ast-tgl-btn-green';
|
593 |
-
} ?>
|
594 |
<li>
|
595 |
-
<
|
596 |
-
|
597 |
-
|
|
|
|
|
598 |
|
599 |
-
<
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
<?php } ?>
|
607 |
</li>
|
608 |
-
<?php
|
|
|
|
|
609 |
<li class="settings_radio_li">
|
610 |
-
<label><strong><?php
|
611 |
-
<?php if( isset($array['tooltip']) ){?>
|
612 |
-
<span class="woocommerce-help-tip tipTip" title="<?php
|
613 |
<?php } ?>
|
614 |
</label>
|
615 |
-
|
616 |
-
|
617 |
-
|
|
|
|
|
|
|
618 |
<span class="radio_section">
|
619 |
-
<label class="" for="<?php
|
620 |
-
<input type="radio" id="<?php
|
621 |
-
<span class=""><?php
|
622 |
-
</br>
|
623 |
</label>
|
624 |
</span>
|
625 |
-
<?php
|
|
|
|
|
626 |
</li>
|
627 |
-
<?php
|
|
|
|
|
628 |
<li class="multiple_select_li">
|
629 |
-
<label><?php
|
630 |
-
<?php if( isset($array['tooltip']) ){?>
|
631 |
-
<span class="woocommerce-help-tip tipTip" title="<?php
|
632 |
<?php } ?>
|
633 |
</label>
|
634 |
<div class="multiple_select_container">
|
635 |
-
<select multiple class="wc-enhanced-select" name="<?php
|
636 |
<?php
|
637 |
-
foreach((array)$array['options'] as $key => $val ){
|
638 |
-
$multi_checkbox_data = get_option($id);
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
<?php } ?>
|
646 |
</select>
|
647 |
</div>
|
648 |
</li>
|
649 |
-
<?php
|
|
|
|
|
650 |
<li>
|
651 |
<div class="multiple_checkbox_label">
|
652 |
-
<label for=""><strong><?php
|
653 |
-
<span class="multiple_checkbox_description"><?php
|
654 |
</div >
|
655 |
<div class="multiple_checkbox_parent">
|
656 |
-
<?php
|
657 |
-
|
|
|
658 |
$multi_checkbox_data = get_option($id);
|
659 |
-
|
660 |
-
|
661 |
-
} else{
|
662 |
-
$checked="";
|
663 |
-
}?>
|
664 |
<span class="multiple_checkbox">
|
665 |
<label class="" for="">
|
666 |
-
<input type="hidden" name="<?php
|
667 |
-
<input type="checkbox" name="<?php
|
668 |
-
<span class="multiple_label"><?php
|
669 |
</br>
|
670 |
</label>
|
671 |
</span>
|
672 |
<?php } ?>
|
673 |
</div>
|
674 |
</li>
|
675 |
-
<?php
|
|
|
|
|
676 |
<li>
|
677 |
-
<label><?php
|
678 |
-
<?php if( isset($array['tooltip']) ){?>
|
679 |
-
<span class="woocommerce-help-tip tipTip" title="<?php
|
680 |
<?php } ?>
|
681 |
</label>
|
682 |
-
|
|
|
683 |
<?php
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
<option <?php
|
|
|
|
|
|
|
|
|
688 |
</select>
|
689 |
-
|
690 |
-
|
|
|
691 |
</fieldset>
|
692 |
-
|
|
|
|
|
|
|
|
|
693 |
</li>
|
694 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
695 |
}
|
696 |
-
}
|
|
|
697 |
</ul>
|
698 |
-
<?php
|
699 |
-
|
700 |
-
/*
|
701 |
-
* return licence valid
|
702 |
-
* return licence status
|
703 |
-
* return licence key
|
704 |
-
* return licence email
|
705 |
-
*/
|
706 |
-
public function licence_valid() {
|
707 |
-
return get_option( $this->license_status, false);
|
708 |
-
}
|
709 |
-
public function get_license_status() {
|
710 |
-
return get_option( $this->license_status, false);
|
711 |
-
}
|
712 |
-
public function get_license_key() {
|
713 |
-
return get_option( $this->license_key, false);
|
714 |
-
}
|
715 |
-
public function get_license_email() {
|
716 |
-
return get_option( $this->license_email, false);
|
717 |
-
}
|
718 |
|
719 |
/*
|
720 |
* get settings tab array data
|
721 |
* return array
|
722 |
*/
|
723 |
-
function get_settings_data(){
|
724 |
|
725 |
$wc_ast_status_shipped = get_option('wc_ast_status_shipped',0);
|
726 |
-
|
|
|
727 |
$completed_order_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
|
728 |
$mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">shipped</span>"', 'woo-advanced-shipment-tracking' );
|
729 |
$mark_as_shipped_tooltip = __( "This means that the 'mark as <span class='shipped_label'>shipped</span>' will be selected by default when adding tracking info to orders.", 'woo-advanced-shipment-tracking' );
|
730 |
-
} else{
|
731 |
$completed_order_label = __( 'Completed', 'woocommerce' );
|
732 |
$mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">completed</span>"', 'woo-advanced-shipment-tracking' );
|
733 |
$mark_as_shipped_tooltip = __( "This means that the 'mark as <span class='shipped_label'>completed</span>' will be selected by default when adding tracking info to orders.", 'woo-advanced-shipment-tracking' );
|
@@ -749,11 +650,14 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
749 |
'wc-partial-shipped' => 'Partially Shipped',
|
750 |
'wc-updated-tracking' => 'Updated Tracking',
|
751 |
);
|
752 |
-
|
|
|
753 |
unset($all_order_status[$key]);
|
754 |
}
|
|
|
755 |
$custom_order_status = $all_order_status;
|
756 |
-
|
|
|
757 |
unset($custom_order_status[$key]);
|
758 |
$key = str_replace("wc-", "", $key);
|
759 |
$custom_order_status[$key] = array(
|
@@ -845,9 +749,8 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
845 |
),
|
846 |
);
|
847 |
|
848 |
-
$order_status_array = array_merge($order_status
|
849 |
-
|
850 |
-
$action_order_status_array = array_merge($actions_order_status,$custom_order_status);
|
851 |
|
852 |
$form_data = array(
|
853 |
'wc_ast_default_mark_shipped' => array(
|
@@ -899,17 +802,14 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
899 |
),
|
900 |
);
|
901 |
|
902 |
-
|
903 |
-
|
904 |
-
return $form_data;
|
905 |
-
|
906 |
}
|
907 |
|
908 |
/*
|
909 |
* get updated tracking status settings array data
|
910 |
* return array
|
911 |
*/
|
912 |
-
function get_updated_tracking_data(){
|
913 |
$form_data = array(
|
914 |
'wc_ast_status_updated_tracking' => array(
|
915 |
'type' => 'checkbox',
|
@@ -927,9 +827,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
927 |
'type' => 'dropdown',
|
928 |
'title' => __( 'Updated Tracking Label font color', '' ),
|
929 |
'options' => array(
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
),
|
934 |
'class' => 'updated_tracking_status_label_color_th',
|
935 |
'show' => true,
|
@@ -937,20 +837,19 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
937 |
'wcast_enable_updated_tracking_email' => array(
|
938 |
'type' => 'checkbox',
|
939 |
'title' => __( 'Enable the Updated Tracking order status email', '' ),
|
940 |
-
'title_link'=> "<a class='settings_edit' href='".
|
941 |
'class' => 'updated_tracking_status_label_color_th',
|
942 |
'show' => true,
|
943 |
),
|
944 |
);
|
945 |
return $form_data;
|
946 |
-
|
947 |
}
|
948 |
|
949 |
/*
|
950 |
* get Partially Shipped array data
|
951 |
* return array
|
952 |
*/
|
953 |
-
function get_partial_shipped_data(){
|
954 |
$form_data = array(
|
955 |
'wc_ast_status_partial_shipped' => array(
|
956 |
'type' => 'checkbox',
|
@@ -968,9 +867,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
968 |
'type' => 'dropdown',
|
969 |
'title' => __( 'Partially Shipped Label font color', '' ),
|
970 |
'options' => array(
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
),
|
975 |
'class' => 'partial_shipped_status_label_color_th',
|
976 |
'show' => true,
|
@@ -978,7 +877,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
978 |
'wcast_enable_partial_shipped_email' => array(
|
979 |
'type' => 'checkbox',
|
980 |
'title' => __( 'Enable the Partially Shipped order status email', '' ),
|
981 |
-
'title_link'=> "<a class='settings_edit' href='".
|
982 |
'class' => 'partial_shipped_status_label_color_th',
|
983 |
'show' => true,
|
984 |
),
|
@@ -987,36 +886,80 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
987 |
|
988 |
}
|
989 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
990 |
/*
|
991 |
* settings form save
|
992 |
*/
|
993 |
-
function wc_ast_settings_form_update_callback(){
|
994 |
|
995 |
if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_settings_form', 'wc_ast_settings_form_nonce' ) ) {
|
996 |
|
997 |
$data = $this->get_settings_data();
|
998 |
|
999 |
-
foreach( $data as $key => $val ){
|
1000 |
|
1001 |
-
if(isset($val['type']) && $val['type']
|
1002 |
|
1003 |
-
foreach( $val['options'] as $op_status => $op_data){
|
1004 |
$_POST[ $key ][$op_status] = 0;
|
1005 |
}
|
1006 |
-
|
|
|
1007 |
$_POST[ $key ][$status] = 1;
|
1008 |
-
}
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
|
|
|
|
|
|
1013 |
}
|
1014 |
}
|
1015 |
|
1016 |
-
if(isset($val['type']) && $val['type']
|
1017 |
-
foreach((array)$val['checkbox_array'] as $key1 => $val1){
|
1018 |
-
if(isset($_POST[ $key1 ])){
|
1019 |
-
update_option( $key1, wc_clean($_POST[ $key1 ]) );
|
1020 |
}
|
1021 |
}
|
1022 |
}
|
@@ -1027,80 +970,82 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1027 |
/**
|
1028 |
* Save custom order status - eanble/disable,color,font,email
|
1029 |
*/
|
1030 |
-
public function wc_ast_custom_order_status_form_update(){
|
|
|
1031 |
if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_order_status_form', 'wc_ast_order_status_form_nonce' ) ) {
|
1032 |
|
1033 |
-
update_option( 'wc_ast_status_shipped', wc_clean($_POST[ 'wc_ast_status_shipped' ]) );
|
1034 |
|
1035 |
$data = $this->get_partial_shipped_data();
|
1036 |
|
1037 |
-
foreach( $data as $key => $val ){
|
1038 |
|
1039 |
-
if(
|
1040 |
-
if(isset($_POST['wcast_enable_partial_shipped_email'])){
|
1041 |
|
1042 |
-
if($_POST['wcast_enable_partial_shipped_email']
|
1043 |
-
update_option( 'customizer_partial_shipped_order_settings_enabled',wc_clean($_POST['wcast_enable_partial_shipped_email']));
|
1044 |
$enabled = 'yes';
|
1045 |
-
} else{
|
1046 |
-
update_option( 'customizer_partial_shipped_order_settings_enabled','');
|
1047 |
$enabled = 'no';
|
1048 |
}
|
1049 |
|
1050 |
-
$wcast_enable_partial_shipped_email = get_option('woocommerce_customer_partial_shipped_order_settings');
|
1051 |
$wcast_enable_partial_shipped_email['enabled'] = $enabled;
|
1052 |
update_option( 'woocommerce_customer_partial_shipped_order_settings', $wcast_enable_partial_shipped_email );
|
1053 |
}
|
1054 |
}
|
1055 |
|
1056 |
-
if(isset($_POST[ $key ])){
|
1057 |
-
update_option( $key, wc_clean($_POST[ $key ]) );
|
1058 |
}
|
1059 |
}
|
1060 |
|
1061 |
$data = $this->get_updated_tracking_data();
|
1062 |
|
1063 |
-
foreach( $data as $key => $val ){
|
1064 |
|
1065 |
-
if(
|
1066 |
-
if(isset($_POST['wcast_enable_updated_tracking_email'])){
|
1067 |
-
|
1068 |
-
|
1069 |
-
update_option( 'customizer_updated_tracking_order_settings_enabled',wc_clean($_POST['wcast_enable_updated_tracking_email']));
|
1070 |
$enabled = 'yes';
|
1071 |
-
} else{
|
1072 |
-
update_option( 'customizer_updated_tracking_order_settings_enabled','');
|
1073 |
$enabled = 'no';
|
1074 |
}
|
1075 |
|
1076 |
-
$wcast_enable_updated_tracking_email = get_option('woocommerce_customer_updated_tracking_order_settings');
|
1077 |
$wcast_enable_updated_tracking_email['enabled'] = $enabled;
|
1078 |
update_option( 'woocommerce_customer_updated_tracking_order_settings', $wcast_enable_updated_tracking_email );
|
1079 |
}
|
1080 |
}
|
1081 |
|
1082 |
-
if(isset($_POST[ $key ])){
|
1083 |
-
update_option( $key, wc_clean($_POST[ $key ]) );
|
1084 |
}
|
1085 |
}
|
1086 |
-
|
1087 |
-
|
|
|
|
|
1088 |
}
|
1089 |
}
|
1090 |
|
1091 |
/*
|
1092 |
* change style of delivered order label
|
1093 |
*/
|
1094 |
-
function footer_function(){
|
1095 |
if ( !is_plugin_active( 'woocommerce-order-status-manager/woocommerce-order-status-manager.php' ) ) {
|
1096 |
-
$bg_color = get_option('wc_ast_status_label_color','#59c889');
|
1097 |
-
$color = get_option('wc_ast_status_label_font_color','#fff');
|
1098 |
|
1099 |
-
$ps_bg_color = get_option('wc_ast_status_partial_shipped_label_color','#1e73be');
|
1100 |
-
$ps_color = get_option('wc_ast_status_partial_shipped_label_font_color','#fff');
|
1101 |
|
1102 |
-
$ut_bg_color = get_option('wc_ast_status_updated_tracking_label_color','#23a2dd');
|
1103 |
-
$ut_color = get_option('wc_ast_status_updated_tracking_label_font_color','#fff');
|
1104 |
?>
|
1105 |
<style>
|
1106 |
.order-status.status-delivered,.order-status-table .order-label.wc-delivered{
|
@@ -1123,76 +1068,74 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1123 |
/*
|
1124 |
* Ajax call for upload tracking details into order from bulk upload
|
1125 |
*/
|
1126 |
-
function upload_tracking_csv_fun(){
|
1127 |
-
$replace_tracking_info = $_POST['replace_tracking_info'];
|
1128 |
-
$date_format_for_csv_import = $_POST['date_format_for_csv_import'];
|
1129 |
-
update_option('date_format_for_csv_import',$date_format_for_csv_import);
|
1130 |
-
$order_id = $_POST['order_id'];
|
1131 |
-
|
1132 |
-
$wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
1133 |
-
$order_id = $wast->get_formated_order_id($order_id);
|
1134 |
|
1135 |
-
$
|
1136 |
-
$
|
1137 |
-
|
|
|
1138 |
|
1139 |
-
|
1140 |
-
|
1141 |
-
}
|
1142 |
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
|
1151 |
global $wpdb;
|
1152 |
|
1153 |
-
$sql = $wpdb->prepare( "SELECT COUNT(*) FROM $this->table WHERE api_provider_name = %s", $tracking_provider );
|
1154 |
$shippment_provider = $wpdb->get_var( $sql );
|
1155 |
|
1156 |
if( $shippment_provider == 0 ){
|
1157 |
-
$sql = "SELECT COUNT(*) FROM $this->table WHERE JSON_CONTAINS(api_provider_name, '[".'"'.$tracking_provider.'"'."]')";
|
1158 |
$shippment_provider = $wpdb->get_var( $sql );
|
1159 |
}
|
1160 |
|
1161 |
if( $shippment_provider == 0 ){
|
1162 |
-
$sql = $wpdb->prepare( "SELECT COUNT(*) FROM $this->table WHERE provider_name = %s", $tracking_provider );
|
1163 |
$shippment_provider = $wpdb->get_var( $sql );
|
1164 |
}
|
1165 |
|
1166 |
$order = wc_get_order($order_id);
|
|
|
1167 |
if ( $order === false ) {
|
1168 |
echo '<li class="invalid_order_id_error">Failed - Invalid Order Id - Order '.$_POST['order_id'].'</li>';exit;
|
1169 |
}
|
1170 |
|
1171 |
-
if($shippment_provider == 0){
|
1172 |
echo '<li class="shipping_provider_error">Failed - Invalid Shipping Provider - Order '.$_POST['order_id'].'</li>';exit;
|
1173 |
}
|
1174 |
-
|
|
|
1175 |
echo '<li class="tracking_number_error">Failed - Empty Tracking Number - Order '.$_POST['order_id'].'</li>';exit;
|
1176 |
}
|
1177 |
|
1178 |
-
if(empty($date_shipped)){
|
1179 |
echo '<li class="empty_date_shipped_error">Failed - Empty Date Shipped - Order '.$_POST['order_id'].'</li>';exit;
|
1180 |
}
|
1181 |
-
|
|
|
1182 |
echo '<li class="invalid_date_shipped_error">Failed - Invalid Date Shipped - Order '.$_POST['order_id'].'</li>';exit;
|
1183 |
}
|
1184 |
|
1185 |
-
if(
|
1186 |
$date_array = explode("-",$date_shipped);
|
1187 |
$date_shipped = $date_array[1].'-'.$date_array[0].'-'.$date_array[2];
|
1188 |
}
|
1189 |
|
1190 |
-
|
|
|
|
|
|
|
1191 |
$order = wc_get_order($order_id);
|
1192 |
|
1193 |
-
if($order){
|
1194 |
-
|
1195 |
-
|
1196 |
if ( count( $tracking_items ) > 0 ) {
|
1197 |
foreach ( $tracking_items as $key => $item ) {
|
1198 |
|
@@ -1200,10 +1143,10 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1200 |
|
1201 |
if ( class_exists( 'ast_woo_advanced_shipment_tracking_by_products' ) ) {
|
1202 |
$item_tracking_number = $item['tracking_number'];
|
1203 |
-
$tracking_exist = in_array($item_tracking_number, array_column($_POST['trackings'], 'tracking_number'));
|
1204 |
}
|
1205 |
|
1206 |
-
if($tracking_exist
|
1207 |
unset( $tracking_items[ $key ] );
|
1208 |
}
|
1209 |
}
|
@@ -1212,7 +1155,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1212 |
}
|
1213 |
}
|
1214 |
|
1215 |
-
if($shippment_provider && $tracking_number && $date_shipped){
|
1216 |
|
1217 |
$tracking_provider = $this->get_provider_slug_from_name( $tracking_provider );
|
1218 |
|
@@ -1223,100 +1166,65 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1223 |
'status_shipped' => wc_clean( $_POST['status_shipped'] ),
|
1224 |
);
|
1225 |
|
1226 |
-
if($sku
|
1227 |
-
$tracking_items = $wast->get_tracking_items( $order_id );
|
1228 |
|
1229 |
$products_list = array();
|
1230 |
|
1231 |
-
if($qty > 0){
|
|
|
1232 |
$product_id = wc_get_product_id_by_sku( $sku );
|
1233 |
|
1234 |
-
if($product_id){
|
1235 |
|
1236 |
$product_data = (object) array (
|
1237 |
'product' => $product_id,
|
1238 |
'qty' => $qty,
|
1239 |
);
|
1240 |
|
1241 |
-
array_push($products_list
|
1242 |
|
1243 |
$product_data_array = array();
|
1244 |
-
$product_data_array[$product_id] = $qty;
|
1245 |
|
1246 |
-
$status_shipped = (isset($_POST["status_shipped"])
|
1247 |
|
1248 |
$autocomplete_order_tpi = get_option('autocomplete_order_tpi',0);
|
1249 |
-
if($autocomplete_order_tpi
|
1250 |
$status_shipped = $this->autocomplete_order_after_adding_all_products( $order_id, $status_shipped, $products_list );
|
1251 |
$args['status_shipped'] = $status_shipped;
|
1252 |
}
|
1253 |
|
1254 |
if ( count( $tracking_items ) > 0 ) {
|
1255 |
foreach ( $tracking_items as $key => $item ) {
|
1256 |
-
if($item['tracking_number'] == $_POST['tracking_number']){
|
1257 |
|
1258 |
-
if(isset($item['products_list']) && !empty($item['products_list'])){
|
1259 |
|
1260 |
$product_list_array = array();
|
1261 |
-
foreach($item['products_list'] as $item_product_list){
|
1262 |
-
$product_list_array[$item_product_list->product] = $item_product_list->qty;
|
1263 |
}
|
1264 |
|
1265 |
$mearge_array = array();
|
1266 |
-
foreach (array_keys($product_data_array + $product_list_array) as $product) {
|
1267 |
-
$mearge_array[$product] = (int)(isset($product_data_array[$product]) ? $product_data_array[$product] : 0) + (int)(isset($product_list_array[$product]) ? $product_list_array[$product] : 0);
|
1268 |
}
|
1269 |
|
1270 |
-
foreach($mearge_array as $productid => $product_qty){
|
1271 |
$merge_product_data[] = (object) array (
|
1272 |
'product' => $productid,
|
1273 |
'qty' => $product_qty,
|
1274 |
);
|
1275 |
}
|
1276 |
|
1277 |
-
if(!empty($merge_product_data)){
|
1278 |
$tracking_items[ $key ]['products_list'] = $merge_product_data;
|
1279 |
$wast->save_tracking_items( $order_id, $tracking_items );
|
1280 |
|
1281 |
$order = new WC_Order( $order_id );
|
1282 |
|
1283 |
-
|
1284 |
-
|
1285 |
-
do_action("send_order_to_trackship", $order_id);
|
1286 |
-
} else{
|
1287 |
-
$order->update_status('completed');
|
1288 |
-
}
|
1289 |
-
}
|
1290 |
-
|
1291 |
-
if( $status_shipped == 2){
|
1292 |
-
$wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
|
1293 |
-
if($wc_ast_status_partial_shipped){
|
1294 |
-
|
1295 |
-
$previous_order_status = $order->get_status();
|
1296 |
-
|
1297 |
-
if('partial-shipped' == $previous_order_status){
|
1298 |
-
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
|
1299 |
-
}
|
1300 |
-
|
1301 |
-
$order->update_status('partial-shipped');
|
1302 |
-
do_action("send_order_to_trackship", $order_id);
|
1303 |
-
}
|
1304 |
-
}
|
1305 |
-
|
1306 |
-
if( $status_shipped == 3){
|
1307 |
-
$wc_ast_status_updated_tracking = get_option('wc_ast_status_updated_tracking');
|
1308 |
-
if($wc_ast_status_updated_tracking){
|
1309 |
-
|
1310 |
-
$previous_order_status = $order->get_status();
|
1311 |
-
|
1312 |
-
if('updated-tracking' == $previous_order_status){
|
1313 |
-
WC()->mailer()->emails['WC_Email_Customer_Updated_Tracking_Order']->trigger( $order_id, $order );
|
1314 |
-
}
|
1315 |
-
|
1316 |
-
$order->update_status('updated-tracking');
|
1317 |
-
do_action("send_order_to_trackship", $order_id);
|
1318 |
-
}
|
1319 |
-
}
|
1320 |
echo '<li class="success">Success - added tracking info to Order '.$_POST['order_id'].'</li>';
|
1321 |
exit;
|
1322 |
}
|
@@ -1330,105 +1238,171 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1330 |
);
|
1331 |
}
|
1332 |
}
|
1333 |
-
$args = array_merge($args
|
1334 |
}
|
1335 |
|
1336 |
$wast->add_tracking_item( $order_id, $args );
|
|
|
1337 |
echo '<li class="success">Success - added tracking info to Order '.$_POST['order_id'].'</li>';exit;
|
1338 |
} else{
|
1339 |
echo '<li class="invalid_tracking_data_error">Failed - Invalid Tracking Data</li>';exit;
|
1340 |
}
|
1341 |
}
|
1342 |
|
1343 |
-
|
|
|
|
|
|
|
1344 |
|
1345 |
$order = wc_get_order( $order_id );
|
1346 |
$items = $order->get_items();
|
1347 |
-
$items_count = count($items);
|
1348 |
|
1349 |
$added_products = $this->get_all_added_product_list_with_qty( $order_id );
|
1350 |
|
1351 |
-
|
1352 |
$new_products = array();
|
1353 |
-
//echo '<pre>';print_r($products_list);echo '</pre>';exit;
|
1354 |
-
foreach($products_list as $in_list){
|
1355 |
|
1356 |
-
|
1357 |
-
|
|
|
|
|
1358 |
} else{
|
1359 |
-
$new_products[$in_list->product] = $in_list->qty;
|
1360 |
}
|
1361 |
}
|
1362 |
|
1363 |
$total_products_data = array();
|
1364 |
|
1365 |
-
foreach (array_keys($new_products + $added_products) as $products) {
|
1366 |
-
$total_products_data[$products] = (isset($new_products[$products]) ? $new_products[$products] : 0) + (isset($added_products[$products]) ? $added_products[$products] : 0);
|
1367 |
}
|
1368 |
|
1369 |
$orders_products_data = array();
|
1370 |
-
foreach($items as $item){
|
1371 |
$checked = 0;
|
1372 |
$qty = $item->get_quantity();
|
1373 |
|
1374 |
-
if( $items_count
|
|
|
|
|
1375 |
|
1376 |
$variation_id = $item->get_variation_id();
|
1377 |
$product_id = $item->get_product_id();
|
1378 |
-
|
|
|
1379 |
$product_id = $variation_id;
|
1380 |
}
|
1381 |
-
|
|
|
1382 |
}
|
1383 |
|
1384 |
$change_status = 0;
|
1385 |
$autocomplete_order = true;
|
1386 |
|
1387 |
-
foreach($orders_products_data as $product_id => $qty){
|
1388 |
-
if(isset($total_products_data[$product_id])){
|
1389 |
-
if( $qty > $total_products_data[$product_id] ){
|
1390 |
$autocomplete_order = false;
|
1391 |
$change_status = 1;
|
1392 |
-
} else{
|
1393 |
$change_status = 1;
|
1394 |
}
|
1395 |
-
} else{
|
1396 |
$autocomplete_order = false;
|
1397 |
}
|
1398 |
}
|
1399 |
|
1400 |
-
if( $autocomplete_order &&
|
1401 |
$status_shipped = 1;
|
1402 |
}
|
1403 |
return $status_shipped;
|
1404 |
}
|
1405 |
|
1406 |
-
|
|
|
|
|
|
|
1407 |
|
1408 |
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
1409 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1410 |
|
1411 |
$product_list = array();
|
1412 |
|
1413 |
-
foreach($tracking_items as $tracking_item){
|
1414 |
-
if(isset($tracking_item['products_list'])){
|
1415 |
-
$product_list[] = $tracking_item['products_list'];
|
1416 |
}
|
1417 |
}
|
1418 |
|
1419 |
$all_list = array();
|
1420 |
-
foreach($product_list as $list){
|
1421 |
-
foreach($list as $in_list){
|
1422 |
-
if(isset($all_list[$in_list->product])){
|
1423 |
-
$all_list[$in_list->product] = (int)$all_list[$in_list->product] + (int)$in_list->qty;
|
1424 |
-
} else{
|
1425 |
-
$all_list[$in_list->product] = $in_list->qty;
|
1426 |
}
|
1427 |
}
|
1428 |
}
|
|
|
1429 |
return $all_list;
|
1430 |
}
|
1431 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1432 |
/**
|
1433 |
* Check if the value is a valid date
|
1434 |
*
|
@@ -1436,44 +1410,43 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1436 |
*
|
1437 |
* @return boolean
|
1438 |
*/
|
1439 |
-
function isDate($date, $format = 'd-m-Y')
|
1440 |
-
|
1441 |
-
if (!$date) {
|
1442 |
return false;
|
1443 |
}
|
1444 |
|
1445 |
-
$d = DateTime::createFromFormat($format, $date);
|
1446 |
// The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
|
1447 |
-
return $d && $d->format($format) === $date;
|
1448 |
}
|
1449 |
|
1450 |
/*
|
1451 |
* update preview order id in customizer
|
1452 |
*/
|
1453 |
-
public function update_email_preview_order_fun(){
|
1454 |
-
set_theme_mod('wcast_availableforpickup_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1455 |
-
set_theme_mod('wcast_returntosender_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1456 |
-
set_theme_mod('wcast_delivered_status_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1457 |
-
set_theme_mod('wcast_outfordelivery_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1458 |
-
set_theme_mod('wcast_intransit_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1459 |
-
set_theme_mod('wcast_onhold_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1460 |
-
set_theme_mod('wcast_pretransit_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1461 |
-
set_theme_mod('wcast_email_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1462 |
-
set_theme_mod('wcast_preview_order_id', wc_clean($_POST['wcast_preview_order_id']));
|
1463 |
exit;
|
1464 |
}
|
1465 |
|
1466 |
/*
|
1467 |
* Change completed order email title to Shipped Order
|
1468 |
*/
|
1469 |
-
public function change_completed_woocommerce_email_title($email_title, $email){
|
1470 |
-
$wc_ast_status_shipped = get_option('wc_ast_status_shipped',0);
|
1471 |
// Only on backend Woocommerce Settings "Emails" tab
|
1472 |
-
if($wc_ast_status_shipped
|
1473 |
-
if( isset($_GET['page']) && $_GET['page'] == 'wc-settings' && isset($_GET['tab']) && $_GET['tab'] == 'email' ) {
|
1474 |
-
switch ($email->id) {
|
1475 |
case 'customer_completed_order':
|
1476 |
-
$email_title = __(
|
1477 |
break;
|
1478 |
}
|
1479 |
}
|
@@ -1484,16 +1457,19 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1484 |
/*
|
1485 |
* Add action button in order list to change order status from completed to delivered
|
1486 |
*/
|
1487 |
-
public function add_delivered_order_status_actions_button($actions, $order){
|
1488 |
|
1489 |
wp_enqueue_style( 'ast_styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/admin.css', array(), wc_advanced_shipment_tracking()->version );
|
1490 |
wp_enqueue_script( 'woocommerce-advanced-shipment-tracking-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/admin.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version);
|
1491 |
|
1492 |
-
$wc_ast_status_delivered = get_option('wc_ast_status_delivered');
|
1493 |
-
|
1494 |
-
|
|
|
|
|
1495 |
// Get Order ID (compatibility all WC versions)
|
1496 |
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
|
|
|
1497 |
// Set the action button
|
1498 |
$actions['delivered'] = array(
|
1499 |
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=delivered&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
|
@@ -1507,23 +1483,25 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1507 |
$wc_ast_show_orders_actions = get_option( 'wc_ast_show_orders_actions' );
|
1508 |
$order_array = array();
|
1509 |
|
1510 |
-
foreach($wc_ast_show_orders_actions as $order_status => $value){
|
1511 |
-
if(
|
|
|
|
|
1512 |
}
|
1513 |
|
1514 |
-
if( $order->get_shipping_method() != 'Local pickup' && $order->get_shipping_method() != 'Local Pickup' ){
|
1515 |
if ( $order->has_status( $order_array ) ) {
|
1516 |
$actions['add_tracking'] = array(
|
1517 |
-
'url' => "#"
|
1518 |
'name' => __( 'Add Tracking', 'woo-advanced-shipment-tracking' ),
|
1519 |
'icon' => '<i class="fa fa-map-marker"> </i>',
|
1520 |
-
'action' =>
|
1521 |
);
|
1522 |
}
|
1523 |
}
|
1524 |
|
1525 |
-
$wc_ast_status_shipped = get_option('wc_ast_status_shipped');
|
1526 |
-
if($wc_ast_status_shipped){
|
1527 |
$actions['complete']['name'] = __( 'Mark as Shipped', 'woo-advanced-shipment-tracking' );
|
1528 |
}
|
1529 |
|
@@ -1533,13 +1511,14 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1533 |
/*
|
1534 |
* Add delivered action button in preview order list to change order status from completed to delivered
|
1535 |
*/
|
1536 |
-
public function additional_admin_order_preview_buttons_actions($actions, $order){
|
1537 |
-
|
1538 |
-
|
|
|
1539 |
// Below set your custom order statuses (key / label / allowed statuses) that needs a button
|
1540 |
$custom_statuses = array(
|
1541 |
'delivered' => array( // The key (slug without "wc-")
|
1542 |
-
'label' => __(
|
1543 |
'allowed' => array( 'completed'), // Button displayed for this statuses (slugs without "wc-")
|
1544 |
),
|
1545 |
);
|
@@ -1547,11 +1526,11 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1547 |
// Loop through your custom orders Statuses
|
1548 |
foreach ( $custom_statuses as $status_slug => $values ){
|
1549 |
if ( $order->has_status( $values['allowed'] ) ) {
|
1550 |
-
$actions['status']['group'] = __( 'Change status: ', 'woocommerce' );
|
1551 |
-
$actions['status']['actions'][$status_slug] = array(
|
1552 |
-
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status='
|
1553 |
'name' => $values['label'],
|
1554 |
-
'title' => __( 'Change order status to', 'woo-advanced-shipment-tracking' ) . ' ' . strtolower($values['label']),
|
1555 |
'action' => $status_slug,
|
1556 |
);
|
1557 |
}
|
@@ -1563,35 +1542,41 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1563 |
/*
|
1564 |
* filter shipping providers by stats
|
1565 |
*/
|
1566 |
-
public function filter_shipiing_provider_by_status_fun(){
|
1567 |
-
|
|
|
|
|
1568 |
global $wpdb;
|
1569 |
-
|
|
|
1570 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE display_in_order = 1" );
|
1571 |
}
|
1572 |
-
|
|
|
1573 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE display_in_order = 0" );
|
1574 |
}
|
1575 |
-
|
|
|
1576 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_default = 0" );
|
1577 |
}
|
1578 |
-
|
|
|
1579 |
$status = '';
|
1580 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1581 |
}
|
1582 |
-
|
1583 |
-
|
|
|
|
|
1584 |
}
|
1585 |
|
1586 |
/*
|
1587 |
* Get providers list html
|
1588 |
*/
|
1589 |
-
public function get_provider_html($default_shippment_providers
|
1590 |
$WC_Countries = new WC_Countries();
|
1591 |
$upload_dir = wp_upload_dir();
|
1592 |
-
$ast_directory = $upload_dir['baseurl'] . '/ast-shipping-providers/';
|
1593 |
-
$ast_base_directory = $upload_dir['basedir'] . '/ast-shipping-providers/';
|
1594 |
-
?>
|
1595 |
<div class="provider_list">
|
1596 |
<?php if($default_shippment_providers){
|
1597 |
if($status == 'custom'){
|
@@ -1604,87 +1589,115 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1604 |
<table class="wp-list-table widefat posts provder_table" id="shipping-provider-table">
|
1605 |
<thead>
|
1606 |
<tr>
|
1607 |
-
<th><?php
|
1608 |
-
<th><?php
|
1609 |
<?php do_action('ast_shipping_provider_column_after_api_name'); ?>
|
1610 |
-
<th><?php
|
1611 |
-
<th><?php
|
1612 |
</tr>
|
1613 |
</thead>
|
1614 |
<tbody>
|
1615 |
<?php
|
1616 |
-
foreach($default_shippment_providers as $d_s_p){
|
1617 |
-
|
|
|
|
|
1618 |
<td>
|
1619 |
<?php
|
1620 |
$custom_thumb_id = $d_s_p->custom_thumb_id;
|
1621 |
-
if( $d_s_p->shipping_default
|
1622 |
-
if($custom_thumb_id
|
1623 |
-
$image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
|
1624 |
$provider_image = $image_attributes[0];
|
1625 |
-
} else{
|
1626 |
-
$provider_image = $ast_directory.''.sanitize_title($d_s_p->provider_name).'.png?v='.wc_advanced_shipment_tracking()->version;
|
1627 |
}
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
$image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
|
1632 |
|
1633 |
-
if($custom_thumb_id
|
1634 |
-
<img class="provider-thumb" src="
|
1635 |
-
|
1636 |
-
<img class="provider-thumb" src="
|
1637 |
-
|
1638 |
} ?>
|
1639 |
|
1640 |
</td>
|
1641 |
<td>
|
1642 |
<span class="provider_name">
|
1643 |
-
<?php
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1649 |
$api_count = 1;
|
1650 |
}
|
1651 |
$api_text = __('API aliases','woo-advanced-shipment-tracking');
|
1652 |
-
|
1653 |
}
|
1654 |
?>
|
1655 |
</span>
|
1656 |
-
<span class="provider_country"
|
|
|
1657 |
$search = array('(US)', '(UK)');
|
1658 |
$replace = array('', '');
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
|
|
|
|
1664 |
</span>
|
1665 |
|
1666 |
-
<?php
|
1667 |
-
|
1668 |
-
|
|
|
|
|
|
|
1669 |
$edit_provider_class = apply_filters( 'edit_provider_class', 'edit_provider' );
|
1670 |
-
?>
|
1671 |
|
1672 |
-
|
1673 |
|
1674 |
-
|
|
|
|
|
1675 |
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
|
|
|
|
|
|
|
|
|
|
1679 |
</label>
|
1680 |
</td>
|
|
|
1681 |
<?php do_action('ast_shipping_provider_column_content_after_api_name', $d_s_p->provider_name); ?>
|
|
|
1682 |
<td class="provider_trackship_td">
|
1683 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
1684 |
</td>
|
|
|
1685 |
<td>
|
1686 |
-
<input class="ast-tgl ast-tgl-flat status_slide" id="list-switch-<?php
|
1687 |
-
<label class="ast-tgl-btn" for="list-switch-<?php
|
1688 |
</td>
|
1689 |
</tr>
|
1690 |
<?php } ?>
|
@@ -1694,13 +1707,19 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1694 |
<div class="shipping_provider_counter counter"></div>
|
1695 |
<div class="paging shipping_provider_paging"></div>
|
1696 |
</div>
|
1697 |
-
<?php } else{
|
1698 |
-
if(
|
1699 |
-
<p class="provider_message"><?php
|
1700 |
-
<a href="javaScript:void(0);" class="button-primary btn_ast2 btn_large add_custom_provider" id="add-custom"
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1704 |
</div>
|
1705 |
<?php
|
1706 |
}
|
@@ -1708,21 +1727,20 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1708 |
/*
|
1709 |
* Check if valid json
|
1710 |
*/
|
1711 |
-
function isJSON($string){
|
1712 |
-
return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
|
1713 |
}
|
1714 |
|
1715 |
/*
|
1716 |
* Update shipment provider status
|
1717 |
*/
|
1718 |
-
function update_shipment_status_fun(){
|
1719 |
global $wpdb;
|
1720 |
-
$
|
1721 |
-
$success = $wpdb->update($woo_shippment_table_name,
|
1722 |
array(
|
1723 |
-
"display_in_order" => wc_clean($_POST['checked']),
|
1724 |
),
|
1725 |
-
array('id' => wc_clean($_POST['id']))
|
1726 |
);
|
1727 |
exit;
|
1728 |
}
|
@@ -1730,11 +1748,11 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1730 |
/**
|
1731 |
* update default provider function
|
1732 |
*/
|
1733 |
-
function update_default_provider_fun(){
|
1734 |
-
if($_POST['checked']
|
1735 |
-
update_option(
|
1736 |
-
} else{
|
1737 |
-
update_option(
|
1738 |
}
|
1739 |
exit;
|
1740 |
}
|
@@ -1742,7 +1760,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1742 |
/**
|
1743 |
* Create slug from title
|
1744 |
*/
|
1745 |
-
public static function create_slug($text){
|
1746 |
// replace non letter or digits by -
|
1747 |
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
|
1748 |
|
@@ -1763,7 +1781,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1763 |
|
1764 |
$text = 'cp-'.$text;
|
1765 |
|
1766 |
-
if (empty($text)) {
|
1767 |
return '';
|
1768 |
}
|
1769 |
|
@@ -1773,33 +1791,33 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1773 |
/**
|
1774 |
* Add custom shipping provider function
|
1775 |
*/
|
1776 |
-
function add_custom_shipment_provider_fun(){
|
1777 |
|
1778 |
global $wpdb;
|
|
|
1779 |
|
1780 |
-
$
|
1781 |
-
|
1782 |
-
if($provider_slug == ''){
|
1783 |
-
$provider_slug = sanitize_text_field($_POST['shipping_provider']);
|
1784 |
}
|
1785 |
|
1786 |
$data_array = array(
|
1787 |
-
'shipping_country' => sanitize_text_field($_POST['shipping_country']),
|
1788 |
-
'provider_name' => sanitize_text_field($_POST['shipping_provider']),
|
1789 |
-
'custom_provider_name' => sanitize_text_field($_POST['shipping_display_name']),
|
1790 |
'ts_slug' => $provider_slug,
|
1791 |
-
'provider_url' => sanitize_text_field($_POST['tracking_url']),
|
1792 |
-
'custom_thumb_id' => sanitize_text_field($_POST['thumb_id']),
|
1793 |
'display_in_order' => 1,
|
1794 |
'shipping_default' => 0,
|
1795 |
);
|
1796 |
|
1797 |
-
$result = $wpdb->insert( $
|
1798 |
|
1799 |
$status = 'all';
|
1800 |
-
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table" );
|
1801 |
-
$html = $this->get_provider_html($default_shippment_providers
|
1802 |
-
echo $html;
|
|
|
1803 |
}
|
1804 |
|
1805 |
/*
|
@@ -1807,7 +1825,8 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1807 |
*/
|
1808 |
public function woocommerce_shipping_provider_delete(){
|
1809 |
|
1810 |
-
$provider_id = wc_clean($_POST['provider_id']);
|
|
|
1811 |
if ( ! empty( $provider_id ) ) {
|
1812 |
global $wpdb;
|
1813 |
$where = array(
|
@@ -1818,29 +1837,33 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1818 |
}
|
1819 |
$status = 'all';
|
1820 |
|
1821 |
-
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table" );
|
1822 |
-
$html = $this->get_provider_html($default_shippment_providers
|
1823 |
-
echo $html;
|
|
|
1824 |
}
|
1825 |
|
1826 |
/**
|
1827 |
* Get shipping provider details fun
|
1828 |
*/
|
1829 |
public function get_provider_details_fun(){
|
1830 |
-
$id = wc_clean($_POST['provider_id']);
|
1831 |
global $wpdb;
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
$image =
|
|
|
|
|
1837 |
}
|
1838 |
|
1839 |
$provider_name = $shippment_provider[0]->provider_name;
|
1840 |
$custom_provider_name = $shippment_provider[0]->custom_provider_name;
|
1841 |
$api_provider_name = $shippment_provider[0]->api_provider_name;
|
1842 |
|
1843 |
-
echo json_encode( array('id' => $shippment_provider[0]->id,'provider_name' => $provider_name,'custom_provider_name' => $custom_provider_name,'api_provider_name' => $api_provider_name,'provider_url' => $shippment_provider[0]->provider_url,'shipping_country' => $shippment_provider[0]->shipping_country,'custom_thumb_id' => $shippment_provider[0]->custom_thumb_id,'image' => $image) );
|
|
|
1844 |
}
|
1845 |
|
1846 |
/**
|
@@ -1850,27 +1873,27 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1850 |
|
1851 |
global $wpdb;
|
1852 |
|
1853 |
-
if (array_filter($_POST['api_provider_name'])
|
1854 |
-
$api_provider_name =
|
1855 |
-
} else{
|
1856 |
-
$api_provider_name = wc_clean(json_encode($_POST['api_provider_name']));
|
1857 |
}
|
1858 |
|
1859 |
$provider_type = $_POST['provider_type'];
|
1860 |
-
if(
|
1861 |
$data_array = array(
|
1862 |
-
'custom_provider_name' => sanitize_text_field($_POST['shipping_display_name']),
|
1863 |
'api_provider_name' => $api_provider_name,
|
1864 |
-
'custom_thumb_id' => sanitize_text_field($_POST['thumb_id']),
|
1865 |
);
|
1866 |
} else{
|
1867 |
$data_array = array(
|
1868 |
-
'shipping_country' => sanitize_text_field($_POST['shipping_country']),
|
1869 |
-
'provider_name' => sanitize_text_field($_POST['shipping_provider']),
|
1870 |
-
'custom_provider_name' => sanitize_text_field($_POST['shipping_display_name']),
|
1871 |
-
'ts_slug' => sanitize_title($_POST['shipping_provider']),
|
1872 |
-
'custom_thumb_id' => sanitize_text_field($_POST['thumb_id']),
|
1873 |
-
'provider_url' => sanitize_text_field($_POST['tracking_url'])
|
1874 |
);
|
1875 |
}
|
1876 |
|
@@ -1880,8 +1903,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1880 |
$wpdb->update( $this->table, $data_array, $where_array );
|
1881 |
$status = 'active';
|
1882 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1883 |
-
$html = $this->get_provider_html($default_shippment_providers
|
1884 |
-
echo $html;
|
|
|
1885 |
}
|
1886 |
|
1887 |
/**
|
@@ -1901,8 +1925,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1901 |
$wpdb->update( $this->table, $data_array, $where_array );
|
1902 |
$status = 'active';
|
1903 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1904 |
-
$html = $this->get_provider_html($default_shippment_providers
|
1905 |
-
echo $html;
|
|
|
1906 |
}
|
1907 |
|
1908 |
/**
|
@@ -1915,11 +1940,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1915 |
'display_in_order' => $_POST['status'],
|
1916 |
);
|
1917 |
|
1918 |
-
|
1919 |
-
$display_in_order = 0;
|
1920 |
-
} else{
|
1921 |
-
$display_in_order = 1;
|
1922 |
-
}
|
1923 |
|
1924 |
$where_array = array(
|
1925 |
'display_in_order' => $display_in_order,
|
@@ -1928,7 +1949,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1928 |
$wpdb->update( $this->table, $data_array, $where_array );
|
1929 |
$status = 'all';
|
1930 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1931 |
-
$html = $this->get_provider_html($default_shippment_providers
|
1932 |
exit;
|
1933 |
}
|
1934 |
|
@@ -1941,16 +1962,17 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1941 |
global $typenow, $wpdb;
|
1942 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1943 |
|
1944 |
-
if ( 'shop_order' === $typenow ) {
|
|
|
1945 |
<select name="_shop_order_shipping_provider" id="dropdown_shop_order_shipping_provider">
|
1946 |
-
<option value=""><?php
|
1947 |
<?php foreach ( $default_shippment_providers as $provider ) : ?>
|
1948 |
<option value="<?php echo esc_attr( $provider->ts_slug ); ?>" <?php echo esc_attr( isset( $_GET['_shop_order_shipping_provider'] ) ? selected( $provider->ts_slug, $_GET['_shop_order_shipping_provider'], false ) : '' ); ?>>
|
1949 |
<?php printf( '%1$s', esc_html( $provider->provider_name ) ); ?>
|
1950 |
</option>
|
1951 |
<?php endforeach; ?>
|
1952 |
</select>
|
1953 |
-
|
1954 |
}
|
1955 |
}
|
1956 |
|
@@ -1961,9 +1983,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1961 |
* @param array $vars query vars without filtering
|
1962 |
* @return array $vars query vars with (maybe) filtering
|
1963 |
*/
|
1964 |
-
public function filter_orders_by_shipping_provider_query( $vars ){
|
1965 |
global $typenow;
|
1966 |
-
if ( 'shop_order' === $typenow && isset( $_GET['_shop_order_shipping_provider'] ) && $_GET['_shop_order_shipping_provider']
|
1967 |
$vars['meta_query'][] = array(
|
1968 |
'key' => '_wc_shipment_tracking_items',
|
1969 |
'value' => $_GET['_shop_order_shipping_provider'],
|
@@ -1981,7 +2003,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1981 |
* @param array $vars query vars without filtering
|
1982 |
* @return array $vars query vars with (maybe) filtering
|
1983 |
*/
|
1984 |
-
public function filter_orders_by_tracking_number_query( $search_fields ){
|
1985 |
$search_fields[] = '_wc_shipment_tracking_items';
|
1986 |
return $search_fields;
|
1987 |
}
|
@@ -1991,7 +2013,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
1991 |
*
|
1992 |
* return array
|
1993 |
*/
|
1994 |
-
public function get_zorem_pluginlist(){
|
1995 |
|
1996 |
if ( !empty( $this->zorem_pluginlist ) ) return $this->zorem_pluginlist;
|
1997 |
|
@@ -2010,15 +2032,15 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
2010 |
return $this->zorem_pluginlist = $plugin_list;
|
2011 |
}
|
2012 |
|
2013 |
-
public function update_custom_order_status_email_display_fun(){
|
2014 |
|
2015 |
-
$status = wc_clean($_POST['status']);
|
2016 |
|
2017 |
-
$wc_ast_show_orders_actions = get_option('wc_ast_show_orders_actions');
|
2018 |
$wc_ast_show_orders_actions[$status] = 1;
|
2019 |
update_option( 'wc_ast_show_orders_actions', $wc_ast_show_orders_actions );
|
2020 |
|
2021 |
-
$wc_ast_unclude_tracking_info = get_option('wc_ast_unclude_tracking_info');
|
2022 |
$wc_ast_unclude_tracking_info[$status] = 1;
|
2023 |
update_option( 'wc_ast_unclude_tracking_info', $wc_ast_unclude_tracking_info );
|
2024 |
}
|
@@ -2028,22 +2050,22 @@ class WC_Advanced_Shipment_Tracking_Admin {
|
|
2028 |
*
|
2029 |
* return provider slug
|
2030 |
*/
|
2031 |
-
public function get_provider_slug_from_name( $tracking_provider_name ){
|
2032 |
|
2033 |
global $wpdb;
|
2034 |
|
2035 |
$tracking_provider = $wpdb->get_var( $wpdb->prepare( "SELECT ts_slug FROM $this->table WHERE api_provider_name = '%s'", $tracking_provider_name ) );
|
2036 |
|
2037 |
-
if(!$tracking_provider){
|
2038 |
$query = "SELECT ts_slug FROM $this->table WHERE JSON_CONTAINS(api_provider_name, '[".'"'.$tracking_provider_name.'"'."]')";
|
2039 |
$tracking_provider = $wpdb->get_var( $query );
|
2040 |
}
|
2041 |
|
2042 |
-
if(!$tracking_provider){
|
2043 |
$tracking_provider = $wpdb->get_var( $wpdb->prepare( "SELECT ts_slug FROM $this->table WHERE provider_name = '%s'", $tracking_provider_name ) );
|
2044 |
}
|
2045 |
|
2046 |
-
if(!$tracking_provider){
|
2047 |
$tracking_provider = $tracking_provider_name ;
|
2048 |
}
|
2049 |
|
4 |
}
|
5 |
|
6 |
class WC_Advanced_Shipment_Tracking_Admin {
|
7 |
+
|
|
|
|
|
|
|
|
|
|
|
8 |
var $zorem_pluginlist;
|
9 |
|
10 |
/**
|
11 |
* Initialize the main plugin function
|
12 |
*/
|
13 |
+
public function __construct() {
|
|
|
|
|
|
|
|
|
14 |
|
15 |
global $wpdb;
|
16 |
+
if ( is_multisite() ) {
|
17 |
+
|
18 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
19 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
20 |
}
|
21 |
+
|
22 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
23 |
+
$main_blog_prefix = $wpdb->get_blog_prefix( BLOG_ID_CURRENT_SITE );
|
24 |
+
$this->table = $main_blog_prefix . 'woo_shippment_provider';
|
25 |
} else{
|
26 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
27 |
}
|
28 |
+
|
29 |
+
} else {
|
30 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
31 |
}
|
32 |
|
33 |
}
|
47 |
public static function get_instance() {
|
48 |
|
49 |
if ( null === self::$instance ) {
|
50 |
+
self::$instance = new self();
|
51 |
}
|
52 |
|
53 |
return self::$instance;
|
56 |
/*
|
57 |
* init from parent mail class
|
58 |
*/
|
59 |
+
public function init() {
|
60 |
+
|
61 |
//cron_schedules
|
62 |
add_filter( 'cron_schedules', array( $this, 'add_cron_interval') );
|
63 |
|
65 |
add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'filter_orders_by_tracking_number_query' ) );
|
66 |
|
67 |
// add bulk order filter for exported / non-exported orders
|
68 |
+
add_action( 'restrict_manage_posts', array( $this, 'filter_orders_by_shipping_provider'), 20 );
|
69 |
add_filter( 'request', array( $this, 'filter_orders_by_shipping_provider_query' ) );
|
70 |
|
71 |
add_filter( 'woocommerce_email_title', array( $this, 'change_completed_woocommerce_email_title'), 10, 2 );
|
72 |
|
|
|
73 |
add_action( 'wp_ajax_wc_ast_upload_csv_form_update', array( $this, 'upload_tracking_csv_fun') );
|
74 |
|
75 |
+
add_action( 'admin_footer', array( $this, 'footer_function'), 1 );
|
76 |
|
77 |
add_action( 'wp_ajax_update_email_preview_order', array( $this, 'update_email_preview_order_fun') );
|
78 |
|
100 |
|
101 |
add_action( 'wp_ajax_update_shipment_status', array( $this, 'update_shipment_status_fun') );
|
102 |
|
103 |
+
add_action( 'wp_ajax_update_custom_order_status_email_display', array( $this, 'update_custom_order_status_email_display_fun') );
|
104 |
+
|
105 |
+
add_action( 'update_order_status_after_adding_tracking', array( $this, 'update_order_status_after_adding_tracking'), 10, 2 );
|
106 |
}
|
107 |
|
108 |
/*
|
109 |
* add_cron_interval
|
110 |
*/
|
111 |
+
public function add_cron_interval( $schedules ) {
|
112 |
+
|
113 |
$schedules['wc_ast_1hr'] = array(
|
114 |
'interval' => 60*60,//1 hour
|
115 |
'display' => esc_html__( 'Every one hour' ),
|
116 |
);
|
117 |
+
|
118 |
$schedules['wc_ast_6hr'] = array(
|
119 |
'interval' => 60*60*6,//6 hour
|
120 |
'display' => esc_html__( 'Every six hour' ),
|
121 |
);
|
122 |
+
|
123 |
$schedules['wc_ast_12hr'] = array(
|
124 |
'interval' => 60*60*12,//6 hour
|
125 |
'display' => esc_html__( 'Every twelve hour' ),
|
126 |
);
|
127 |
+
|
128 |
$schedules['wc_ast_1day'] = array(
|
129 |
'interval' => 60*60*24*1,//1 days
|
130 |
'display' => esc_html__( 'Every one day' ),
|
131 |
);
|
132 |
+
|
133 |
$schedules['wc_ast_2day'] = array(
|
134 |
'interval' => 60*60*24*2,//2 days
|
135 |
'display' => esc_html__( 'Every two day' ),
|
136 |
);
|
137 |
+
|
138 |
$schedules['wc_ast_7day'] = array(
|
139 |
'interval' => 60*60*24*7,//7 days
|
140 |
'display' => esc_html__( 'Every Seven day' ),
|
145 |
'interval' => 2*60,//1 hour
|
146 |
'display' => esc_html__( 'Every two min' ),
|
147 |
);
|
148 |
+
|
149 |
return $schedules;
|
150 |
}
|
151 |
|
153 |
* get shipped orders
|
154 |
*/
|
155 |
function get_shipped_orders() {
|
156 |
+
$range = get_option( 'wc_ast_api_date_range', 30 );
|
157 |
$args = array(
|
158 |
'status' => 'wc-completed',
|
159 |
'limit' => -1,
|
160 |
);
|
161 |
+
|
162 |
+
if ( 0 != $range ) {
|
163 |
+
$start = strtotime( date( 'Y-m-d 00:00:00', strtotime( '-'.$range.' days' ) ) );
|
164 |
+
$end = strtotime( date( 'Y-m-d 23:59:59', strtotime( '-1 days' ) ) );
|
165 |
$args['date_completed'] = $start.'...'.$end;
|
166 |
}
|
167 |
|
168 |
+
return wc_get_orders( $args );
|
169 |
}
|
170 |
|
171 |
/**
|
172 |
* Load admin styles.
|
173 |
*/
|
174 |
+
public function admin_styles( $hook ) {
|
175 |
|
176 |
+
if ( !isset( $_GET['page'] ) ) {
|
177 |
return;
|
178 |
+
}
|
179 |
+
|
180 |
+
if ( 'woocommerce-advanced-shipment-tracking' != $_GET['page'] && 'trackship-for-woocommerce' != $_GET['page'] ) {
|
181 |
+
return;
|
182 |
+
}
|
183 |
|
184 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
185 |
|
197 |
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
198 |
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
199 |
|
200 |
+
wp_enqueue_script( 'selectWoo' );
|
201 |
+
wp_enqueue_script( 'wc-enhanced-select' );
|
202 |
|
203 |
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
|
204 |
wp_enqueue_style( 'woocommerce_admin_styles' );
|
206 |
|
207 |
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip.min.js', array( 'jquery' ), WC_VERSION, true );
|
208 |
|
|
|
209 |
wp_enqueue_script( 'jquery-tiptip' );
|
210 |
wp_enqueue_script( 'jquery-blockui' );
|
211 |
wp_enqueue_script( 'wp-color-picker' );
|
212 |
wp_enqueue_script( 'jquery-ui-sortable' );
|
213 |
+
wp_enqueue_script( 'media-upload' );
|
214 |
+
wp_enqueue_script( 'thickbox' );
|
215 |
+
wp_enqueue_style( 'thickbox' );
|
216 |
wp_enqueue_style( 'trackship_styles' );
|
217 |
|
218 |
+
wp_enqueue_script( 'ajax-queue', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/jquery.ajax.queue.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version );
|
219 |
|
220 |
+
wp_enqueue_script( 'ast_settings', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/settings.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version );
|
221 |
|
222 |
+
wp_enqueue_script( 'ast_datatable', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/datatable.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version );
|
223 |
|
224 |
+
wp_enqueue_script( 'ast_datatable_jquery', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/datatable.jquery.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version );
|
225 |
|
226 |
+
wp_enqueue_script( 'front-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/front.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version );
|
227 |
|
228 |
wp_register_script( 'shipment_tracking_table_rows', wc_advanced_shipment_tracking()->plugin_dir_url().'assets/js/shipping_row.js' , array( 'jquery', 'wp-util' ), wc_advanced_shipment_tracking()->version );
|
229 |
+
|
230 |
wp_localize_script( 'shipment_tracking_table_rows', 'shipment_tracking_table_rows', array(
|
231 |
'i18n' => array(
|
232 |
'data_saved' => __( 'Data saved successfully.', 'woo-advanced-shipment-tracking' ),
|
246 |
*/
|
247 |
public function register_woocommerce_menu() {
|
248 |
add_submenu_page( 'woocommerce', 'Shipment Tracking', __( 'Shipment Tracking', 'woo-advanced-shipment-tracking' ), 'manage_woocommerce', 'woocommerce-advanced-shipment-tracking', array( $this, 'woocommerce_advanced_shipment_tracking_page_callback' ) );
|
249 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
/*
|
252 |
* callback for Shipment Tracking page
|
253 |
*/
|
254 |
+
public function woocommerce_advanced_shipment_tracking_page_callback() {
|
255 |
+
|
256 |
+
global $order, $wpdb;
|
257 |
$WC_Countries = new WC_Countries();
|
258 |
+
$countries = $WC_Countries->get_countries();
|
259 |
|
260 |
+
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM {$this->table} ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
|
|
|
|
261 |
|
262 |
+
foreach ( $default_shippment_providers as $key => $value ) {
|
263 |
+
$search = array('(US)', '(UK)');
|
264 |
$replace = array('', '');
|
265 |
+
|
266 |
+
if ( $value->shipping_country && 'Global' != $value->shipping_country ) {
|
267 |
+
$country = str_replace( $search, $replace, $WC_Countries->countries[ $value->shipping_country ] );
|
268 |
+
$default_shippment_providers[ $key ]->country = $country;
|
269 |
+
} elseif ( $value->shipping_country && 'Global' == $value->shipping_country ) {
|
270 |
+
$default_shippment_providers[ $key ]->country = 'Global';
|
|
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
+
}
|
273 |
|
274 |
+
wp_enqueue_script( 'shipment_tracking_table_rows' );
|
275 |
+
?>
|
276 |
+
|
277 |
+
<div class="zorem-layout">
|
278 |
+
<div class="zorem-layout__header">
|
279 |
+
<h1 class="zorem-layout__header-breadcrumbs"><span class="header-breadcrumbs-last"><?php _e('Shipment Tracking', 'woo-advanced-shipment-tracking'); ?></span></h1>
|
280 |
+
<?php
|
281 |
+
/*if ( !class_exists( 'ast_pro' ) ) {
|
282 |
+
?>
|
283 |
<div class="zorem-layout__docs-panel">
|
284 |
+
<a class="button-primary btn_ast2 ast-pro-btn" target="blank" href="https://www.zorem.com/product/ast-pro/"><?php _e('UPGRADE TO PRO', 'woo-advanced-shipment-tracking'); ?><span class="dashicons dashicons-arrow-right-alt2"></span></a>
|
285 |
</div>
|
286 |
+
<?php }*/ ?>
|
287 |
+
</div>
|
288 |
+
<?php do_action( 'ast_settings_admin_notice' ); ?>
|
289 |
+
<div class="woocommerce zorem_admin_layout">
|
290 |
+
<div class="ast_admin_content" >
|
291 |
<div class="ast_nav_div">
|
292 |
+
<?php $this->get_html_menu_tab( $this->get_ast_tab_settings_data() ); ?>
|
293 |
+
<div class="nav_doc_section">
|
294 |
+
<a target="blank" class="doc_link" href="https://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/"><?php _e( 'Documentation', 'woo-advanced-shipment-tracking' ); ?><span class="dashicons dashicons-media-default"></span></a>
|
295 |
+
</div>
|
296 |
+
<?php
|
297 |
require_once( 'views/admin_options_shipping_provider.php' );
|
298 |
require_once( 'views/admin_options_settings.php' );
|
299 |
require_once( 'views/admin_options_bulk_upload.php' );
|
300 |
+
do_action( 'ast_paypal_settings_panel' );
|
301 |
+
require_once( 'views/admin_options_addons.php' );
|
302 |
+
?>
|
303 |
</div>
|
304 |
+
</div>
|
305 |
+
</div>
|
306 |
+
|
307 |
<div id="ast_settings_snackbar" class="ast_snackbar"><?php _e( 'Data saved successfully.', 'woo-advanced-shipment-tracking' )?></div>
|
308 |
+
|
309 |
<div id="" class="popupwrapper ts_video_popup" style="display:none;">
|
310 |
<div class="popuprow">
|
311 |
<div class="videoWrapper">
|
323 |
<div class="popupclose"></div>
|
324 |
</div>
|
325 |
</div>
|
326 |
+
<?php }
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
|
328 |
+
/*
|
329 |
+
* callback for Shipment Tracking menu array
|
330 |
+
*/
|
331 |
+
public function get_ast_tab_settings_data() {
|
332 |
+
|
333 |
+
$ast_customizer_settings = new wcast_initialise_customizer_settings();
|
334 |
+
$go_pro_label = class_exists( 'ast_pro' ) ? __( 'License', 'woo-advanced-shipment-tracking' ) : __( 'Go PRO', 'woo-advanced-shipment-tracking' ) ;
|
335 |
$setting_data = array(
|
336 |
'tab2' => array(
|
337 |
'title' => __( 'Settings', 'woo-advanced-shipment-tracking' ),
|
342 |
'name' => 'tabs',
|
343 |
'position' => 1,
|
344 |
),
|
345 |
+
'customize' => array(
|
346 |
+
'title' => __( 'Customize', 'woo-advanced-shipment-tracking' ),
|
347 |
+
'type' => 'link',
|
348 |
+
'link' => $ast_customizer_settings->get_customizer_url( 'ast_tracking_general_section', 'settings' ),
|
349 |
+
'show' => true,
|
350 |
+
'class' => 'tab_label',
|
351 |
+
'data-tab' => 'trackship',
|
352 |
+
'data-label' => __( 'Customize', 'woo-advanced-shipment-tracking' ),
|
353 |
+
'name' => 'tabs',
|
354 |
+
'position' => 3,
|
355 |
+
),
|
356 |
'tab1' => array(
|
357 |
'title' => __( 'Shipping Providers', 'woo-advanced-shipment-tracking' ),
|
358 |
'show' => true,
|
369 |
'data-tab' => 'bulk-upload',
|
370 |
'data-label' => __( 'CSV Import', 'woo-advanced-shipment-tracking' ),
|
371 |
'name' => 'tabs',
|
372 |
+
'position' => 4,
|
373 |
),
|
374 |
'tab6' => array(
|
375 |
+
'title' => $go_pro_label,
|
376 |
'show' => true,
|
377 |
'class' => 'tab_label',
|
378 |
'data-tab' => 'addons',
|
379 |
+
'data-label' => $go_pro_label,
|
380 |
'name' => 'tabs',
|
381 |
+
'position' => 5,
|
382 |
),
|
383 |
);
|
384 |
+
return apply_filters( 'ast_menu_tab_options', $setting_data );
|
|
|
385 |
}
|
386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
/*
|
388 |
+
* callback for Shipment Tracking general settings data
|
389 |
*/
|
390 |
+
public function get_ast_tab_general_settings_data() {
|
391 |
+
$setting_data = array(
|
392 |
+
'tab_general_settings' => array(
|
393 |
+
'title' => __( 'General Settings', 'woo-advanced-shipment-tracking' ),
|
394 |
+
'show' => true,
|
395 |
+
'class' => 'inner_tab_label',
|
396 |
+
'data-tab' => 'general-settings',
|
397 |
+
'data-label' => __( 'General Settings', 'woo-advanced-shipment-tracking' ),
|
398 |
+
'name' => 'ast_generatral_settings_tabs',
|
399 |
+
'position' => 1,
|
400 |
+
),
|
401 |
+
'tab_order_status' => array(
|
402 |
+
'title' => __( 'Order Statuses', 'woo-advanced-shipment-tracking' ),
|
403 |
+
'show' => true,
|
404 |
+
'class' => 'inner_tab_label',
|
405 |
+
'data-tab' => 'order-status',
|
406 |
+
'data-label' => __( 'Order Statuses', 'woo-advanced-shipment-tracking' ),
|
407 |
+
'name' => 'ast_generatral_settings_tabs',
|
408 |
+
'position' => 1,
|
409 |
+
),
|
410 |
+
);
|
411 |
+
return apply_filters( 'ast_general_settings_tab_options', $setting_data );
|
412 |
+
}
|
413 |
+
|
414 |
+
/*
|
415 |
+
* callback for HTML function for Shipment Tracking menu
|
416 |
+
*/
|
417 |
+
public function get_html_menu_tab( $arrays, $tab_class = "tab_input" ) {
|
418 |
+
|
419 |
+
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'settings';
|
420 |
+
$settings = isset( $_GET['settings'] ) ? sanitize_text_field( $_GET['settings'] ) : 'general-settings';
|
421 |
+
|
422 |
+
foreach ( (array) $arrays as $id => $array ) {
|
423 |
+
$checked = ( $tab == $array['data-tab'] || $settings == $array['data-tab'] ) ? 'checked' : '';
|
424 |
+
if( isset( $array['type'] ) && 'link' == $array['type'] ) {
|
425 |
+
?>
|
426 |
+
<a class="menu_trackship_link" href="<?php esc_html_e( esc_url( $array['link'] ) ); ?>"><?php esc_html_e( $array['title'] ); ?></a>
|
427 |
+
<?php
|
428 |
+
} else {
|
429 |
+
?>
|
430 |
+
<input class="<?php esc_html_e( $tab_class ); ?>" id="<?php esc_html_e( $id ); ?>" name="<?php esc_html_e( $array['name'] ); ?>" type="radio" data-tab="<?php esc_html_e( $array['data-tab'] ); ?>" data-label="<?php esc_html_e( $array['data-label'] ); ?>" <?php esc_html_e( $checked ); ?>/>
|
431 |
+
<label class="<?php esc_html_e( $array['class'] ); ?>" for="<?php esc_html_e( $id ); ?>"><?php esc_html_e( $array['title'] ); ?></label>
|
432 |
+
<?php
|
433 |
+
}
|
434 |
+
}
|
435 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
|
437 |
/*
|
438 |
+
* get UL html of fields
|
439 |
*/
|
440 |
+
public function get_html_ul( $arrays ) {
|
441 |
+
?>
|
442 |
+
<ul class="settings_ul">
|
443 |
+
<?php
|
444 |
+
foreach( (array)$arrays as $id => $array ) {
|
445 |
|
446 |
+
if( $array['show'] ) {
|
447 |
+
|
448 |
+
if( 'checkbox' == $array['type'] ) {
|
449 |
+
$checked = ( get_option( $id ) ) ? 'checked' : '' ;
|
450 |
+
?>
|
|
|
|
|
|
|
451 |
<li>
|
452 |
+
<input type="hidden" name="<?php esc_html_e( $id ); ?>" value="0"/>
|
453 |
+
<input class="" id="<?php esc_html_e( $id ); ?>" name="<?php esc_html_e( $id ); ?>" type="checkbox" <?php esc_html_e( $checked ); ?> value="1"/>
|
454 |
|
455 |
+
<label class="setting_ul_checkbox_label"><?php esc_html_e( $array['title'] ); ?>
|
456 |
+
<?php if ( isset( $array['tooltip'] ) ) { ?>
|
457 |
+
<span class="woocommerce-help-tip tipTip" title="<?php esc_html_e( $array['tooltip'] ); ?>"></span>
|
458 |
<?php } ?>
|
459 |
</label>
|
460 |
</li>
|
461 |
+
<?php
|
462 |
+
} else if ( 'tgl_checkbox' == $array['type'] ) {
|
463 |
+
|
464 |
+
$checked = ( get_option( $id ) ) ? 'checked' : '' ;
|
465 |
+
$tgl_class = isset( $array['tgl_color'] ) ? 'ast-tgl-btn-green' : '';
|
466 |
+
$disabled = isset( $array['disabled'] ) && true == $array['disabled'] ? 'disabled' : '';
|
467 |
+
?>
|
|
|
|
|
|
|
468 |
<li>
|
469 |
+
<span class="ast-tgl-btn-parent">
|
470 |
+
<input type="hidden" name="<?php esc_html_e( $id ); ?>" value="0"/>
|
471 |
+
<input class="ast-tgl ast-tgl-flat" id="<?php esc_html_e( $id ); ?>" name="<?php esc_html_e( $id ); ?>" type="checkbox" <?php esc_html_e( $checked ); ?> value="1" <?php esc_html_e( $disabled ); ?>/>
|
472 |
+
<label class="ast-tgl-btn <?php esc_html_e( $tgl_class ); ?>" for="<?php esc_html_e( $id ); ?>"></label>
|
473 |
+
</span>
|
474 |
|
475 |
+
<div class="setting_ul_tgl_checkbox_label"><strong><?php esc_html_e( $array['title'] ); ?></strong>
|
476 |
+
<?php if ( isset( $array['tooltip'] ) ) { ?>
|
477 |
+
<span class="woocommerce-help-tip tipTip" title="<?php esc_html_e( $array['tooltip'] ); ?>"></span>
|
478 |
+
<?php } ?>
|
479 |
+
<?php if ( isset( $array['desc'] ) ) { ?>
|
480 |
+
<div class="tgl_checkbox_desc"><?php esc_html_e( $array['desc'] ); ?></div>
|
481 |
+
<?php } ?>
|
482 |
+
</div>
|
483 |
+
|
484 |
+
<?php if ( isset( $array['customize_link'] ) ) { ?>
|
485 |
+
<a href="<?php esc_html_e( $array['customize_link'] ); ?>" class="button-primary btn_ts_transparent btn_large ts_customizer_btn">
|
486 |
+
<?php esc_html_e( 'Customize', 'woo-advanced-shipment-tracking' ); ?>
|
487 |
+
</a>
|
488 |
<?php } ?>
|
489 |
</li>
|
490 |
+
<?php
|
491 |
+
} else if ( 'radio' == $array['type'] ) {
|
492 |
+
?>
|
493 |
<li class="settings_radio_li">
|
494 |
+
<label><strong><?php esc_html_e( $array['title'] ); ?></strong>
|
495 |
+
<?php if ( isset( $array['tooltip'] ) ) { ?>
|
496 |
+
<span class="woocommerce-help-tip tipTip" title="<?php esc_html_e( $array['tooltip'] ); ?>"></span>
|
497 |
<?php } ?>
|
498 |
</label>
|
499 |
+
|
500 |
+
<?php
|
501 |
+
|
502 |
+
foreach( (array) $array['options'] as $key => $val ) {
|
503 |
+
$selected = ( get_option( $id, $array['default'] ) == (string)$key ) ? 'checked' : '' ;
|
504 |
+
?>
|
505 |
<span class="radio_section">
|
506 |
+
<label class="" for="<?php esc_html_e( $id ); ?>_<?php esc_html_e( $key ); ?>">
|
507 |
+
<input type="radio" id="<?php esc_html_e( $id ); ?>_<?php esc_html_e( $key ); ?>" name="<?php esc_html_e( $id ); ?>" class="<?php esc_html_e( $id ); ?>" value="<?php esc_html_e( $key ); ?>" <?php esc_html_e( $selected ); ?> />
|
508 |
+
<span class=""><?php esc_html_e( $val ); ?></span></br>
|
|
|
509 |
</label>
|
510 |
</span>
|
511 |
+
<?php
|
512 |
+
}
|
513 |
+
?>
|
514 |
</li>
|
515 |
+
<?php
|
516 |
+
} else if ( 'multiple_select' == $array['type'] ) {
|
517 |
+
?>
|
518 |
<li class="multiple_select_li">
|
519 |
+
<label><?php esc_html_e( $array['title'] ); ?>
|
520 |
+
<?php if ( isset( $array['tooltip'] ) ) { ?>
|
521 |
+
<span class="woocommerce-help-tip tipTip" title="<?php esc_html_e( $array['tooltip'] ); ?>"></span>
|
522 |
<?php } ?>
|
523 |
</label>
|
524 |
<div class="multiple_select_container">
|
525 |
+
<select multiple class="wc-enhanced-select" name="<?php esc_html_e( $id ); ?>[]" id="<?php esc_html_e( $id ); ?>">
|
526 |
<?php
|
527 |
+
foreach ( (array) $array['options'] as $key => $val ) {
|
528 |
+
$multi_checkbox_data = get_option( $id );
|
529 |
+
$checked = isset( $multi_checkbox_data[ $key ] ) && 1 == $multi_checkbox_data[ $key ] ? 'selected' : '' ;
|
530 |
+
?>
|
531 |
+
<option value="<?php echo esc_attr( $key ); ?>" <?php esc_html_e( $checked ); ?>><?php esc_html_e( $val['status'] ); ?></option>
|
532 |
+
<?php
|
533 |
+
}
|
534 |
+
?>
|
|
|
535 |
</select>
|
536 |
</div>
|
537 |
</li>
|
538 |
+
<?php
|
539 |
+
} else if ( 'multiple_checkbox' == $array['type'] ) {
|
540 |
+
?>
|
541 |
<li>
|
542 |
<div class="multiple_checkbox_label">
|
543 |
+
<label for=""><strong><?php esc_html_e( $array['title'] ); ?></strong></label>
|
544 |
+
<span class="multiple_checkbox_description"><?php esc_html_e( $array['desc'] ); ?></span>
|
545 |
</div >
|
546 |
<div class="multiple_checkbox_parent">
|
547 |
+
<?php
|
548 |
+
$op = 1;
|
549 |
+
foreach ( (array) $array['options'] as $key => $val ) {
|
550 |
$multi_checkbox_data = get_option($id);
|
551 |
+
$checked = isset( $multi_checkbox_data[ $key ] ) && 1 == $multi_checkbox_data[ $key ] ? 'checked' : '' ;
|
552 |
+
?>
|
|
|
|
|
|
|
553 |
<span class="multiple_checkbox">
|
554 |
<label class="" for="">
|
555 |
+
<input type="hidden" name="<?php esc_html_e( $id ); ?>[<?php esc_html_e( $key ); ?>]" value="0"/>
|
556 |
+
<input type="checkbox" name="<?php esc_html_e( $id ); ?>[<?php esc_html_e( $key ); ?>]" class="" <?php esc_html_e( $checked ); ?> value="1"/>
|
557 |
+
<span class="multiple_label"><?php esc_html_e( $val['status'] ); ?></span>
|
558 |
</br>
|
559 |
</label>
|
560 |
</span>
|
561 |
<?php } ?>
|
562 |
</div>
|
563 |
</li>
|
564 |
+
<?php
|
565 |
+
} else if ( 'dropdown_tpage' == $array['type'] ) {
|
566 |
+
?>
|
567 |
<li>
|
568 |
+
<label class="left_label"><?php esc_html_e( $array['title'] ); ?>
|
569 |
+
<?php if ( isset( $array['tooltip'] ) ) { ?>
|
570 |
+
<span class="woocommerce-help-tip tipTip" title="<?php esc_html_e( $array['tooltip'] ); ?>"></span>
|
571 |
<?php } ?>
|
572 |
</label>
|
573 |
+
|
574 |
+
<select class="select select2 tracking_page_select" id="<?php esc_html_e( $id ); ?>" name="<?php esc_html_e( $id ); ?>">
|
575 |
<?php
|
576 |
+
foreach ( (array) $array['options'] as $page_id => $page_name ) {
|
577 |
+
$selected = ( get_option( $id ) == $page_id ) ? 'selected' : '' ;
|
578 |
+
?>
|
579 |
+
<option value="<?php esc_html_e( $page_id ); ?>" <?php esc_html_e( $selected ); ?>><?php esc_html_e( $page_name ); ?></option>
|
580 |
+
<?php
|
581 |
+
}
|
582 |
+
?>
|
583 |
+
<option <?php if ( 'other' == get_option( $id ) ) { esc_html_e( 'selected' ); } ?> value="other"><?php esc_html_e( 'Other', 'woo-advanced-shipment-tracking' ); ?></option>
|
584 |
</select>
|
585 |
+
|
586 |
+
<fieldset style="<?php if ( 'other' != get_option( $id ) ) { esc_html_e( 'display:none;' ); } ?>" class="trackship_other_page_fieldset">
|
587 |
+
<input type="text" name="wc_ast_trackship_other_page" id="wc_ast_trackship_other_page" value="<?php esc_html_e( get_option('wc_ast_trackship_other_page') ); ?>">
|
588 |
</fieldset>
|
589 |
+
|
590 |
+
<p class="tracking_page_desc"><?php esc_html_e( 'add the [wcast-track-order] shortcode in the selected page.', 'woo-advanced-shipment-tracking' ); ?>
|
591 |
+
<a href="https://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/integration/" target="blank"><?php esc_html_e( 'more info', 'woo-advanced-shipment-tracking' ); ?></a>
|
592 |
+
</p>
|
593 |
+
|
594 |
</li>
|
595 |
+
<?php
|
596 |
+
} else if ( 'button' == $array['type'] ) {
|
597 |
+
?>
|
598 |
+
<li>
|
599 |
+
<label class="left_label"><?php esc_html_e( $array['title'] ); ?>
|
600 |
+
<?php if ( isset( $array['tooltip'] ) ) { ?>
|
601 |
+
<span class="woocommerce-help-tip tipTip" title="<?php esc_html_e( $array['tooltip'] ); ?>"></span>
|
602 |
+
<?php } ?>
|
603 |
+
</label>
|
604 |
+
<?php
|
605 |
+
if ( isset( $array['customize_link'] ) ) {
|
606 |
+
?>
|
607 |
+
<a href="<?php esc_html_e( $array['customize_link'] ); ?>" class="button-primary btn_ts_transparent btn_large ts_customizer_btn"><?php esc_html_e( 'Customize', 'woo-advanced-shipment-tracking' ); ?></a>
|
608 |
+
<?php } ?>
|
609 |
+
</li>
|
610 |
+
<?php
|
611 |
+
}
|
612 |
}
|
613 |
+
}
|
614 |
+
?>
|
615 |
</ul>
|
616 |
+
<?php
|
617 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
618 |
|
619 |
/*
|
620 |
* get settings tab array data
|
621 |
* return array
|
622 |
*/
|
623 |
+
public function get_settings_data(){
|
624 |
|
625 |
$wc_ast_status_shipped = get_option('wc_ast_status_shipped',0);
|
626 |
+
|
627 |
+
if( 1 == $wc_ast_status_shipped ) {
|
628 |
$completed_order_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
|
629 |
$mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">shipped</span>"', 'woo-advanced-shipment-tracking' );
|
630 |
$mark_as_shipped_tooltip = __( "This means that the 'mark as <span class='shipped_label'>shipped</span>' will be selected by default when adding tracking info to orders.", 'woo-advanced-shipment-tracking' );
|
631 |
+
} else {
|
632 |
$completed_order_label = __( 'Completed', 'woocommerce' );
|
633 |
$mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">completed</span>"', 'woo-advanced-shipment-tracking' );
|
634 |
$mark_as_shipped_tooltip = __( "This means that the 'mark as <span class='shipped_label'>completed</span>' will be selected by default when adding tracking info to orders.", 'woo-advanced-shipment-tracking' );
|
650 |
'wc-partial-shipped' => 'Partially Shipped',
|
651 |
'wc-updated-tracking' => 'Updated Tracking',
|
652 |
);
|
653 |
+
|
654 |
+
foreach ( $default_order_status as $key => $value ) {
|
655 |
unset($all_order_status[$key]);
|
656 |
}
|
657 |
+
|
658 |
$custom_order_status = $all_order_status;
|
659 |
+
|
660 |
+
foreach ( $custom_order_status as $key => $value ) {
|
661 |
unset($custom_order_status[$key]);
|
662 |
$key = str_replace("wc-", "", $key);
|
663 |
$custom_order_status[$key] = array(
|
749 |
),
|
750 |
);
|
751 |
|
752 |
+
$order_status_array = array_merge( $order_status, $custom_order_status );
|
753 |
+
$action_order_status_array = array_merge( $actions_order_status, $custom_order_status );
|
|
|
754 |
|
755 |
$form_data = array(
|
756 |
'wc_ast_default_mark_shipped' => array(
|
802 |
),
|
803 |
);
|
804 |
|
805 |
+
return apply_filters( 'ast_general_settings_options', $form_data );
|
|
|
|
|
|
|
806 |
}
|
807 |
|
808 |
/*
|
809 |
* get updated tracking status settings array data
|
810 |
* return array
|
811 |
*/
|
812 |
+
public function get_updated_tracking_data() {
|
813 |
$form_data = array(
|
814 |
'wc_ast_status_updated_tracking' => array(
|
815 |
'type' => 'checkbox',
|
827 |
'type' => 'dropdown',
|
828 |
'title' => __( 'Updated Tracking Label font color', '' ),
|
829 |
'options' => array(
|
830 |
+
'' =>__( 'Select', 'woocommerce' ),
|
831 |
+
'#fff' =>__( 'Light', '' ),
|
832 |
+
'#000' =>__( 'Dark', '' ),
|
833 |
),
|
834 |
'class' => 'updated_tracking_status_label_color_th',
|
835 |
'show' => true,
|
837 |
'wcast_enable_updated_tracking_email' => array(
|
838 |
'type' => 'checkbox',
|
839 |
'title' => __( 'Enable the Updated Tracking order status email', '' ),
|
840 |
+
'title_link'=> "<a class='settings_edit' href='" . ps_customizer()->get_customizer_url( 'custom_order_status_email' , 'updated_tracking' ) . "'>" . __( 'Edit', 'woocommerce' ) . "</a>",
|
841 |
'class' => 'updated_tracking_status_label_color_th',
|
842 |
'show' => true,
|
843 |
),
|
844 |
);
|
845 |
return $form_data;
|
|
|
846 |
}
|
847 |
|
848 |
/*
|
849 |
* get Partially Shipped array data
|
850 |
* return array
|
851 |
*/
|
852 |
+
public function get_partial_shipped_data(){
|
853 |
$form_data = array(
|
854 |
'wc_ast_status_partial_shipped' => array(
|
855 |
'type' => 'checkbox',
|
867 |
'type' => 'dropdown',
|
868 |
'title' => __( 'Partially Shipped Label font color', '' ),
|
869 |
'options' => array(
|
870 |
+
'' =>__( 'Select', 'woocommerce' ),
|
871 |
+
'#fff' =>__( 'Light', '' ),
|
872 |
+
'#000' =>__( 'Dark', '' ),
|
873 |
),
|
874 |
'class' => 'partial_shipped_status_label_color_th',
|
875 |
'show' => true,
|
877 |
'wcast_enable_partial_shipped_email' => array(
|
878 |
'type' => 'checkbox',
|
879 |
'title' => __( 'Enable the Partially Shipped order status email', '' ),
|
880 |
+
'title_link'=> "<a class='settings_edit' href='" . ps_customizer()->get_customizer_url( 'custom_order_status_email', 'partially_shipped' ) . "'>" . __( 'Edit', 'woocommerce' ) . "</a>",
|
881 |
'class' => 'partial_shipped_status_label_color_th',
|
882 |
'show' => true,
|
883 |
),
|
886 |
|
887 |
}
|
888 |
|
889 |
+
/*
|
890 |
+
* get Order Status data
|
891 |
+
* return array
|
892 |
+
*/
|
893 |
+
public function get_osm_data(){
|
894 |
+
$osm_data = array(
|
895 |
+
'partial_shipped' => array(
|
896 |
+
'id' => 'wc_ast_status_partial_shipped',
|
897 |
+
'slug' => 'partial-shipped',
|
898 |
+
'label' => __( 'Partially Shipped', 'woo-advanced-shipment-tracking' ),
|
899 |
+
'label_class' => 'wc-partially-shipped',
|
900 |
+
'option_id' => 'woocommerce_customer_partial_shipped_order_settings',
|
901 |
+
'edit_email'=> ps_customizer()->get_customizer_url('custom_order_status_email','partially_shipped'),
|
902 |
+
'label_color_field' => 'wc_ast_status_partial_shipped_label_color',
|
903 |
+
'font_color_field' => 'wc_ast_status_partial_shipped_label_font_color',
|
904 |
+
'email_field' => 'wcast_enable_partial_shipped_email',
|
905 |
+
),
|
906 |
+
);
|
907 |
+
|
908 |
+
$updated_tracking_status = get_option( "wc_ast_status_updated_tracking", 0);
|
909 |
+
|
910 |
+
if ( true == $updated_tracking_status ) {
|
911 |
+
$updated_tracking_data = array(
|
912 |
+
'updated_tracking' => array(
|
913 |
+
'id' => 'wc_ast_status_updated_tracking',
|
914 |
+
'slug' => 'updated-tracking',
|
915 |
+
'label' => __( 'Updated Tracking', 'woo-advanced-shipment-tracking' ),
|
916 |
+
'label_class' => 'wc-updated-tracking',
|
917 |
+
'option_id' => 'woocommerce_customer_updated_tracking_order_settings',
|
918 |
+
'edit_email'=> ut_customizer()->get_customizer_url('custom_order_status_email','updated_tracking'),
|
919 |
+
'label_color_field' => 'wc_ast_status_updated_tracking_label_color',
|
920 |
+
'font_color_field' => 'wc_ast_status_updated_tracking_label_font_color',
|
921 |
+
'email_field' => 'wcast_enable_updated_tracking_email',
|
922 |
+
),
|
923 |
+
);
|
924 |
+
$osm_data = array_merge( $osm_data, $updated_tracking_data );
|
925 |
+
}
|
926 |
+
return apply_filters( 'ast_osm_data', $osm_data );
|
927 |
+
}
|
928 |
+
|
929 |
/*
|
930 |
* settings form save
|
931 |
*/
|
932 |
+
public function wc_ast_settings_form_update_callback() {
|
933 |
|
934 |
if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_settings_form', 'wc_ast_settings_form_nonce' ) ) {
|
935 |
|
936 |
$data = $this->get_settings_data();
|
937 |
|
938 |
+
foreach ( $data as $key => $val ) {
|
939 |
|
940 |
+
if ( isset( $val['type'] ) && 'multiple_select' == $val['type'] ) {
|
941 |
|
942 |
+
foreach ( $val['options'] as $op_status => $op_data ) {
|
943 |
$_POST[ $key ][$op_status] = 0;
|
944 |
}
|
945 |
+
|
946 |
+
foreach ( $_POST[ $key ] as $key1 => $status) {
|
947 |
$_POST[ $key ][$status] = 1;
|
948 |
+
}
|
949 |
+
|
950 |
+
update_option( $key, wc_clean( $_POST[ $key ] ) );
|
951 |
+
|
952 |
+
} else {
|
953 |
+
|
954 |
+
if ( isset( $_POST[ $key ] ) ) {
|
955 |
+
update_option( $key, wc_clean( $_POST[ $key ] ) );
|
956 |
}
|
957 |
}
|
958 |
|
959 |
+
if ( isset( $val['type'] ) && 'inline_checkbox' == $val['type'] ) {
|
960 |
+
foreach ( (array) $val['checkbox_array'] as $key1 => $val1 ) {
|
961 |
+
if ( isset( $_POST[ $key1 ] ) ) {
|
962 |
+
update_option( $key1, wc_clean( $_POST[ $key1 ] ) );
|
963 |
}
|
964 |
}
|
965 |
}
|
970 |
/**
|
971 |
* Save custom order status - eanble/disable,color,font,email
|
972 |
*/
|
973 |
+
public function wc_ast_custom_order_status_form_update() {
|
974 |
+
|
975 |
if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_order_status_form', 'wc_ast_order_status_form_nonce' ) ) {
|
976 |
|
977 |
+
update_option( 'wc_ast_status_shipped', wc_clean( $_POST[ 'wc_ast_status_shipped' ] ) );
|
978 |
|
979 |
$data = $this->get_partial_shipped_data();
|
980 |
|
981 |
+
foreach ( $data as $key => $val ) {
|
982 |
|
983 |
+
if ( 'wcast_enable_partial_shipped_email' == $key ) {
|
984 |
+
if ( isset( $_POST['wcast_enable_partial_shipped_email'] ) ) {
|
985 |
|
986 |
+
if ( 1 == $_POST['wcast_enable_partial_shipped_email'] ) {
|
987 |
+
update_option( 'customizer_partial_shipped_order_settings_enabled', wc_clean( $_POST['wcast_enable_partial_shipped_email'] ) );
|
988 |
$enabled = 'yes';
|
989 |
+
} else {
|
990 |
+
update_option( 'customizer_partial_shipped_order_settings_enabled', '' );
|
991 |
$enabled = 'no';
|
992 |
}
|
993 |
|
994 |
+
$wcast_enable_partial_shipped_email = get_option( 'woocommerce_customer_partial_shipped_order_settings' );
|
995 |
$wcast_enable_partial_shipped_email['enabled'] = $enabled;
|
996 |
update_option( 'woocommerce_customer_partial_shipped_order_settings', $wcast_enable_partial_shipped_email );
|
997 |
}
|
998 |
}
|
999 |
|
1000 |
+
if ( isset( $_POST[ $key ] ) ) {
|
1001 |
+
update_option( $key, wc_clean( $_POST[ $key ] ) );
|
1002 |
}
|
1003 |
}
|
1004 |
|
1005 |
$data = $this->get_updated_tracking_data();
|
1006 |
|
1007 |
+
foreach ( $data as $key => $val ) {
|
1008 |
|
1009 |
+
if ( 'wcast_enable_updated_tracking_email' == $key ) {
|
1010 |
+
if ( isset( $_POST['wcast_enable_updated_tracking_email'] ) ) {
|
1011 |
+
if ( 1 == $_POST['wcast_enable_updated_tracking_email'] ) {
|
1012 |
+
update_option( 'customizer_updated_tracking_order_settings_enabled', wc_clean( $_POST['wcast_enable_updated_tracking_email'] ) );
|
|
|
1013 |
$enabled = 'yes';
|
1014 |
+
} else {
|
1015 |
+
update_option( 'customizer_updated_tracking_order_settings_enabled', '' );
|
1016 |
$enabled = 'no';
|
1017 |
}
|
1018 |
|
1019 |
+
$wcast_enable_updated_tracking_email = get_option( 'woocommerce_customer_updated_tracking_order_settings' );
|
1020 |
$wcast_enable_updated_tracking_email['enabled'] = $enabled;
|
1021 |
update_option( 'woocommerce_customer_updated_tracking_order_settings', $wcast_enable_updated_tracking_email );
|
1022 |
}
|
1023 |
}
|
1024 |
|
1025 |
+
if ( isset( $_POST[ $key ] ) ) {
|
1026 |
+
update_option( $key, wc_clean( $_POST[ $key ] ) );
|
1027 |
}
|
1028 |
}
|
1029 |
+
|
1030 |
+
do_action( 'ast_custom_order_status_save', $_POST );
|
1031 |
+
echo json_encode( array('success' => 'true') );
|
1032 |
+
die();
|
1033 |
}
|
1034 |
}
|
1035 |
|
1036 |
/*
|
1037 |
* change style of delivered order label
|
1038 |
*/
|
1039 |
+
public function footer_function(){
|
1040 |
if ( !is_plugin_active( 'woocommerce-order-status-manager/woocommerce-order-status-manager.php' ) ) {
|
1041 |
+
$bg_color = get_option( 'wc_ast_status_label_color', '#59c889' );
|
1042 |
+
$color = get_option( 'wc_ast_status_label_font_color', '#fff' );
|
1043 |
|
1044 |
+
$ps_bg_color = get_option( 'wc_ast_status_partial_shipped_label_color', '#1e73be' );
|
1045 |
+
$ps_color = get_option( 'wc_ast_status_partial_shipped_label_font_color', '#fff' );
|
1046 |
|
1047 |
+
$ut_bg_color = get_option( 'wc_ast_status_updated_tracking_label_color', '#23a2dd' );
|
1048 |
+
$ut_color = get_option( 'wc_ast_status_updated_tracking_label_font_color', '#fff' );
|
1049 |
?>
|
1050 |
<style>
|
1051 |
.order-status.status-delivered,.order-status-table .order-label.wc-delivered{
|
1068 |
/*
|
1069 |
* Ajax call for upload tracking details into order from bulk upload
|
1070 |
*/
|
1071 |
+
public function upload_tracking_csv_fun(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1072 |
|
1073 |
+
$replace_tracking_info = wc_clean( $_POST['replace_tracking_info'] );
|
1074 |
+
$date_format_for_csv_import = wc_clean( $_POST['date_format_for_csv_import'] );
|
1075 |
+
update_option( 'date_format_for_csv_import', $date_format_for_csv_import );
|
1076 |
+
$order_id = wc_clean( $_POST['order_id'] );
|
1077 |
|
1078 |
+
$wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
1079 |
+
$order_id = $wast->get_formated_order_id( $order_id );
|
|
|
1080 |
|
1081 |
+
$tracking_provider = wc_clean( $_POST['tracking_provider'] );
|
1082 |
+
$tracking_number = wc_clean( $_POST['tracking_number'] );
|
1083 |
+
$date_shipped = str_replace( "/", "-", wc_clean( $_POST['date_shipped']) );
|
1084 |
|
1085 |
+
$sku = isset( $_POST['sku'] ) ? wc_clean( $_POST['sku'] ) : '';
|
1086 |
+
$qty = isset( $_POST['qty'] ) ? wc_clean( $_POST['qty'] ) : '';
|
1087 |
+
$date_shipped = empty( $date_shipped ) ? date("d-m-Y") : $date_shipped ;
|
1088 |
|
1089 |
global $wpdb;
|
1090 |
|
1091 |
+
$sql = $wpdb->prepare( "SELECT COUNT(*) FROM {$this->table} WHERE api_provider_name = %s", $tracking_provider );
|
1092 |
$shippment_provider = $wpdb->get_var( $sql );
|
1093 |
|
1094 |
if( $shippment_provider == 0 ){
|
1095 |
+
$sql = "SELECT COUNT(*) FROM {$this->table} WHERE JSON_CONTAINS(api_provider_name, '[".'"'.$tracking_provider.'"'."]')";
|
1096 |
$shippment_provider = $wpdb->get_var( $sql );
|
1097 |
}
|
1098 |
|
1099 |
if( $shippment_provider == 0 ){
|
1100 |
+
$sql = $wpdb->prepare( "SELECT COUNT(*) FROM {$this->table} WHERE provider_name = %s", $tracking_provider );
|
1101 |
$shippment_provider = $wpdb->get_var( $sql );
|
1102 |
}
|
1103 |
|
1104 |
$order = wc_get_order($order_id);
|
1105 |
+
|
1106 |
if ( $order === false ) {
|
1107 |
echo '<li class="invalid_order_id_error">Failed - Invalid Order Id - Order '.$_POST['order_id'].'</li>';exit;
|
1108 |
}
|
1109 |
|
1110 |
+
if ( $shippment_provider == 0 ) {
|
1111 |
echo '<li class="shipping_provider_error">Failed - Invalid Shipping Provider - Order '.$_POST['order_id'].'</li>';exit;
|
1112 |
}
|
1113 |
+
|
1114 |
+
if ( empty( $tracking_number ) ){
|
1115 |
echo '<li class="tracking_number_error">Failed - Empty Tracking Number - Order '.$_POST['order_id'].'</li>';exit;
|
1116 |
}
|
1117 |
|
1118 |
+
if ( empty( $date_shipped ) ) {
|
1119 |
echo '<li class="empty_date_shipped_error">Failed - Empty Date Shipped - Order '.$_POST['order_id'].'</li>';exit;
|
1120 |
}
|
1121 |
+
|
1122 |
+
if ( !$this->isDate( $date_shipped, $date_format_for_csv_import ) ) {
|
1123 |
echo '<li class="invalid_date_shipped_error">Failed - Invalid Date Shipped - Order '.$_POST['order_id'].'</li>';exit;
|
1124 |
}
|
1125 |
|
1126 |
+
if ( 'm-d-Y' == $date_format_for_csv_import ) {
|
1127 |
$date_array = explode("-",$date_shipped);
|
1128 |
$date_shipped = $date_array[1].'-'.$date_array[0].'-'.$date_array[2];
|
1129 |
}
|
1130 |
|
1131 |
+
$tracking_items = $wast->get_tracking_items( $order_id );
|
1132 |
+
|
1133 |
+
if ( 1 == $replace_tracking_info ) {
|
1134 |
+
|
1135 |
$order = wc_get_order($order_id);
|
1136 |
|
1137 |
+
if ( $order ) {
|
1138 |
+
|
|
|
1139 |
if ( count( $tracking_items ) > 0 ) {
|
1140 |
foreach ( $tracking_items as $key => $item ) {
|
1141 |
|
1143 |
|
1144 |
if ( class_exists( 'ast_woo_advanced_shipment_tracking_by_products' ) ) {
|
1145 |
$item_tracking_number = $item['tracking_number'];
|
1146 |
+
$tracking_exist = in_array( $item_tracking_number, array_column( $_POST['trackings'], 'tracking_number' ) );
|
1147 |
}
|
1148 |
|
1149 |
+
if( false == $tracking_exist ) {
|
1150 |
unset( $tracking_items[ $key ] );
|
1151 |
}
|
1152 |
}
|
1155 |
}
|
1156 |
}
|
1157 |
|
1158 |
+
if ( $shippment_provider && $tracking_number && $date_shipped ) {
|
1159 |
|
1160 |
$tracking_provider = $this->get_provider_slug_from_name( $tracking_provider );
|
1161 |
|
1166 |
'status_shipped' => wc_clean( $_POST['status_shipped'] ),
|
1167 |
);
|
1168 |
|
1169 |
+
if ( '' != $sku ) {
|
|
|
1170 |
|
1171 |
$products_list = array();
|
1172 |
|
1173 |
+
if ( $qty > 0 ) {
|
1174 |
+
|
1175 |
$product_id = wc_get_product_id_by_sku( $sku );
|
1176 |
|
1177 |
+
if ( $product_id ) {
|
1178 |
|
1179 |
$product_data = (object) array (
|
1180 |
'product' => $product_id,
|
1181 |
'qty' => $qty,
|
1182 |
);
|
1183 |
|
1184 |
+
array_push( $products_list, $product_data );
|
1185 |
|
1186 |
$product_data_array = array();
|
1187 |
+
$product_data_array[ $product_id ] = $qty;
|
1188 |
|
1189 |
+
$status_shipped = ( isset( $_POST["status_shipped"] ) ? $_POST["status_shipped"] : "" );
|
1190 |
|
1191 |
$autocomplete_order_tpi = get_option('autocomplete_order_tpi',0);
|
1192 |
+
if ( 1 == $autocomplete_order_tpi ) {
|
1193 |
$status_shipped = $this->autocomplete_order_after_adding_all_products( $order_id, $status_shipped, $products_list );
|
1194 |
$args['status_shipped'] = $status_shipped;
|
1195 |
}
|
1196 |
|
1197 |
if ( count( $tracking_items ) > 0 ) {
|
1198 |
foreach ( $tracking_items as $key => $item ) {
|
1199 |
+
if ( $item['tracking_number'] == $_POST['tracking_number'] ) {
|
1200 |
|
1201 |
+
if ( isset( $item['products_list'] ) && !empty( $item['products_list'] ) ) {
|
1202 |
|
1203 |
$product_list_array = array();
|
1204 |
+
foreach ( $item['products_list'] as $item_product_list ) {
|
1205 |
+
$product_list_array[ $item_product_list->product ] = $item_product_list->qty;
|
1206 |
}
|
1207 |
|
1208 |
$mearge_array = array();
|
1209 |
+
foreach ( array_keys( $product_data_array + $product_list_array ) as $product) {
|
1210 |
+
$mearge_array[ $product ] = (int)( isset( $product_data_array[ $product ] ) ? $product_data_array[ $product ] : 0 ) + (int)( isset( $product_list_array[$product] ) ? $product_list_array[ $product ] : 0);
|
1211 |
}
|
1212 |
|
1213 |
+
foreach ( $mearge_array as $productid => $product_qty ) {
|
1214 |
$merge_product_data[] = (object) array (
|
1215 |
'product' => $productid,
|
1216 |
'qty' => $product_qty,
|
1217 |
);
|
1218 |
}
|
1219 |
|
1220 |
+
if ( !empty( $merge_product_data ) ) {
|
1221 |
$tracking_items[ $key ]['products_list'] = $merge_product_data;
|
1222 |
$wast->save_tracking_items( $order_id, $tracking_items );
|
1223 |
|
1224 |
$order = new WC_Order( $order_id );
|
1225 |
|
1226 |
+
do_action( 'update_order_status_after_adding_tracking', $status_shipped, $order );
|
1227 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1228 |
echo '<li class="success">Success - added tracking info to Order '.$_POST['order_id'].'</li>';
|
1229 |
exit;
|
1230 |
}
|
1238 |
);
|
1239 |
}
|
1240 |
}
|
1241 |
+
$args = array_merge( $args, $product_args );
|
1242 |
}
|
1243 |
|
1244 |
$wast->add_tracking_item( $order_id, $args );
|
1245 |
+
|
1246 |
echo '<li class="success">Success - added tracking info to Order '.$_POST['order_id'].'</li>';exit;
|
1247 |
} else{
|
1248 |
echo '<li class="invalid_tracking_data_error">Failed - Invalid Tracking Data</li>';exit;
|
1249 |
}
|
1250 |
}
|
1251 |
|
1252 |
+
/*
|
1253 |
+
* Function for autocompleted order after adding all product through TPI
|
1254 |
+
*/
|
1255 |
+
public function autocomplete_order_after_adding_all_products( $order_id, $status_shipped, $products_list ) {
|
1256 |
|
1257 |
$order = wc_get_order( $order_id );
|
1258 |
$items = $order->get_items();
|
1259 |
+
$items_count = count( $items );
|
1260 |
|
1261 |
$added_products = $this->get_all_added_product_list_with_qty( $order_id );
|
1262 |
|
|
|
1263 |
$new_products = array();
|
|
|
|
|
1264 |
|
1265 |
+
foreach ( $products_list as $in_list ) {
|
1266 |
+
|
1267 |
+
if ( isset( $new_products[ $in_list->product ] ) ) {
|
1268 |
+
$new_products[ $in_list->product ] = (int)$new_products[ $in_list->product ] + (int)$in_list->qty;
|
1269 |
} else{
|
1270 |
+
$new_products[ $in_list->product ] = $in_list->qty;
|
1271 |
}
|
1272 |
}
|
1273 |
|
1274 |
$total_products_data = array();
|
1275 |
|
1276 |
+
foreach ( array_keys( $new_products + $added_products ) as $products ) {
|
1277 |
+
$total_products_data[ $products ] = ( isset( $new_products[ $products ] ) ? $new_products[ $products ] : 0 ) + ( isset( $added_products[ $products ] ) ? $added_products[ $products ] : 0);
|
1278 |
}
|
1279 |
|
1280 |
$orders_products_data = array();
|
1281 |
+
foreach ( $items as $item ) {
|
1282 |
$checked = 0;
|
1283 |
$qty = $item->get_quantity();
|
1284 |
|
1285 |
+
if ( 1 == $items_count && 1 == $qty ) {
|
1286 |
+
return $status_shipped;
|
1287 |
+
}
|
1288 |
|
1289 |
$variation_id = $item->get_variation_id();
|
1290 |
$product_id = $item->get_product_id();
|
1291 |
+
|
1292 |
+
if ( 0 != $variation_id ) {
|
1293 |
$product_id = $variation_id;
|
1294 |
}
|
1295 |
+
|
1296 |
+
$orders_products_data[ $product_id ] = $qty;
|
1297 |
}
|
1298 |
|
1299 |
$change_status = 0;
|
1300 |
$autocomplete_order = true;
|
1301 |
|
1302 |
+
foreach ( $orders_products_data as $product_id => $qty ) {
|
1303 |
+
if (isset( $total_products_data[ $product_id ] ) ) {
|
1304 |
+
if ( $qty > $total_products_data[ $product_id ] ) {
|
1305 |
$autocomplete_order = false;
|
1306 |
$change_status = 1;
|
1307 |
+
} else {
|
1308 |
$change_status = 1;
|
1309 |
}
|
1310 |
+
} else {
|
1311 |
$autocomplete_order = false;
|
1312 |
}
|
1313 |
}
|
1314 |
|
1315 |
+
if ( $autocomplete_order && 1 == $change_status ) {
|
1316 |
$status_shipped = 1;
|
1317 |
}
|
1318 |
return $status_shipped;
|
1319 |
}
|
1320 |
|
1321 |
+
/*
|
1322 |
+
* Function for get already added product in TPI
|
1323 |
+
*/
|
1324 |
+
public function get_all_added_product_list_with_qty( $order_id ) {
|
1325 |
|
1326 |
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
1327 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1328 |
|
1329 |
$product_list = array();
|
1330 |
|
1331 |
+
foreach ( $tracking_items as $tracking_item ) {
|
1332 |
+
if ( isset( $tracking_item[ 'products_list' ] ) ) {
|
1333 |
+
$product_list[] = $tracking_item[ 'products_list' ];
|
1334 |
}
|
1335 |
}
|
1336 |
|
1337 |
$all_list = array();
|
1338 |
+
foreach ( $product_list as $list ) {
|
1339 |
+
foreach ( $list as $in_list ) {
|
1340 |
+
if ( isset( $all_list[ $in_list->product ] ) ) {
|
1341 |
+
$all_list[ $in_list->product ] = (int)$all_list[ $in_list->product ] + (int)$in_list->qty;
|
1342 |
+
} else {
|
1343 |
+
$all_list[ $in_list->product ] = $in_list->qty;
|
1344 |
}
|
1345 |
}
|
1346 |
}
|
1347 |
+
|
1348 |
return $all_list;
|
1349 |
}
|
1350 |
|
1351 |
+
/*
|
1352 |
+
* Updated order status to Shipped(Completed), Partially Shipped, Updated Tracking
|
1353 |
+
*/
|
1354 |
+
public function update_order_status_after_adding_tracking( $status_shipped, $order ) {
|
1355 |
+
|
1356 |
+
$order_id = $order->get_id();
|
1357 |
+
|
1358 |
+
if ( 1 == $status_shipped ) {
|
1359 |
+
|
1360 |
+
$custom_shipped = apply_filters( 'check_for_custom_shipped', false, $status_shipped, $order );
|
1361 |
+
|
1362 |
+
if ( !$custom_shipped ) {
|
1363 |
+
if ( 'completed' == $order->get_status() ) {
|
1364 |
+
do_action( 'send_order_to_trackship', $order_id );
|
1365 |
+
} else{
|
1366 |
+
$order->update_status( 'completed' );
|
1367 |
+
}
|
1368 |
+
}
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
if ( 2 == $status_shipped ) {
|
1372 |
+
|
1373 |
+
$wc_ast_status_partial_shipped = get_option( 'wc_ast_status_partial_shipped' );
|
1374 |
+
|
1375 |
+
if ( $wc_ast_status_partial_shipped ) {
|
1376 |
+
|
1377 |
+
$previous_order_status = $order->get_status();
|
1378 |
+
|
1379 |
+
if ( 'partial-shipped' == $previous_order_status ) {
|
1380 |
+
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
$order->update_status('partial-shipped');
|
1384 |
+
do_action("send_order_to_trackship", $order_id);
|
1385 |
+
}
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
if ( 3 == $status_shipped ) {
|
1389 |
+
|
1390 |
+
$wc_ast_status_updated_tracking = get_option( 'wc_ast_status_updated_tracking' );
|
1391 |
+
|
1392 |
+
if ( $wc_ast_status_updated_tracking ) {
|
1393 |
+
|
1394 |
+
$previous_order_status = $order->get_status();
|
1395 |
+
|
1396 |
+
if ( 'updated-tracking' == $previous_order_status ) {
|
1397 |
+
WC()->mailer()->emails['WC_Email_Customer_Updated_Tracking_Order']->trigger( $order_id, $order );
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
$order->update_status( 'updated-tracking' );
|
1401 |
+
do_action( 'send_order_to_trackship', $order_id );
|
1402 |
+
}
|
1403 |
+
}
|
1404 |
+
}
|
1405 |
+
|
1406 |
/**
|
1407 |
* Check if the value is a valid date
|
1408 |
*
|
1410 |
*
|
1411 |
* @return boolean
|
1412 |
*/
|
1413 |
+
public function isDate( $date, $format = 'd-m-Y' ) {
|
1414 |
+
if ( !$date ) {
|
|
|
1415 |
return false;
|
1416 |
}
|
1417 |
|
1418 |
+
$d = DateTime::createFromFormat( $format, $date );
|
1419 |
// The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
|
1420 |
+
return $d && $d->format( $format ) === $date;
|
1421 |
}
|
1422 |
|
1423 |
/*
|
1424 |
* update preview order id in customizer
|
1425 |
*/
|
1426 |
+
public function update_email_preview_order_fun() {
|
1427 |
+
set_theme_mod( 'wcast_availableforpickup_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1428 |
+
set_theme_mod( 'wcast_returntosender_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1429 |
+
set_theme_mod( 'wcast_delivered_status_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1430 |
+
set_theme_mod( 'wcast_outfordelivery_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1431 |
+
set_theme_mod( 'wcast_intransit_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1432 |
+
set_theme_mod( 'wcast_onhold_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1433 |
+
set_theme_mod( 'wcast_pretransit_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1434 |
+
set_theme_mod( 'wcast_email_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1435 |
+
set_theme_mod( 'wcast_preview_order_id', wc_clean( $_POST['wcast_preview_order_id'] ) );
|
1436 |
exit;
|
1437 |
}
|
1438 |
|
1439 |
/*
|
1440 |
* Change completed order email title to Shipped Order
|
1441 |
*/
|
1442 |
+
public function change_completed_woocommerce_email_title( $email_title, $email ) {
|
1443 |
+
$wc_ast_status_shipped = get_option( 'wc_ast_status_shipped', 0 );
|
1444 |
// Only on backend Woocommerce Settings "Emails" tab
|
1445 |
+
if ( 1 == $wc_ast_status_shipped ) {
|
1446 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-settings' && isset( $_GET['tab'] ) && $_GET['tab'] == 'email' ) {
|
1447 |
+
switch ( $email->id ) {
|
1448 |
case 'customer_completed_order':
|
1449 |
+
$email_title = __( 'Shipped Order', 'woo-advanced-shipment-tracking' );
|
1450 |
break;
|
1451 |
}
|
1452 |
}
|
1457 |
/*
|
1458 |
* Add action button in order list to change order status from completed to delivered
|
1459 |
*/
|
1460 |
+
public function add_delivered_order_status_actions_button( $actions, $order ) {
|
1461 |
|
1462 |
wp_enqueue_style( 'ast_styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/admin.css', array(), wc_advanced_shipment_tracking()->version );
|
1463 |
wp_enqueue_script( 'woocommerce-advanced-shipment-tracking-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/admin.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version);
|
1464 |
|
1465 |
+
$wc_ast_status_delivered = get_option( 'wc_ast_status_delivered' );
|
1466 |
+
|
1467 |
+
if ( $wc_ast_status_delivered ) {
|
1468 |
+
if ( $order->has_status( array( 'completed' ) ) || $order->has_status( array( 'shipped' ) ) ) {
|
1469 |
+
|
1470 |
// Get Order ID (compatibility all WC versions)
|
1471 |
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
|
1472 |
+
|
1473 |
// Set the action button
|
1474 |
$actions['delivered'] = array(
|
1475 |
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=delivered&order_id=' . $order_id ), 'woocommerce-mark-order-status' ),
|
1483 |
$wc_ast_show_orders_actions = get_option( 'wc_ast_show_orders_actions' );
|
1484 |
$order_array = array();
|
1485 |
|
1486 |
+
foreach ( $wc_ast_show_orders_actions as $order_status => $value ) {
|
1487 |
+
if ( 1 == $value ) {
|
1488 |
+
array_push($order_array, $order_status);
|
1489 |
+
}
|
1490 |
}
|
1491 |
|
1492 |
+
if ( $order->get_shipping_method() != 'Local pickup' && $order->get_shipping_method() != 'Local Pickup' ) {
|
1493 |
if ( $order->has_status( $order_array ) ) {
|
1494 |
$actions['add_tracking'] = array(
|
1495 |
+
'url' => "#" . $order->get_id(),
|
1496 |
'name' => __( 'Add Tracking', 'woo-advanced-shipment-tracking' ),
|
1497 |
'icon' => '<i class="fa fa-map-marker"> </i>',
|
1498 |
+
'action' => 'add_inline_tracking', // keep "view" class for a clean button CSS
|
1499 |
);
|
1500 |
}
|
1501 |
}
|
1502 |
|
1503 |
+
$wc_ast_status_shipped = get_option( 'wc_ast_status_shipped' );
|
1504 |
+
if ( $wc_ast_status_shipped ) {
|
1505 |
$actions['complete']['name'] = __( 'Mark as Shipped', 'woo-advanced-shipment-tracking' );
|
1506 |
}
|
1507 |
|
1511 |
/*
|
1512 |
* Add delivered action button in preview order list to change order status from completed to delivered
|
1513 |
*/
|
1514 |
+
public function additional_admin_order_preview_buttons_actions( $actions, $order ) {
|
1515 |
+
|
1516 |
+
$wc_ast_status_delivered = get_option( 'wc_ast_status_delivered' );
|
1517 |
+
if ( $wc_ast_status_delivered ) {
|
1518 |
// Below set your custom order statuses (key / label / allowed statuses) that needs a button
|
1519 |
$custom_statuses = array(
|
1520 |
'delivered' => array( // The key (slug without "wc-")
|
1521 |
+
'label' => __( 'Delivered', 'woo-advanced-shipment-tracking' ), // Label name
|
1522 |
'allowed' => array( 'completed'), // Button displayed for this statuses (slugs without "wc-")
|
1523 |
),
|
1524 |
);
|
1526 |
// Loop through your custom orders Statuses
|
1527 |
foreach ( $custom_statuses as $status_slug => $values ){
|
1528 |
if ( $order->has_status( $values['allowed'] ) ) {
|
1529 |
+
$actions[ 'status' ][ 'group' ] = __( 'Change status: ', 'woocommerce' );
|
1530 |
+
$actions[ 'status' ][ 'actions' ][ $status_slug ] = array(
|
1531 |
+
'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status=' . $status_slug.'&order_id=' . $order->get_id() ), 'woocommerce-mark-order-status' ),
|
1532 |
'name' => $values['label'],
|
1533 |
+
'title' => __( 'Change order status to', 'woo-advanced-shipment-tracking' ) . ' ' . strtolower( $values['label'] ),
|
1534 |
'action' => $status_slug,
|
1535 |
);
|
1536 |
}
|
1542 |
/*
|
1543 |
* filter shipping providers by stats
|
1544 |
*/
|
1545 |
+
public function filter_shipiing_provider_by_status_fun() {
|
1546 |
+
|
1547 |
+
$status = wc_clean( $_POST['status'] );
|
1548 |
+
|
1549 |
global $wpdb;
|
1550 |
+
|
1551 |
+
if( 'active' == $status ){
|
1552 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE display_in_order = 1" );
|
1553 |
}
|
1554 |
+
|
1555 |
+
if ( 'inactive' == $status ) {
|
1556 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE display_in_order = 0" );
|
1557 |
}
|
1558 |
+
|
1559 |
+
if ( 'custom' == $status ) {
|
1560 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_default = 0" );
|
1561 |
}
|
1562 |
+
|
1563 |
+
if( 'all' == $status ) {
|
1564 |
$status = '';
|
1565 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1566 |
}
|
1567 |
+
|
1568 |
+
$html = $this->get_provider_html( $default_shippment_providers, $status );
|
1569 |
+
echo $html;
|
1570 |
+
exit;
|
1571 |
}
|
1572 |
|
1573 |
/*
|
1574 |
* Get providers list html
|
1575 |
*/
|
1576 |
+
public function get_provider_html( $default_shippment_providers, $status ) {
|
1577 |
$WC_Countries = new WC_Countries();
|
1578 |
$upload_dir = wp_upload_dir();
|
1579 |
+
$ast_directory = $upload_dir['baseurl'] . '/ast-shipping-providers/'; ?>
|
|
|
|
|
1580 |
<div class="provider_list">
|
1581 |
<?php if($default_shippment_providers){
|
1582 |
if($status == 'custom'){
|
1589 |
<table class="wp-list-table widefat posts provder_table" id="shipping-provider-table">
|
1590 |
<thead>
|
1591 |
<tr>
|
1592 |
+
<th><?php esc_html_e( 'Shipping Providers', 'woo-advanced-shipment-tracking'); ?></th>
|
1593 |
+
<th><?php esc_html_e( 'Display Name', 'woo-advanced-shipment-tracking'); ?></th>
|
1594 |
<?php do_action('ast_shipping_provider_column_after_api_name'); ?>
|
1595 |
+
<th><?php esc_html_e( 'TrackShip', 'woo-advanced-shipment-tracking'); ?></th>
|
1596 |
+
<th><?php esc_html_e( 'Actions', 'woo-advanced-shipment-tracking'); ?></th>
|
1597 |
</tr>
|
1598 |
</thead>
|
1599 |
<tbody>
|
1600 |
<?php
|
1601 |
+
foreach ( $default_shippment_providers as $d_s_p ) {
|
1602 |
+
$class = ( 1 == $d_s_p->display_in_order ) ? 'enable' : 'disable' ;
|
1603 |
+
?>
|
1604 |
+
<tr class="<?php esc_html_e( $class ); ?>">
|
1605 |
<td>
|
1606 |
<?php
|
1607 |
$custom_thumb_id = $d_s_p->custom_thumb_id;
|
1608 |
+
if ( 1 == $d_s_p->shipping_default ) {
|
1609 |
+
if ( 0 != $custom_thumb_id ) {
|
1610 |
+
$image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array( '60', '60' ) );
|
1611 |
$provider_image = $image_attributes[0];
|
1612 |
+
} else {
|
1613 |
+
$provider_image = $ast_directory . '' . sanitize_title( $d_s_p->provider_name ) . '.png?v=' . wc_advanced_shipment_tracking()->version;
|
1614 |
}
|
1615 |
+
echo '<img class="provider-thumb" src="' . $provider_image . '">';
|
1616 |
+
} else {
|
1617 |
+
$image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array( '60', '60' ) );
|
|
|
1618 |
|
1619 |
+
if ( 0 != $custom_thumb_id ) {
|
1620 |
+
echo '<img class="provider-thumb" src="' . $image_attributes[0] . '">';
|
1621 |
+
} else {
|
1622 |
+
echo '<img class="provider-thumb" src="' . wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/images/icon-default.png">';
|
1623 |
+
}
|
1624 |
} ?>
|
1625 |
|
1626 |
</td>
|
1627 |
<td>
|
1628 |
<span class="provider_name">
|
1629 |
+
<?php
|
1630 |
+
esc_html_e( $d_s_p->provider_name );
|
1631 |
+
|
1632 |
+
if ( isset( $d_s_p->custom_provider_name ) && '' != $d_s_p->custom_provider_name ) {
|
1633 |
+
esc_html_e( ' (' . $d_s_p->custom_provider_name . ')' );
|
1634 |
+
}
|
1635 |
+
|
1636 |
+
if ( isset( $d_s_p->api_provider_name ) && '' != $d_s_p->api_provider_name ) {
|
1637 |
+
|
1638 |
+
if ( $this->isJSON( $d_s_p->api_provider_name ) ) {
|
1639 |
+
$api_count = count( json_decode( $d_s_p->api_provider_name ) );
|
1640 |
+
} else {
|
1641 |
$api_count = 1;
|
1642 |
}
|
1643 |
$api_text = __('API aliases','woo-advanced-shipment-tracking');
|
1644 |
+
esc_html_e( ' (' . $api_count . ' ' . $api_text . ')' );
|
1645 |
}
|
1646 |
?>
|
1647 |
</span>
|
1648 |
+
<span class="provider_country">
|
1649 |
+
<?php
|
1650 |
$search = array('(US)', '(UK)');
|
1651 |
$replace = array('', '');
|
1652 |
+
|
1653 |
+
if ( $d_s_p->shipping_country && 'Global' != $d_s_p->shipping_country ) {
|
1654 |
+
esc_html_e( str_replace( $search, $replace, $WC_Countries->countries[ $d_s_p->shipping_country ] ) );
|
1655 |
+
} elseif ( $d_s_p->shipping_country && 'Global' == $d_s_p->shipping_country ) {
|
1656 |
+
esc_html_e( 'Global' );
|
1657 |
+
}
|
1658 |
+
?>
|
1659 |
</span>
|
1660 |
|
1661 |
+
<?php
|
1662 |
+
|
1663 |
+
if ( 0 == $d_s_p->shipping_default ) {
|
1664 |
+
echo '<span class="dashicons dashicons-trash remove provider_actions_btn" data-pid="' . $d_s_p->id . '"></span>';
|
1665 |
+
}
|
1666 |
+
|
1667 |
$edit_provider_class = apply_filters( 'edit_provider_class', 'edit_provider' );
|
|
|
1668 |
|
1669 |
+
$provider_type = ( 1 == $d_s_p->shipping_default ) ? 'default_provider' : 'custom_provider';
|
1670 |
|
1671 |
+
echo '<span class="' . $edit_provider_class . ' provider_actions_btn" data-provider="' . $provider_type . '" data-pid="' . $d_s_p->id . '">' . esc_html( 'edit', 'woo-advanced-shipment-tracking' ) . '</span>';
|
1672 |
+
|
1673 |
+
$default_provider = get_option( 'wc_ast_default_provider' );
|
1674 |
|
1675 |
+
$label_class = ( 1 != $d_s_p->display_in_order ) ? 'disable_label' : '';
|
1676 |
+
$make_default_checked = ( $default_provider == $d_s_p->provider_name ) ? 'checked' : '';
|
1677 |
+
$make_default_disabled = ( 1 != $d_s_p->display_in_order ) ? 'disabled' : '';
|
1678 |
+
?>
|
1679 |
+
|
1680 |
+
<label for="make_default_<?php esc_html_e( $d_s_p->id ); ?>" id="default_label_<?php esc_html_e( $d_s_p->id ); ?>" class="<?php esc_html_e( $label_class ); ?>">
|
1681 |
+
<input type="checkbox" id="make_default_<?php esc_html_e( $d_s_p->id ); ?>" name="make_provider_default" data-id="<?php esc_html_e( $d_s_p->id ); ?>" class="make_provider_default" value="<?php esc_html_e( $d_s_p->provider_name ); ?>" <?php esc_html_e( $make_default_checked ); ?> <?php esc_html_e( $make_default_disabled ); ?>>
|
1682 |
+
<span class="default_label"><?php esc_html_e( 'default', 'woo-advanced-shipment-tracking' ); ?></span>
|
1683 |
</label>
|
1684 |
</td>
|
1685 |
+
|
1686 |
<?php do_action('ast_shipping_provider_column_content_after_api_name', $d_s_p->provider_name); ?>
|
1687 |
+
|
1688 |
<td class="provider_trackship_td">
|
1689 |
+
<?php
|
1690 |
+
if ( 1 == $d_s_p->trackship_supported ) {
|
1691 |
+
echo '<span class="dashicons dashicons-yes-alt"></span>';
|
1692 |
+
} else {
|
1693 |
+
echo '<span class="dashicons dashicons-dismiss"></span>';
|
1694 |
+
} ?>
|
1695 |
+
<span>TrackShip</span>
|
1696 |
</td>
|
1697 |
+
|
1698 |
<td>
|
1699 |
+
<input class="ast-tgl ast-tgl-flat status_slide" id="list-switch-<?php esc_html_e( $d_s_p->id ); ?>" name="select_custom_provider[]" type="checkbox" <?php if( 1 == $d_s_p->display_in_order ) { esc_html_e( 'checked' ); } ?> value="<?php esc_html_e( $d_s_p->id ); ?>"/>
|
1700 |
+
<label class="ast-tgl-btn" for="list-switch-<?php esc_html_e( $d_s_p->id ); ?>"></label>
|
1701 |
</td>
|
1702 |
</tr>
|
1703 |
<?php } ?>
|
1707 |
<div class="shipping_provider_counter counter"></div>
|
1708 |
<div class="paging shipping_provider_paging"></div>
|
1709 |
</div>
|
1710 |
+
<?php } else {
|
1711 |
+
if ( 'custom' == $status ) { ?>
|
1712 |
+
<p class="provider_message"><?php printf( esc_html_e( 'You did not create any %s shipping providers yet.', 'woo-advanced-shipment-tracking' ), $status ); ?></p>
|
1713 |
+
<a href="javaScript:void(0);" class="button-primary btn_ast2 btn_large add_custom_provider" id="add-custom">
|
1714 |
+
<span class="dashicons dashicons-plus-alt"></span>
|
1715 |
+
<?php esc_html_e( 'Add Custom Provider', 'woo-advanced-shipment-tracking' ); ?>
|
1716 |
+
</a>
|
1717 |
+
<?php } else { ?>
|
1718 |
+
<p class="provider_message"><?php printf( esc_html_e( "You don't have any %s shipping providers.", 'woo-advanced-shipment-tracking' ), $status ); ?></p>
|
1719 |
+
<?php
|
1720 |
+
}
|
1721 |
+
}
|
1722 |
+
?>
|
1723 |
</div>
|
1724 |
<?php
|
1725 |
}
|
1727 |
/*
|
1728 |
* Check if valid json
|
1729 |
*/
|
1730 |
+
public function isJSON( $string ) {
|
1731 |
+
return is_string( $string ) && is_array( json_decode( $string, true ) ) && ( json_last_error() == JSON_ERROR_NONE ) ? true : false;
|
1732 |
}
|
1733 |
|
1734 |
/*
|
1735 |
* Update shipment provider status
|
1736 |
*/
|
1737 |
+
public function update_shipment_status_fun() {
|
1738 |
global $wpdb;
|
1739 |
+
$success = $wpdb->update( $this->table,
|
|
|
1740 |
array(
|
1741 |
+
"display_in_order" => wc_clean( $_POST['checked'] ),
|
1742 |
),
|
1743 |
+
array( 'id' => wc_clean( $_POST['id'] ) )
|
1744 |
);
|
1745 |
exit;
|
1746 |
}
|
1748 |
/**
|
1749 |
* update default provider function
|
1750 |
*/
|
1751 |
+
public function update_default_provider_fun() {
|
1752 |
+
if ( 1 == $_POST['checked'] ) {
|
1753 |
+
update_option( 'wc_ast_default_provider', wc_clean( $_POST['default_provider'] ) );
|
1754 |
+
} else {
|
1755 |
+
update_option( 'wc_ast_default_provider', '' );
|
1756 |
}
|
1757 |
exit;
|
1758 |
}
|
1760 |
/**
|
1761 |
* Create slug from title
|
1762 |
*/
|
1763 |
+
public static function create_slug( $text ) {
|
1764 |
// replace non letter or digits by -
|
1765 |
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
|
1766 |
|
1781 |
|
1782 |
$text = 'cp-'.$text;
|
1783 |
|
1784 |
+
if ( empty( $text ) ) {
|
1785 |
return '';
|
1786 |
}
|
1787 |
|
1791 |
/**
|
1792 |
* Add custom shipping provider function
|
1793 |
*/
|
1794 |
+
public function add_custom_shipment_provider_fun() {
|
1795 |
|
1796 |
global $wpdb;
|
1797 |
+
$provider_slug = $this->create_slug( wc_clean($_POST['shipping_provider'] ) );
|
1798 |
|
1799 |
+
if ( '' == $provider_slug ) {
|
1800 |
+
$provider_slug = sanitize_text_field( $_POST['shipping_provider'] );
|
|
|
|
|
1801 |
}
|
1802 |
|
1803 |
$data_array = array(
|
1804 |
+
'shipping_country' => sanitize_text_field( $_POST['shipping_country'] ),
|
1805 |
+
'provider_name' => sanitize_text_field( $_POST['shipping_provider'] ),
|
1806 |
+
'custom_provider_name' => sanitize_text_field( $_POST['shipping_display_name'] ),
|
1807 |
'ts_slug' => $provider_slug,
|
1808 |
+
'provider_url' => sanitize_text_field( $_POST['tracking_url'] ),
|
1809 |
+
'custom_thumb_id' => sanitize_text_field( $_POST['thumb_id'] ),
|
1810 |
'display_in_order' => 1,
|
1811 |
'shipping_default' => 0,
|
1812 |
);
|
1813 |
|
1814 |
+
$result = $wpdb->insert( $this->table, $data_array );
|
1815 |
|
1816 |
$status = 'all';
|
1817 |
+
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1818 |
+
$html = $this->get_provider_html( $default_shippment_providers, $status );
|
1819 |
+
echo $html;
|
1820 |
+
exit;
|
1821 |
}
|
1822 |
|
1823 |
/*
|
1825 |
*/
|
1826 |
public function woocommerce_shipping_provider_delete(){
|
1827 |
|
1828 |
+
$provider_id = wc_clean( $_POST['provider_id'] );
|
1829 |
+
|
1830 |
if ( ! empty( $provider_id ) ) {
|
1831 |
global $wpdb;
|
1832 |
$where = array(
|
1837 |
}
|
1838 |
$status = 'all';
|
1839 |
|
1840 |
+
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1841 |
+
$html = $this->get_provider_html( $default_shippment_providers, $status );
|
1842 |
+
echo $html;
|
1843 |
+
exit;
|
1844 |
}
|
1845 |
|
1846 |
/**
|
1847 |
* Get shipping provider details fun
|
1848 |
*/
|
1849 |
public function get_provider_details_fun(){
|
1850 |
+
$id = wc_clean( $_POST['provider_id'] );
|
1851 |
global $wpdb;
|
1852 |
+
|
1853 |
+
$shippment_provider = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table WHERE id=%d", $id ) );
|
1854 |
+
|
1855 |
+
if ( 0 != $shippment_provider[0]->custom_thumb_id ) {
|
1856 |
+
$image = wp_get_attachment_url( $shippment_provider[0]->custom_thumb_id );
|
1857 |
+
} else {
|
1858 |
+
$image = null;
|
1859 |
}
|
1860 |
|
1861 |
$provider_name = $shippment_provider[0]->provider_name;
|
1862 |
$custom_provider_name = $shippment_provider[0]->custom_provider_name;
|
1863 |
$api_provider_name = $shippment_provider[0]->api_provider_name;
|
1864 |
|
1865 |
+
echo json_encode( array('id' => $shippment_provider[0]->id,'provider_name' => $provider_name,'custom_provider_name' => $custom_provider_name,'api_provider_name' => $api_provider_name,'provider_url' => $shippment_provider[0]->provider_url,'shipping_country' => $shippment_provider[0]->shipping_country,'custom_thumb_id' => $shippment_provider[0]->custom_thumb_id,'image' => $image) );
|
1866 |
+
exit;
|
1867 |
}
|
1868 |
|
1869 |
/**
|
1873 |
|
1874 |
global $wpdb;
|
1875 |
|
1876 |
+
if ( [] == array_filter( $_POST['api_provider_name'] ) ) {
|
1877 |
+
$api_provider_name = null;
|
1878 |
+
} else {
|
1879 |
+
$api_provider_name = wc_clean( json_encode( $_POST['api_provider_name'] ) );
|
1880 |
}
|
1881 |
|
1882 |
$provider_type = $_POST['provider_type'];
|
1883 |
+
if ( 'default_provider' == $provider_type ) {
|
1884 |
$data_array = array(
|
1885 |
+
'custom_provider_name' => sanitize_text_field( $_POST['shipping_display_name'] ),
|
1886 |
'api_provider_name' => $api_provider_name,
|
1887 |
+
'custom_thumb_id' => sanitize_text_field( $_POST['thumb_id'] ),
|
1888 |
);
|
1889 |
} else{
|
1890 |
$data_array = array(
|
1891 |
+
'shipping_country' => sanitize_text_field( $_POST['shipping_country'] ),
|
1892 |
+
'provider_name' => sanitize_text_field( $_POST['shipping_provider'] ),
|
1893 |
+
'custom_provider_name' => sanitize_text_field( $_POST['shipping_display_name'] ),
|
1894 |
+
'ts_slug' => sanitize_title( $_POST['shipping_provider'] ),
|
1895 |
+
'custom_thumb_id' => sanitize_text_field( $_POST['thumb_id'] ),
|
1896 |
+
'provider_url' => sanitize_text_field( $_POST['tracking_url'] )
|
1897 |
);
|
1898 |
}
|
1899 |
|
1903 |
$wpdb->update( $this->table, $data_array, $where_array );
|
1904 |
$status = 'active';
|
1905 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1906 |
+
$html = $this->get_provider_html( $default_shippment_providers, $status );
|
1907 |
+
echo $html;
|
1908 |
+
exit;
|
1909 |
}
|
1910 |
|
1911 |
/**
|
1925 |
$wpdb->update( $this->table, $data_array, $where_array );
|
1926 |
$status = 'active';
|
1927 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1928 |
+
$html = $this->get_provider_html( $default_shippment_providers, $status );
|
1929 |
+
echo $html;
|
1930 |
+
exit;
|
1931 |
}
|
1932 |
|
1933 |
/**
|
1940 |
'display_in_order' => $_POST['status'],
|
1941 |
);
|
1942 |
|
1943 |
+
$display_in_order = ( 1 == $_POST['status'] ) ? 0 : 1;
|
|
|
|
|
|
|
|
|
1944 |
|
1945 |
$where_array = array(
|
1946 |
'display_in_order' => $display_in_order,
|
1949 |
$wpdb->update( $this->table, $data_array, $where_array );
|
1950 |
$status = 'all';
|
1951 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1952 |
+
$html = $this->get_provider_html( $default_shippment_providers, $status );
|
1953 |
exit;
|
1954 |
}
|
1955 |
|
1962 |
global $typenow, $wpdb;
|
1963 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
1964 |
|
1965 |
+
if ( 'shop_order' === $typenow ) {
|
1966 |
+
?>
|
1967 |
<select name="_shop_order_shipping_provider" id="dropdown_shop_order_shipping_provider">
|
1968 |
+
<option value=""><?php esc_html_e( 'Filter by shipping provider', 'woo-advanced-shipment-tracking' ); ?></option>
|
1969 |
<?php foreach ( $default_shippment_providers as $provider ) : ?>
|
1970 |
<option value="<?php echo esc_attr( $provider->ts_slug ); ?>" <?php echo esc_attr( isset( $_GET['_shop_order_shipping_provider'] ) ? selected( $provider->ts_slug, $_GET['_shop_order_shipping_provider'], false ) : '' ); ?>>
|
1971 |
<?php printf( '%1$s', esc_html( $provider->provider_name ) ); ?>
|
1972 |
</option>
|
1973 |
<?php endforeach; ?>
|
1974 |
</select>
|
1975 |
+
<?php
|
1976 |
}
|
1977 |
}
|
1978 |
|
1983 |
* @param array $vars query vars without filtering
|
1984 |
* @return array $vars query vars with (maybe) filtering
|
1985 |
*/
|
1986 |
+
public function filter_orders_by_shipping_provider_query( $vars ) {
|
1987 |
global $typenow;
|
1988 |
+
if ( 'shop_order' === $typenow && isset( $_GET['_shop_order_shipping_provider'] ) && '' != $_GET['_shop_order_shipping_provider'] ) {
|
1989 |
$vars['meta_query'][] = array(
|
1990 |
'key' => '_wc_shipment_tracking_items',
|
1991 |
'value' => $_GET['_shop_order_shipping_provider'],
|
2003 |
* @param array $vars query vars without filtering
|
2004 |
* @return array $vars query vars with (maybe) filtering
|
2005 |
*/
|
2006 |
+
public function filter_orders_by_tracking_number_query( $search_fields ) {
|
2007 |
$search_fields[] = '_wc_shipment_tracking_items';
|
2008 |
return $search_fields;
|
2009 |
}
|
2013 |
*
|
2014 |
* return array
|
2015 |
*/
|
2016 |
+
public function get_zorem_pluginlist() {
|
2017 |
|
2018 |
if ( !empty( $this->zorem_pluginlist ) ) return $this->zorem_pluginlist;
|
2019 |
|
2032 |
return $this->zorem_pluginlist = $plugin_list;
|
2033 |
}
|
2034 |
|
2035 |
+
public function update_custom_order_status_email_display_fun() {
|
2036 |
|
2037 |
+
$status = wc_clean( $_POST['status'] );
|
2038 |
|
2039 |
+
$wc_ast_show_orders_actions = get_option( 'wc_ast_show_orders_actions' );
|
2040 |
$wc_ast_show_orders_actions[$status] = 1;
|
2041 |
update_option( 'wc_ast_show_orders_actions', $wc_ast_show_orders_actions );
|
2042 |
|
2043 |
+
$wc_ast_unclude_tracking_info = get_option( 'wc_ast_unclude_tracking_info' );
|
2044 |
$wc_ast_unclude_tracking_info[$status] = 1;
|
2045 |
update_option( 'wc_ast_unclude_tracking_info', $wc_ast_unclude_tracking_info );
|
2046 |
}
|
2050 |
*
|
2051 |
* return provider slug
|
2052 |
*/
|
2053 |
+
public function get_provider_slug_from_name( $tracking_provider_name ) {
|
2054 |
|
2055 |
global $wpdb;
|
2056 |
|
2057 |
$tracking_provider = $wpdb->get_var( $wpdb->prepare( "SELECT ts_slug FROM $this->table WHERE api_provider_name = '%s'", $tracking_provider_name ) );
|
2058 |
|
2059 |
+
if ( !$tracking_provider ) {
|
2060 |
$query = "SELECT ts_slug FROM $this->table WHERE JSON_CONTAINS(api_provider_name, '[".'"'.$tracking_provider_name.'"'."]')";
|
2061 |
$tracking_provider = $wpdb->get_var( $query );
|
2062 |
}
|
2063 |
|
2064 |
+
if ( !$tracking_provider ) {
|
2065 |
$tracking_provider = $wpdb->get_var( $wpdb->prepare( "SELECT ts_slug FROM $this->table WHERE provider_name = '%s'", $tracking_provider_name ) );
|
2066 |
}
|
2067 |
|
2068 |
+
if ( !$tracking_provider ) {
|
2069 |
$tracking_provider = $tracking_provider_name ;
|
2070 |
}
|
2071 |
|
includes/class-wc-advanced-shipment-tracking-api-call.php
CHANGED
@@ -19,25 +19,29 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
|
|
19 |
/*
|
20 |
* get trackship shipment status and update in order meta
|
21 |
*/
|
22 |
-
public function get_trackship_apicall( $order_id ){
|
23 |
|
24 |
$logger = wc_get_logger();
|
25 |
$context = array( 'source' => 'wc_ast_trackship' );
|
26 |
$array = array();
|
27 |
$order = wc_get_order( $order_id );
|
28 |
-
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
29 |
|
30 |
-
$
|
|
|
31 |
|
32 |
-
if( $tracking_items ){
|
33 |
-
foreach( ( array )$tracking_items as $key => $val ){
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
$tracking_number = trim($val['tracking_number']);
|
36 |
|
37 |
$tracking_provider = isset( $val['tracking_provider'] ) ? $val['tracking_provider'] : $val['custom_tracking_provider'];
|
38 |
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
39 |
|
40 |
-
if( isset($tracking_number) ){
|
41 |
|
42 |
//do api call
|
43 |
$response = $this->get_trackship_data( $order, $tracking_number, $tracking_provider );
|
@@ -55,59 +59,76 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
|
|
55 |
$hook = 'wcast_retry_trackship_apicall';
|
56 |
wp_schedule_single_event( $timestamp, $hook, $args );
|
57 |
|
58 |
-
$shipment_status = get_post_meta( $order->get_id(),
|
59 |
-
$ts_shipment_status = get_post_meta( $order->get_id(),
|
60 |
|
61 |
-
if( is_string($shipment_status) )
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
$shipment_status[$key]['status'] = "Something went wrong: {$error_message}";
|
65 |
-
$shipment_status[$key]['status_date'] = date(
|
66 |
|
67 |
$ts_shipment_status[$key]['status'] = $shipment_status[$key]['status'];
|
68 |
|
69 |
-
update_post_meta( $order_id,
|
70 |
-
update_post_meta( $order->get_id(),
|
71 |
|
72 |
} else {
|
73 |
|
74 |
$code = $response['response']['code'];
|
75 |
|
76 |
-
if(
|
|
|
77 |
//update trackers_balance, status_msg
|
78 |
-
if( !$this->isJson($response['body']) ){
|
79 |
return;
|
80 |
}
|
81 |
-
$body = json_decode($response['body'], true);
|
82 |
|
83 |
-
$
|
84 |
-
$ts_shipment_status = get_post_meta( $order->get_id(), "ts_shipment_status", true);
|
85 |
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
$shipment_status[$key]['pending_status'] = $body['status_msg'];
|
90 |
|
91 |
-
$shipment_status[$key]['status_date'] = date(
|
92 |
$shipment_status[$key]['est_delivery_date'] = '';
|
93 |
|
94 |
$ts_shipment_status[$key]['status'] = $shipment_status[$key]['pending_status'];
|
95 |
|
96 |
-
update_post_meta( $order_id,
|
97 |
-
update_post_meta( $order->get_id(),
|
98 |
|
99 |
-
if(isset($body['trackers_balance'])){
|
100 |
update_option('trackers_balance',$body['trackers_balance']);
|
101 |
}
|
102 |
} else {
|
103 |
//error like 400
|
104 |
$body = json_decode($response['body'], true);
|
105 |
|
106 |
-
$shipment_status = get_post_meta( $order->get_id(),
|
107 |
-
$ts_shipment_status = get_post_meta( $order->get_id(),
|
108 |
|
109 |
-
if( is_string($shipment_status) )
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
$shipment_status[$key]['status'] = "Error message : ".$body['message'];
|
113 |
$shipment_status[$key]['status_date'] = date("Y-m-d H:i:s");
|
@@ -115,8 +136,8 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
|
|
115 |
|
116 |
$ts_shipment_status[$key]['status'] = $shipment_status[$key]['status'];
|
117 |
|
118 |
-
update_post_meta( $order_id,
|
119 |
-
update_post_meta( $order->get_id(),
|
120 |
|
121 |
$logger = wc_get_logger();
|
122 |
$context = array( 'source' => 'Trackship_apicall_error' );
|
@@ -133,27 +154,23 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
|
|
133 |
/*
|
134 |
* get trackship shipment data
|
135 |
*/
|
136 |
-
public function get_trackship_data( $order, $tracking_number, $tracking_provider ){
|
137 |
-
$user_key = get_option("wc_ast_api_key");
|
138 |
-
$domain = get_home_url();
|
139 |
-
$order_id = $order->get_id();
|
140 |
|
141 |
-
$
|
142 |
-
$
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
}
|
147 |
|
148 |
-
if($order->get_shipping_country()
|
149 |
$shipping_country = $order->get_shipping_country();
|
150 |
-
} else{
|
151 |
$shipping_country = $order->get_billing_country();
|
152 |
}
|
153 |
|
154 |
-
if($order->get_shipping_postcode()
|
155 |
$shipping_postal_code = $order->get_shipping_postcode();
|
156 |
-
} else{
|
157 |
$shipping_postal_code = $order->get_billing_postcode();
|
158 |
}
|
159 |
|
@@ -162,7 +179,7 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
|
|
162 |
$args['body'] = array(
|
163 |
'user_key' => $user_key,
|
164 |
'order_id' => $order_id,
|
165 |
-
'custom_order_id' => $
|
166 |
'domain' => $domain,
|
167 |
'tracking_number' => $tracking_number,
|
168 |
'tracking_provider' => $tracking_provider,
|
@@ -181,8 +198,9 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
|
|
181 |
/*
|
182 |
* delete tracking number from trackship
|
183 |
*/
|
184 |
-
public function delete_tracking_number_from_trackship($order_id, $tracking_number, $tracking_provider){
|
185 |
-
|
|
|
186 |
$domain = get_site_url();
|
187 |
|
188 |
$url = 'https://trackship.info/wp-json/tracking/delete';
|
19 |
/*
|
20 |
* get trackship shipment status and update in order meta
|
21 |
*/
|
22 |
+
public function get_trackship_apicall( $order_id ) {
|
23 |
|
24 |
$logger = wc_get_logger();
|
25 |
$context = array( 'source' => 'wc_ast_trackship' );
|
26 |
$array = array();
|
27 |
$order = wc_get_order( $order_id );
|
|
|
28 |
|
29 |
+
$tracking_items = ast_get_tracking_items( $order_id );
|
30 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
31 |
|
32 |
+
if ( $tracking_items ){
|
33 |
+
foreach ( ( array ) $tracking_items as $key => $val ) {
|
34 |
+
|
35 |
+
if ( isset( $shipment_status[$key]['status'] ) && 'delivered' == $shipment_status[$key]['status'] ) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
|
39 |
$tracking_number = trim($val['tracking_number']);
|
40 |
|
41 |
$tracking_provider = isset( $val['tracking_provider'] ) ? $val['tracking_provider'] : $val['custom_tracking_provider'];
|
42 |
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
43 |
|
44 |
+
if ( isset( $tracking_number ) ) {
|
45 |
|
46 |
//do api call
|
47 |
$response = $this->get_trackship_data( $order, $tracking_number, $tracking_provider );
|
59 |
$hook = 'wcast_retry_trackship_apicall';
|
60 |
wp_schedule_single_event( $timestamp, $hook, $args );
|
61 |
|
62 |
+
$shipment_status = get_post_meta( $order->get_id(), 'shipment_status', true);
|
63 |
+
$ts_shipment_status = get_post_meta( $order->get_id(), 'ts_shipment_status', true);
|
64 |
|
65 |
+
if ( is_string( $shipment_status ) ) {
|
66 |
+
$shipment_status = array();
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( is_string( $ts_shipment_status ) ) {
|
70 |
+
$ts_shipment_status = array();
|
71 |
+
}
|
72 |
|
73 |
$shipment_status[$key]['status'] = "Something went wrong: {$error_message}";
|
74 |
+
$shipment_status[$key]['status_date'] = date( 'Y-m-d H:i:s' );
|
75 |
|
76 |
$ts_shipment_status[$key]['status'] = $shipment_status[$key]['status'];
|
77 |
|
78 |
+
update_post_meta( $order_id, 'ts_shipment_status', $ts_shipment_status);
|
79 |
+
update_post_meta( $order->get_id(), 'shipment_status', $shipment_status);
|
80 |
|
81 |
} else {
|
82 |
|
83 |
$code = $response['response']['code'];
|
84 |
|
85 |
+
if ( 200 == $code ) {
|
86 |
+
|
87 |
//update trackers_balance, status_msg
|
88 |
+
if ( !$this->isJson( $response['body'] ) ) {
|
89 |
return;
|
90 |
}
|
|
|
91 |
|
92 |
+
$body = json_decode( $response['body'], true );
|
|
|
93 |
|
94 |
+
$shipment_status = get_post_meta( $order->get_id(), 'shipment_status', true);
|
95 |
+
$ts_shipment_status = get_post_meta( $order->get_id(), 'ts_shipment_status', true);
|
96 |
+
|
97 |
+
if ( is_string( $shipment_status ) ) {
|
98 |
+
$shipment_status = array();
|
99 |
+
}
|
100 |
+
|
101 |
+
if ( is_string( $ts_shipment_status ) ) {
|
102 |
+
$ts_shipment_status = array();
|
103 |
+
}
|
104 |
|
105 |
$shipment_status[$key]['pending_status'] = $body['status_msg'];
|
106 |
|
107 |
+
$shipment_status[$key]['status_date'] = date( 'Y-m-d H:i:s' );
|
108 |
$shipment_status[$key]['est_delivery_date'] = '';
|
109 |
|
110 |
$ts_shipment_status[$key]['status'] = $shipment_status[$key]['pending_status'];
|
111 |
|
112 |
+
update_post_meta( $order_id, 'ts_shipment_status', $ts_shipment_status);
|
113 |
+
update_post_meta( $order->get_id(), 'shipment_status', $shipment_status);
|
114 |
|
115 |
+
if ( isset( $body['trackers_balance'] ) ) {
|
116 |
update_option('trackers_balance',$body['trackers_balance']);
|
117 |
}
|
118 |
} else {
|
119 |
//error like 400
|
120 |
$body = json_decode($response['body'], true);
|
121 |
|
122 |
+
$shipment_status = get_post_meta( $order->get_id(), 'shipment_status', true);
|
123 |
+
$ts_shipment_status = get_post_meta( $order->get_id(), 'ts_shipment_status', true);
|
124 |
|
125 |
+
if ( is_string( $shipment_status ) ) {
|
126 |
+
$shipment_status = array();
|
127 |
+
}
|
128 |
+
|
129 |
+
if ( is_string( $ts_shipment_status ) ) {
|
130 |
+
$ts_shipment_status = array();
|
131 |
+
}
|
132 |
|
133 |
$shipment_status[$key]['status'] = "Error message : ".$body['message'];
|
134 |
$shipment_status[$key]['status_date'] = date("Y-m-d H:i:s");
|
136 |
|
137 |
$ts_shipment_status[$key]['status'] = $shipment_status[$key]['status'];
|
138 |
|
139 |
+
update_post_meta( $order_id, 'ts_shipment_status', $ts_shipment_status);
|
140 |
+
update_post_meta( $order->get_id(), 'shipment_status', $shipment_status);
|
141 |
|
142 |
$logger = wc_get_logger();
|
143 |
$context = array( 'source' => 'Trackship_apicall_error' );
|
154 |
/*
|
155 |
* get trackship shipment data
|
156 |
*/
|
157 |
+
public function get_trackship_data( $order, $tracking_number, $tracking_provider ) {
|
|
|
|
|
|
|
158 |
|
159 |
+
$user_key = get_option( 'wc_ast_api_key' );
|
160 |
+
$domain = get_home_url();
|
161 |
|
162 |
+
$order_id = $order->get_id();
|
163 |
+
$order_number = $order->get_order_number();
|
|
|
164 |
|
165 |
+
if ( null != $order->get_shipping_country() ) {
|
166 |
$shipping_country = $order->get_shipping_country();
|
167 |
+
} else {
|
168 |
$shipping_country = $order->get_billing_country();
|
169 |
}
|
170 |
|
171 |
+
if ( null != $order->get_shipping_postcode() ) {
|
172 |
$shipping_postal_code = $order->get_shipping_postcode();
|
173 |
+
} else {
|
174 |
$shipping_postal_code = $order->get_billing_postcode();
|
175 |
}
|
176 |
|
179 |
$args['body'] = array(
|
180 |
'user_key' => $user_key,
|
181 |
'order_id' => $order_id,
|
182 |
+
'custom_order_id' => $order_number,
|
183 |
'domain' => $domain,
|
184 |
'tracking_number' => $tracking_number,
|
185 |
'tracking_provider' => $tracking_provider,
|
198 |
/*
|
199 |
* delete tracking number from trackship
|
200 |
*/
|
201 |
+
public function delete_tracking_number_from_trackship( $order_id, $tracking_number, $tracking_provider ) {
|
202 |
+
|
203 |
+
$user_key = get_option( 'wc_ast_api_key' );
|
204 |
$domain = get_site_url();
|
205 |
|
206 |
$url = 'https://trackship.info/wp-json/tracking/delete';
|
includes/class-wc-advanced-shipment-tracking-cron.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
} // Exit if accessed directly
|
6 |
-
|
7 |
-
class WC_Advanced_Shipment_Tracking_Cron {
|
8 |
-
|
9 |
-
const CRON_HOOK = 'wc_ast_cron';
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Remove the Cron
|
13 |
-
*
|
14 |
-
* @access public
|
15 |
-
* @since 1.0.0
|
16 |
-
*/
|
17 |
-
public function remove_cron() {
|
18 |
-
wp_clear_scheduled_hook( self::CRON_HOOK );
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Setup the Cron
|
23 |
-
* @access public
|
24 |
-
* @since 1.0.0
|
25 |
-
*/
|
26 |
-
public function setup_cron() {
|
27 |
-
|
28 |
-
// Add the count words cronjob
|
29 |
-
if ( ! wp_next_scheduled( self::CRON_HOOK ) ) {
|
30 |
-
|
31 |
-
$cron_timing = get_option("wc_ast_api_cron_time", "wc_ast_1day");
|
32 |
-
$send_time = get_option("wc_ast_api_run_time", "03:00");
|
33 |
-
|
34 |
-
// Create a Date Time object when the cron should run for the first time
|
35 |
-
$first_cron = new DateTime( date( 'Y-m-d' ) . $send_time.":00" , new DateTimeZone( wc_timezone_string() ) );
|
36 |
-
|
37 |
-
$hr_min = explode(":",$send_time);
|
38 |
-
if( $hr_min[0] <= date("H") ) $first_cron->modify( '+1 day' );
|
39 |
-
|
40 |
-
wp_schedule_event( $first_cron->format( 'U' ) + $first_cron->getOffset(), $cron_timing, self::CRON_HOOK );
|
41 |
-
}
|
42 |
-
}
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wc-advanced-shipment-tracking-front.php
CHANGED
@@ -19,18 +19,21 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
19 |
|
20 |
global $wpdb;
|
21 |
$this->table = $wpdb->prefix."woo_shippment_provider";
|
22 |
-
|
|
|
|
|
23 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
24 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
25 |
}
|
|
|
26 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
27 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
28 |
-
$this->table = $main_blog_prefix.
|
29 |
-
} else{
|
30 |
-
$this->table = $wpdb->prefix.
|
31 |
}
|
32 |
-
} else{
|
33 |
-
$this->table = $wpdb->prefix.
|
34 |
}
|
35 |
|
36 |
$this->init();
|
@@ -44,7 +47,7 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
44 |
public static function get_instance() {
|
45 |
|
46 |
if ( null === self::$instance ) {
|
47 |
-
self::$instance = new self;
|
48 |
}
|
49 |
|
50 |
return self::$instance;
|
@@ -53,20 +56,21 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
53 |
/*
|
54 |
* init from parent mail class
|
55 |
*/
|
56 |
-
public function init(){
|
57 |
-
|
|
|
58 |
add_action( 'wp_enqueue_scripts', array( $this, 'front_styles' ));
|
59 |
-
add_action( 'wp_ajax_nopriv_get_tracking_info', array( $this, 'get_tracking_info_fun') );
|
60 |
-
add_action( 'wp_ajax_get_tracking_info', array( $this, 'get_tracking_info_fun') );
|
61 |
|
62 |
-
add_action( 'wp_ajax_nopriv_ts_open_tracking_lightbox', array( $this, 'ts_open_tracking_lightbox') );
|
63 |
-
add_action( 'wp_ajax_ts_open_tracking_lightbox', array( $this, 'ts_open_tracking_lightbox') );
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* Include front js and css
|
68 |
*/
|
69 |
-
public function front_styles(){
|
70 |
|
71 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
72 |
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
@@ -75,62 +79,67 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
75 |
|
76 |
wp_register_style( 'front_style', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/front.css', array(), wc_advanced_shipment_tracking()->version );
|
77 |
|
78 |
-
$action = (isset($_REQUEST[
|
79 |
|
80 |
-
if(
|
81 |
wp_enqueue_style( 'front_style' );
|
82 |
wp_enqueue_script( 'front-js' );
|
83 |
-
}
|
84 |
-
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
* Return tracking details or tracking form for shortcode - [wcast-track-order]
|
89 |
*/
|
90 |
-
public function woo_track_order_function(){
|
91 |
|
92 |
wp_enqueue_style( 'front_style' );
|
93 |
wp_enqueue_script( 'jquery-blockui' );
|
94 |
wp_enqueue_script( 'front-js' );
|
95 |
|
96 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
97 |
|
98 |
-
if(!$wc_ast_api_key){
|
|
|
99 |
<p><a href="https://trackship.info/" target="blank">TrackShip</a> is not active.</p>
|
100 |
-
<?php
|
|
|
101 |
}
|
102 |
|
103 |
-
if(isset($_GET['order_id']) && isset($_GET['order_key'])){
|
104 |
|
105 |
$order_id = wc_clean($_GET['order_id']);
|
106 |
|
107 |
$order = wc_get_order( $order_id );
|
108 |
|
109 |
-
if(empty($order))
|
|
|
|
|
110 |
|
111 |
$order_key = $order->get_order_key();
|
112 |
|
113 |
-
if($order_key != $_GET['order_key'])
|
|
|
|
|
114 |
|
115 |
-
if(empty($order))
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
|
119 |
-
} else {
|
120 |
-
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
121 |
-
}
|
122 |
|
123 |
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
124 |
|
125 |
-
if(!$tracking_items)
|
|
|
|
|
126 |
}
|
127 |
|
128 |
-
if(!isset($order_id)){
|
129 |
ob_start();
|
130 |
$this->track_form_template();
|
131 |
$form = ob_get_clean();
|
132 |
return $form;
|
133 |
-
} else{
|
134 |
ob_start();
|
135 |
echo $this->display_tracking_page( $order_id, $tracking_items, $shipment_status );
|
136 |
$form = ob_get_clean();
|
@@ -141,13 +150,13 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
141 |
/**
|
142 |
* Ajax function for get tracking details
|
143 |
*/
|
144 |
-
public function get_tracking_info_fun(){
|
145 |
|
146 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
147 |
|
148 |
-
if(!$wc_ast_api_key){
|
149 |
-
return;
|
150 |
-
}
|
151 |
|
152 |
$order_id = wc_clean($_POST['order_id']);
|
153 |
$email = sanitize_email($_POST['order_email']);
|
@@ -157,64 +166,66 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
157 |
|
158 |
$order = wc_get_order( $order_id );
|
159 |
|
160 |
-
if(empty($order)){
|
161 |
ob_start();
|
162 |
$this->track_form_template();
|
163 |
$form = ob_get_clean();
|
164 |
-
echo json_encode( array('success' => 'false', 'message' => __( 'Order not found.', 'woo-advanced-shipment-tracking' ), 'html' => $form ));
|
|
|
165 |
}
|
166 |
|
167 |
$order_id = $wast->get_formated_order_id($order_id);
|
168 |
$order_email = $order->get_billing_email();
|
169 |
|
170 |
-
if(strtolower($order_email) != strtolower($email)){
|
171 |
ob_start();
|
172 |
$this->track_form_template();
|
173 |
$form = ob_get_clean();
|
174 |
-
echo json_encode( array('success' => 'false', 'message' => __( 'Order not found.', 'woo-advanced-shipment-tracking' ), 'html' => $form ));
|
|
|
175 |
}
|
176 |
|
177 |
-
|
178 |
-
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
|
179 |
-
} else {
|
180 |
-
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
181 |
-
}
|
182 |
|
183 |
-
$shipment_status = get_post_meta( $order_id,
|
184 |
|
185 |
-
if(!$tracking_items){
|
186 |
ob_start();
|
187 |
$this->track_form_template();
|
188 |
$form = ob_get_clean();
|
189 |
-
echo json_encode( array('success' => 'false', 'message' => __( 'Tracking details not found', 'woo-advanced-shipment-tracking' ), 'html' => $form ));
|
|
|
190 |
}
|
|
|
191 |
ob_start();
|
192 |
$html = $this->display_tracking_page( $order_id, $tracking_items, $shipment_status );
|
193 |
$html = ob_get_clean();
|
194 |
-
echo json_encode( array('success' => 'true', 'message' => '', 'html' => $html ));
|
|
|
195 |
}
|
196 |
|
197 |
/**
|
198 |
* Ajax function for get tracking details lightbox
|
199 |
*/
|
200 |
-
public function ts_open_tracking_lightbox(){
|
|
|
201 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
202 |
|
203 |
-
if(!$wc_ast_api_key)
|
|
|
|
|
204 |
|
205 |
-
$order_id = wc_clean($_POST['order_id']);
|
206 |
-
$tracking_number = wc_clean($_POST['tracking_number']);
|
207 |
|
208 |
$order = wc_get_order( $order_id );
|
209 |
|
210 |
-
|
211 |
-
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
|
212 |
-
} else {
|
213 |
-
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
214 |
-
}
|
215 |
|
216 |
foreach( $tracking_items as $key => $tracking_item ){
|
217 |
-
if( $tracking_item['tracking_number'] != $tracking_number )
|
|
|
|
|
218 |
}
|
219 |
|
220 |
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
@@ -222,7 +233,8 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
222 |
ob_start();
|
223 |
$html = $this->display_tracking_page( $order_id, $tracking_items, $shipment_status );
|
224 |
$html = ob_get_clean();
|
225 |
-
echo $html;
|
|
|
226 |
}
|
227 |
|
228 |
/*
|
@@ -240,7 +252,7 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
240 |
/*
|
241 |
* retuern Tracking page HTML
|
242 |
*/
|
243 |
-
public function display_tracking_page( $order_id, $tracking_items, $shipment_status ){
|
244 |
|
245 |
wp_enqueue_style( 'front_style' );
|
246 |
wp_enqueue_script( 'jquery-blockui' );
|
@@ -258,7 +270,7 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
258 |
?>
|
259 |
|
260 |
<style>
|
261 |
-
<?php if($border_color){ ?>
|
262 |
body .col.tracking-detail{
|
263 |
border: 1px solid <?php echo $border_color; ?>;
|
264 |
}
|
@@ -278,9 +290,9 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
278 |
<?php
|
279 |
|
280 |
$num = 1;
|
281 |
-
$total_trackings = sizeof($tracking_items);
|
282 |
|
283 |
-
foreach($tracking_items as $key => $item){
|
284 |
$tracking_number = $item['tracking_number'];
|
285 |
$trackship_url = 'https://trackship.info';
|
286 |
$tracking_provider = $item['tracking_provider'];
|
@@ -295,22 +307,22 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
295 |
***/
|
296 |
$tracker = new \stdClass();
|
297 |
|
298 |
-
if( isset($shipment_status[$key]['pending_status']) ){
|
299 |
$tracker->ep_status = $shipment_status[$key]['pending_status'];
|
300 |
-
} else if( isset($shipment_status[$key]['status']) ){
|
301 |
$tracker->ep_status = $shipment_status[$key]['status'];
|
302 |
}
|
303 |
|
304 |
-
$tracker->est_delivery_date = isset( $shipment_status[$key]['est_delivery_date'] ) ? $shipment_status[$key]['est_delivery_date'] : '';
|
305 |
|
306 |
-
if( isset($shipment_status[$key]['tracking_events']) || isset($shipment_status[$key]['pending_status'])){
|
307 |
|
308 |
-
if( isset($shipment_status[$key]['tracking_events']) ){
|
309 |
-
$tracker->tracking_detail = json_encode($shipment_status[$key]['tracking_events']);
|
310 |
}
|
311 |
|
312 |
-
if(isset($shipment_status[$key]['tracking_destination_events'])){
|
313 |
-
$tracker->tracking_destination_events = json_encode($shipment_status[$key]['tracking_destination_events']);
|
314 |
}
|
315 |
|
316 |
$decoded_data = true;
|
@@ -319,108 +331,97 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
319 |
$tracking_detail_org = '';
|
320 |
$trackind_detail_by_status_rev = '';
|
321 |
|
322 |
-
if(isset($tracker->tracking_detail) && $tracker->tracking_detail
|
323 |
-
$tracking_detail_org = json_decode($tracker->tracking_detail);
|
324 |
-
$trackind_detail_by_status_rev = array_reverse($tracking_detail_org);
|
325 |
}
|
326 |
|
327 |
$tracking_details_by_date = array();
|
328 |
|
329 |
-
foreach((array)$trackind_detail_by_status_rev as $key => $details){
|
330 |
-
if(isset($details->datetime)){
|
331 |
-
$date = date('Y-m-d', strtotime($details->datetime));
|
332 |
-
$tracking_details_by_date[$date][] = $details;
|
333 |
}
|
334 |
}
|
335 |
|
336 |
$tracking_destination_detail_org = '';
|
337 |
$trackind_destination_detail_by_status_rev = '';
|
338 |
|
339 |
-
if(isset($tracker->tracking_destination_events) && $tracker->tracking_destination_events
|
340 |
-
$tracking_destination_detail_org = json_decode($tracker->tracking_destination_events);
|
341 |
-
|
342 |
-
$trackind_destination_detail_by_status_rev = array_reverse($tracking_destination_detail_org);
|
343 |
}
|
344 |
|
345 |
$tracking_destination_details_by_date = array();
|
346 |
|
347 |
-
foreach((array)$trackind_destination_detail_by_status_rev as $key => $details){
|
348 |
-
if(isset($details->datetime)){
|
349 |
-
$date = date('Y-m-d', strtotime($details->datetime));
|
350 |
$tracking_destination_details_by_date[$date][] = $details;
|
351 |
}
|
352 |
}
|
353 |
|
354 |
$order = wc_get_order( $order_id );
|
355 |
$order_url = $order->get_view_order_url();
|
|
|
356 |
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
if($tracking_page_layout == 't_layout_1'){ ?>
|
363 |
-
|
364 |
-
<div class="tracking-detail col">
|
365 |
-
|
366 |
<div class="shipment-header">
|
367 |
-
<?php if($total_trackings > 1 ){ ?>
|
368 |
-
<p class="shipment_heading"><?php
|
369 |
-
<span><?php
|
370 |
-
|
371 |
-
|
372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
<?php } ?>
|
374 |
-
</div>
|
375 |
-
<?php
|
376 |
-
echo $this->tracking_page_header( $order_id, $tracking_provider, $tracking_number, $tracker, $item, $custom_provider_name, $custom_thumb_id );
|
377 |
-
|
378 |
-
if($tracker->ep_status == 'pending_trackship' || $tracker->ep_status == 'INVALID_TRACKING_NUM' || $tracker->ep_status == 'carrier_unsupported' || $tracker->ep_status == 'invalid_user_key' || $tracker->ep_status == 'wrong_shipping_provider' || $tracker->ep_status == 'deleted' || $tracker->ep_status == 'pending'){
|
379 |
-
} elseif(isset($tracker->ep_status)){
|
380 |
-
echo $this->layout1_progress_bar($tracker);
|
381 |
-
}
|
382 |
-
|
383 |
-
if( !empty($trackind_detail_by_status_rev) ){
|
384 |
-
echo $this->layout1_tracking_details( $trackind_detail_by_status_rev, $tracking_details_by_date, $trackind_destination_detail_by_status_rev, $tracking_destination_details_by_date, $tracker , $order_id, $tracking_provider, $tracking_number );
|
385 |
-
}
|
386 |
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
if($remove_trackship_branding != 1){ ?>
|
412 |
-
<div class="trackship_branding">
|
413 |
-
<p>Shipment Tracking info by <a href="https://trackship.info/trackings/?number=<?php echo $tracking_number; ?>" title="TrackShip" target="blank"><img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-logo.png"></a></p>
|
414 |
-
</div>
|
415 |
-
<?php } ?>
|
416 |
-
|
417 |
</div>
|
418 |
-
<?php
|
|
|
|
|
419 |
<div class="tracking-detail col">
|
420 |
-
<h1 class="shipment_status_heading text-secondary text-center"><?php
|
421 |
-
<h3 class="text-center"><?php
|
422 |
</div>
|
423 |
-
|
|
|
424 |
$num++;
|
425 |
}
|
426 |
}
|
@@ -428,47 +429,25 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
428 |
/*
|
429 |
* Tracking Page Header
|
430 |
*/
|
431 |
-
public function tracking_page_header( $order_id, $
|
432 |
-
|
433 |
-
if(isset($tracker->est_delivery_date)){
|
434 |
-
$unixTimestamp = strtotime($tracker->est_delivery_date);
|
435 |
-
$day = date("l", $unixTimestamp);
|
436 |
-
}
|
437 |
$ts_tracking_page_customizer = new ts_tracking_page_customizer();
|
438 |
$wc_ast_link_to_shipping_provider = get_option('wc_ast_link_to_shipping_provider', $ts_tracking_page_customizer->defaults['wc_ast_link_to_shipping_provider'] );
|
439 |
$hide_tracking_provider_image = get_option('wc_ast_hide_tracking_provider_image', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_provider_image'] );
|
440 |
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
}
|
446 |
-
|
447 |
-
$upload_dir = wp_upload_dir();
|
448 |
-
$ast_directory = $upload_dir['baseurl'] . '/ast-shipping-providers/';
|
449 |
-
$ast_base_directory = $upload_dir['basedir'] . '/ast-shipping-providers/';
|
450 |
|
451 |
-
if($
|
452 |
-
|
453 |
-
$src = $image_attributes[0];
|
454 |
-
} else{
|
455 |
-
$src = $ast_directory.''.sanitize_title($tracking_provider).'.png?v='.wc_advanced_shipment_tracking()->version;
|
456 |
}
|
457 |
|
458 |
-
if($
|
459 |
-
$
|
460 |
-
} else{
|
461 |
-
$
|
462 |
-
}
|
463 |
-
|
464 |
-
include 'views/front/tracking_page_header.php';
|
465 |
-
}
|
466 |
-
|
467 |
-
public function layout1_progress_bar($tracker){
|
468 |
-
if($tracker->ep_status == 'pending_trackship' || $tracker->ep_status == 'INVALID_TRACKING_NUM' || $tracker->ep_status == 'carrier_unsupported' || $tracker->ep_status == 'invalid_user_key' || $tracker->ep_status == 'wrong_shipping_provider' || $tracker->ep_status == 'deleted' || $tracker->ep_status == 'pending' || $tracker->ep_status == 'unknown' || $tracker->ep_status == 'pre_transit' || $tracker->ep_status == 'failure'){
|
469 |
-
$width = '0';
|
470 |
-
} else if($tracker->ep_status == 'in_transit' || $tracker->ep_status == 'on_hold'){
|
471 |
-
$width = '33%';
|
472 |
} else if($tracker->ep_status == 'out_for_delivery'){
|
473 |
$width = '67%';
|
474 |
} else if($tracker->ep_status == 'available_for_pickup'){
|
@@ -477,36 +456,21 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
477 |
$width = '67%';
|
478 |
} else if($tracker->ep_status == 'delivered'){
|
479 |
$width = '100%';
|
480 |
-
}
|
481 |
-
|
|
|
|
|
|
|
|
|
482 |
<div class="progress">
|
483 |
-
<div class="progress-bar <?php
|
484 |
</div>
|
485 |
</div>
|
486 |
-
<?php
|
|
|
487 |
|
488 |
-
public function layout2_progress_bar($tracker){
|
489 |
-
if($tracker->ep_status == 'pending_trackship' || $tracker->ep_status == 'INVALID_TRACKING_NUM' || $tracker->ep_status == 'carrier_unsupported' || $tracker->ep_status == 'invalid_user_key' || $tracker->ep_status == 'wrong_shipping_provider' || $tracker->ep_status == 'deleted' || $tracker->ep_status == 'pending' || $tracker->ep_status == 'unknown' || $tracker->ep_status == 'pre_transit' || $tracker->ep_status == 'failure'){
|
490 |
-
$width = '0';
|
491 |
-
} else if($tracker->ep_status == 'in_transit' || $tracker->ep_status == 'on_hold'){
|
492 |
-
$width = '33%';
|
493 |
-
} else if($tracker->ep_status == 'out_for_delivery'){
|
494 |
-
$width = '67%';
|
495 |
-
} else if($tracker->ep_status == 'available_for_pickup'){
|
496 |
-
$width = '67%';
|
497 |
-
} else if($tracker->ep_status == 'return_to_sender'){
|
498 |
-
$width = '67%';
|
499 |
-
} else if($tracker->ep_status == 'delivered'){
|
500 |
-
$width = '100%';
|
501 |
-
} ?>
|
502 |
-
<div class="tracker-progress-bar">
|
503 |
-
<div class="progress">
|
504 |
-
<div class="progress-bar <?php echo $tracker->ep_status; ?>" style="width: <?php echo $width; ?>;"></div>
|
505 |
-
</div>
|
506 |
-
</div>
|
507 |
-
<?php }
|
508 |
|
509 |
-
public function layout1_tracking_details( $trackind_detail_by_status_rev, $tracking_details_by_date, $trackind_destination_detail_by_status_rev, $tracking_destination_details_by_date, $tracker, $order_id, $tracking_provider, $tracking_number ){
|
510 |
$ts_tracking_page_customizer = new ts_tracking_page_customizer();
|
511 |
$hide_tracking_events = get_option( 'wc_ast_hide_tracking_events', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_events'] );
|
512 |
include 'views/front/layout1_tracking_details.php';
|
@@ -515,8 +479,7 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
515 |
/**
|
516 |
* convert string to date
|
517 |
*/
|
518 |
-
public static function convertString ($date)
|
519 |
-
{
|
520 |
// convert date and time to seconds
|
521 |
$sec = strtotime($date);
|
522 |
|
@@ -525,94 +488,17 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
525 |
|
526 |
// print final date and time
|
527 |
return $date;
|
528 |
-
}
|
529 |
-
|
530 |
-
/*
|
531 |
-
* Function for return tracking url from tracking number and shipping provider
|
532 |
-
*/
|
533 |
-
public function get_tracking_number_url( $order_id, $tracking_provider, $tracking_number, $item ){
|
534 |
-
|
535 |
-
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
536 |
-
$postcode = get_post_meta( $order_id, '_shipping_postcode', true );
|
537 |
-
} else {
|
538 |
-
$order = new WC_Order( $order_id );
|
539 |
-
$postcode = $order->get_shipping_postcode();
|
540 |
-
}
|
541 |
-
|
542 |
-
if ( empty( $postcode ) ) {
|
543 |
-
$postcode = get_post_meta( $order_id, '_shipping_postcode', true );
|
544 |
-
}
|
545 |
-
|
546 |
-
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
547 |
-
|
548 |
-
$link_format = '';
|
549 |
-
|
550 |
-
foreach ( $ast->get_providers() as $provider => $format ) {
|
551 |
-
if ( $format['provider_name'] === $tracking_provider ) {
|
552 |
-
$link_format = $format['provider_url'];
|
553 |
-
break;
|
554 |
-
}
|
555 |
-
}
|
556 |
-
|
557 |
-
if($link_format){
|
558 |
-
$searchVal = array("%number%", str_replace(' ', '', "%2 $ s") );
|
559 |
-
$tracking_number = str_replace(' ', '', $tracking_number);
|
560 |
-
$replaceVal = array( $tracking_number, urlencode( $postcode ) );
|
561 |
-
$link_format = str_replace($searchVal, $replaceVal, $link_format);
|
562 |
-
|
563 |
-
if(isset($item['tracking_product_code'])){
|
564 |
-
$searchnumber2 = array("%number2%", str_replace(' ', '', "%2 $ s") );
|
565 |
-
$tracking_product_code = str_replace(' ', '', $item['tracking_product_code']);
|
566 |
-
$link_format = str_replace($searchnumber2, $tracking_product_code, $link_format);
|
567 |
-
}
|
568 |
-
|
569 |
-
if($order->get_shipping_country() != null){
|
570 |
-
$shipping_country = $order->get_shipping_country();
|
571 |
-
} else{
|
572 |
-
$shipping_country = $order->get_billing_country();
|
573 |
-
}
|
574 |
-
|
575 |
-
if($shipping_country){
|
576 |
-
|
577 |
-
if($tracking_provider == 'JP Post' && $shipping_country != 'JP'){
|
578 |
-
$local_en = '&locale=en';
|
579 |
-
$link_format = $link_format.$local_en;
|
580 |
-
}
|
581 |
-
|
582 |
-
if($tracking_provider == 'DHL eCommerce'){
|
583 |
-
$link_format = str_replace('us-en', strtolower($shipping_country).'-en', $link_format);
|
584 |
-
}
|
585 |
-
|
586 |
-
if($tracking_provider == 'DHL Freight'){
|
587 |
-
$link_format = str_replace('global-en', strtolower($shipping_country).'-en', $link_format);
|
588 |
-
}
|
589 |
-
}
|
590 |
-
|
591 |
-
if($order->get_shipping_postcode() != null){
|
592 |
-
$shipping_postal_code = $order->get_shipping_postcode();
|
593 |
-
} else{
|
594 |
-
$shipping_postal_code = $order->get_billing_postcode();
|
595 |
-
}
|
596 |
-
|
597 |
-
$shipping_country = str_replace(' ', '', $shipping_country);
|
598 |
-
$link_format = str_replace("%country_code%", $shipping_country, $link_format);
|
599 |
-
|
600 |
-
if($tracking_provider == 'APC Overnight'){
|
601 |
-
$shipping_postal_code = str_replace(' ', '+', $shipping_postal_code);
|
602 |
-
} else{
|
603 |
-
$shipping_postal_code = str_replace(' ', '', $shipping_postal_code);
|
604 |
-
}
|
605 |
-
$link_format = str_replace("%postal_code%", $shipping_postal_code, $link_format);
|
606 |
-
}
|
607 |
-
return $link_format;
|
608 |
-
}
|
609 |
|
610 |
/*
|
611 |
* Tracking Page preview
|
612 |
*/
|
613 |
-
public static function preview_tracking_page(){
|
614 |
-
|
615 |
-
|
|
|
|
|
|
|
616 |
|
617 |
wp_head();
|
618 |
|
@@ -623,12 +509,7 @@ class WC_Advanced_Shipment_Tracking_Front {
|
|
623 |
$wc_ast_link_to_shipping_provider = get_option('wc_ast_link_to_shipping_provider', $ts_tracking_page_customizer->defaults['wc_ast_link_to_shipping_provider'] );
|
624 |
$hide_tracking_provider_image = get_option('wc_ast_hide_tracking_provider_image', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_provider_image'] );
|
625 |
$hide_tracking_events = get_option('wc_ast_hide_tracking_events', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_events'] );
|
626 |
-
$tracking_page_layout = get_option('wc_ast_select_tracking_page_layout', $ts_tracking_page_customizer->defaults['wc_ast_select_tracking_page_layout'] );
|
627 |
-
$remove_trackship_branding = get_option('wc_ast_remove_trackship_branding', $ts_tracking_page_customizer->defaults['wc_ast_remove_trackship_branding'] );
|
628 |
-
|
629 |
-
$upload_dir = wp_upload_dir();
|
630 |
-
$ast_directory = $upload_dir['baseurl'] . '/ast-shipping-providers/';
|
631 |
-
$ast_base_directory = $upload_dir['basedir'] . '/ast-shipping-providers/';
|
632 |
|
633 |
include 'views/front/preview_tracking_page.php';
|
634 |
wp_footer();
|
19 |
|
20 |
global $wpdb;
|
21 |
$this->table = $wpdb->prefix."woo_shippment_provider";
|
22 |
+
|
23 |
+
if ( is_multisite() ) {
|
24 |
+
|
25 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
26 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
27 |
}
|
28 |
+
|
29 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
30 |
+
$main_blog_prefix = $wpdb->get_blog_prefix( BLOG_ID_CURRENT_SITE );
|
31 |
+
$this->table = $main_blog_prefix . 'woo_shippment_provider';
|
32 |
+
} else {
|
33 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
34 |
}
|
35 |
+
} else {
|
36 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
37 |
}
|
38 |
|
39 |
$this->init();
|
47 |
public static function get_instance() {
|
48 |
|
49 |
if ( null === self::$instance ) {
|
50 |
+
self::$instance = new self();
|
51 |
}
|
52 |
|
53 |
return self::$instance;
|
56 |
/*
|
57 |
* init from parent mail class
|
58 |
*/
|
59 |
+
public function init() {
|
60 |
+
|
61 |
+
add_shortcode( 'wcast-track-order', array( $this, 'woo_track_order_function' ) );
|
62 |
add_action( 'wp_enqueue_scripts', array( $this, 'front_styles' ));
|
63 |
+
add_action( 'wp_ajax_nopriv_get_tracking_info', array( $this, 'get_tracking_info_fun' ) );
|
64 |
+
add_action( 'wp_ajax_get_tracking_info', array( $this, 'get_tracking_info_fun' ) );
|
65 |
|
66 |
+
add_action( 'wp_ajax_nopriv_ts_open_tracking_lightbox', array( $this, 'ts_open_tracking_lightbox' ) );
|
67 |
+
add_action( 'wp_ajax_ts_open_tracking_lightbox', array( $this, 'ts_open_tracking_lightbox' ) );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
* Include front js and css
|
72 |
*/
|
73 |
+
public function front_styles() {
|
74 |
|
75 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
76 |
wp_register_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
79 |
|
80 |
wp_register_style( 'front_style', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/front.css', array(), wc_advanced_shipment_tracking()->version );
|
81 |
|
82 |
+
$action = ( isset( $_REQUEST[ 'action' ] ) ? $_REQUEST[ 'action' ] : '' );
|
83 |
|
84 |
+
if ( 'preview_tracking_page' == $action ) {
|
85 |
wp_enqueue_style( 'front_style' );
|
86 |
wp_enqueue_script( 'front-js' );
|
87 |
+
}
|
|
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
* Return tracking details or tracking form for shortcode - [wcast-track-order]
|
92 |
*/
|
93 |
+
public function woo_track_order_function() {
|
94 |
|
95 |
wp_enqueue_style( 'front_style' );
|
96 |
wp_enqueue_script( 'jquery-blockui' );
|
97 |
wp_enqueue_script( 'front-js' );
|
98 |
|
99 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
100 |
|
101 |
+
if ( !$wc_ast_api_key ) {
|
102 |
+
?>
|
103 |
<p><a href="https://trackship.info/" target="blank">TrackShip</a> is not active.</p>
|
104 |
+
<?php
|
105 |
+
return;
|
106 |
}
|
107 |
|
108 |
+
if ( isset( $_GET['order_id'] ) && isset( $_GET['order_key'] ) ) {
|
109 |
|
110 |
$order_id = wc_clean($_GET['order_id']);
|
111 |
|
112 |
$order = wc_get_order( $order_id );
|
113 |
|
114 |
+
if ( empty( $order ) ) {
|
115 |
+
return;
|
116 |
+
}
|
117 |
|
118 |
$order_key = $order->get_order_key();
|
119 |
|
120 |
+
if ( $order_key != $_GET['order_key'] ) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
|
124 |
+
if ( empty( $order ) ) {
|
125 |
+
return;
|
126 |
+
}
|
127 |
|
128 |
+
$tracking_items = ast_get_tracking_items( $order_id );
|
|
|
|
|
|
|
|
|
129 |
|
130 |
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
131 |
|
132 |
+
if ( !$tracking_items ) {
|
133 |
+
unset($order_id);
|
134 |
+
}
|
135 |
}
|
136 |
|
137 |
+
if ( !isset( $order_id ) ) {
|
138 |
ob_start();
|
139 |
$this->track_form_template();
|
140 |
$form = ob_get_clean();
|
141 |
return $form;
|
142 |
+
} else {
|
143 |
ob_start();
|
144 |
echo $this->display_tracking_page( $order_id, $tracking_items, $shipment_status );
|
145 |
$form = ob_get_clean();
|
150 |
/**
|
151 |
* Ajax function for get tracking details
|
152 |
*/
|
153 |
+
public function get_tracking_info_fun() {
|
154 |
|
155 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
156 |
|
157 |
+
if ( !$wc_ast_api_key ) {
|
158 |
+
return;
|
159 |
+
}
|
160 |
|
161 |
$order_id = wc_clean($_POST['order_id']);
|
162 |
$email = sanitize_email($_POST['order_email']);
|
166 |
|
167 |
$order = wc_get_order( $order_id );
|
168 |
|
169 |
+
if ( empty( $order ) ) {
|
170 |
ob_start();
|
171 |
$this->track_form_template();
|
172 |
$form = ob_get_clean();
|
173 |
+
echo json_encode( array('success' => 'false', 'message' => __( 'Order not found.', 'woo-advanced-shipment-tracking' ), 'html' => $form ));
|
174 |
+
die();
|
175 |
}
|
176 |
|
177 |
$order_id = $wast->get_formated_order_id($order_id);
|
178 |
$order_email = $order->get_billing_email();
|
179 |
|
180 |
+
if ( strtolower( $order_email ) != strtolower( $email ) ) {
|
181 |
ob_start();
|
182 |
$this->track_form_template();
|
183 |
$form = ob_get_clean();
|
184 |
+
echo json_encode( array('success' => 'false', 'message' => __( 'Order not found.', 'woo-advanced-shipment-tracking' ), 'html' => $form ));
|
185 |
+
die();
|
186 |
}
|
187 |
|
188 |
+
$tracking_items = ast_get_tracking_items( $order_id );
|
|
|
|
|
|
|
|
|
189 |
|
190 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
191 |
|
192 |
+
if ( !$tracking_items ) {
|
193 |
ob_start();
|
194 |
$this->track_form_template();
|
195 |
$form = ob_get_clean();
|
196 |
+
echo json_encode( array('success' => 'false', 'message' => __( 'Tracking details not found', 'woo-advanced-shipment-tracking' ), 'html' => $form ));
|
197 |
+
die();
|
198 |
}
|
199 |
+
|
200 |
ob_start();
|
201 |
$html = $this->display_tracking_page( $order_id, $tracking_items, $shipment_status );
|
202 |
$html = ob_get_clean();
|
203 |
+
echo json_encode( array('success' => 'true', 'message' => '', 'html' => $html ));
|
204 |
+
die();
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
* Ajax function for get tracking details lightbox
|
209 |
*/
|
210 |
+
public function ts_open_tracking_lightbox() {
|
211 |
+
|
212 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
213 |
|
214 |
+
if ( !$wc_ast_api_key ) {
|
215 |
+
exit;
|
216 |
+
}
|
217 |
|
218 |
+
$order_id = wc_clean( $_POST['order_id'] );
|
219 |
+
$tracking_number = wc_clean( $_POST['tracking_number'] );
|
220 |
|
221 |
$order = wc_get_order( $order_id );
|
222 |
|
223 |
+
$tracking_items = ast_get_tracking_items( $order_id );
|
|
|
|
|
|
|
|
|
224 |
|
225 |
foreach( $tracking_items as $key => $tracking_item ){
|
226 |
+
if ( $tracking_item['tracking_number'] != $tracking_number ) {
|
227 |
+
unset( $tracking_items[$key] );
|
228 |
+
}
|
229 |
}
|
230 |
|
231 |
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
233 |
ob_start();
|
234 |
$html = $this->display_tracking_page( $order_id, $tracking_items, $shipment_status );
|
235 |
$html = ob_get_clean();
|
236 |
+
echo $html;
|
237 |
+
exit;
|
238 |
}
|
239 |
|
240 |
/*
|
252 |
/*
|
253 |
* retuern Tracking page HTML
|
254 |
*/
|
255 |
+
public function display_tracking_page( $order_id, $tracking_items, $shipment_status ) {
|
256 |
|
257 |
wp_enqueue_style( 'front_style' );
|
258 |
wp_enqueue_script( 'jquery-blockui' );
|
270 |
?>
|
271 |
|
272 |
<style>
|
273 |
+
<?php if ( $border_color ) { ?>
|
274 |
body .col.tracking-detail{
|
275 |
border: 1px solid <?php echo $border_color; ?>;
|
276 |
}
|
290 |
<?php
|
291 |
|
292 |
$num = 1;
|
293 |
+
$total_trackings = sizeof( $tracking_items );
|
294 |
|
295 |
+
foreach ( $tracking_items as $key => $item ) {
|
296 |
$tracking_number = $item['tracking_number'];
|
297 |
$trackship_url = 'https://trackship.info';
|
298 |
$tracking_provider = $item['tracking_provider'];
|
307 |
***/
|
308 |
$tracker = new \stdClass();
|
309 |
|
310 |
+
if ( isset( $shipment_status[ $key ][ 'pending_status' ] ) ) {
|
311 |
$tracker->ep_status = $shipment_status[$key]['pending_status'];
|
312 |
+
} else if ( isset( $shipment_status[ $key ][ 'status' ] ) ) {
|
313 |
$tracker->ep_status = $shipment_status[$key]['status'];
|
314 |
}
|
315 |
|
316 |
+
$tracker->est_delivery_date = isset( $shipment_status[ $key ][ 'est_delivery_date' ] ) ? $shipment_status[ $key ][ 'est_delivery_date' ] : '';
|
317 |
|
318 |
+
if ( isset( $shipment_status[ $key ][ 'tracking_events' ] ) || isset( $shipment_status[ $key ][ 'pending_status' ] ) ) {
|
319 |
|
320 |
+
if( isset( $shipment_status[ $key ][ 'tracking_events' ] ) ) {
|
321 |
+
$tracker->tracking_detail = json_encode( $shipment_status[ $key ][ 'tracking_events' ] );
|
322 |
}
|
323 |
|
324 |
+
if ( isset( $shipment_status[ $key ][ 'tracking_destination_events' ] ) ) {
|
325 |
+
$tracker->tracking_destination_events = json_encode( $shipment_status[ $key ][ 'tracking_destination_events' ] );
|
326 |
}
|
327 |
|
328 |
$decoded_data = true;
|
331 |
$tracking_detail_org = '';
|
332 |
$trackind_detail_by_status_rev = '';
|
333 |
|
334 |
+
if ( isset( $tracker->tracking_detail ) && null != $tracker->tracking_detail ) {
|
335 |
+
$tracking_detail_org = json_decode( $tracker->tracking_detail );
|
336 |
+
$trackind_detail_by_status_rev = array_reverse( $tracking_detail_org );
|
337 |
}
|
338 |
|
339 |
$tracking_details_by_date = array();
|
340 |
|
341 |
+
foreach ( (array) $trackind_detail_by_status_rev as $key => $details ) {
|
342 |
+
if ( isset( $details->datetime ) ) {
|
343 |
+
$date = date( 'Y-m-d', strtotime( $details->datetime ) );
|
344 |
+
$tracking_details_by_date[ $date ][] = $details;
|
345 |
}
|
346 |
}
|
347 |
|
348 |
$tracking_destination_detail_org = '';
|
349 |
$trackind_destination_detail_by_status_rev = '';
|
350 |
|
351 |
+
if ( isset( $tracker->tracking_destination_events ) && null != $tracker->tracking_destination_events ) {
|
352 |
+
$tracking_destination_detail_org = json_decode( $tracker->tracking_destination_events );
|
353 |
+
$trackind_destination_detail_by_status_rev = array_reverse( $tracking_destination_detail_org );
|
|
|
354 |
}
|
355 |
|
356 |
$tracking_destination_details_by_date = array();
|
357 |
|
358 |
+
foreach ( (array) $trackind_destination_detail_by_status_rev as $key => $details ) {
|
359 |
+
if ( isset( $details->datetime ) ) {
|
360 |
+
$date = date( 'Y-m-d', strtotime( $details->datetime ) );
|
361 |
$tracking_destination_details_by_date[$date][] = $details;
|
362 |
}
|
363 |
}
|
364 |
|
365 |
$order = wc_get_order( $order_id );
|
366 |
$order_url = $order->get_view_order_url();
|
367 |
+
$order_number = $order->get_order_number();
|
368 |
|
369 |
+
if ( isset( $tracker->ep_status ) ) {
|
370 |
+
$t_layout_class = ( 't_layout_1' != $tracking_page_layout ) ? 'tracking-layout-2' : '' ;
|
371 |
+
?>
|
372 |
+
<div class="tracking-detail col <?php esc_html_e( $t_layout_class ); ?>">
|
373 |
+
|
|
|
|
|
|
|
|
|
374 |
<div class="shipment-header">
|
375 |
+
<?php if ( $total_trackings > 1 ) { ?>
|
376 |
+
<p class="shipment_heading"><?php printf( esc_html( "Shipment : %s (out of %s)", 'woo-advanced-shipment-tracking'), $num , $total_trackings ); ?></p>
|
377 |
+
<span class="wc_order_id"><?php esc_html_e( 'Order', 'woocommerce' ); ?>
|
378 |
+
<a href="<?php echo esc_url( $order_url ); ?>" target="_blank">
|
379 |
+
<strong>#<?php esc_html_e( apply_filters( 'ast_order_number_filter', $order_number ) ); ?></strong>
|
380 |
+
</a>
|
381 |
+
</span>
|
382 |
+
<?php } else { ?>
|
383 |
+
<p class="shipment_heading"><?php esc_html_e( 'Shipment', 'woo-advanced-shipment-tracking' ); ?></p>
|
384 |
+
<span class="wc_order_id"><?php esc_html_e( 'Order', 'woocommerce' ); ?>
|
385 |
+
<a href="<?php echo esc_url( $order_url ); ?>" target="_blank">
|
386 |
+
<strong>#<?php esc_html_e( apply_filters( 'ast_order_number_filter', $order_number ) ); ?></strong>
|
387 |
+
</a>
|
388 |
+
</span>
|
389 |
<?php } ?>
|
390 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
+
<div class="shipment-content">
|
393 |
+
<?php
|
394 |
+
|
395 |
+
echo $this->tracking_page_header( $order_id, $tracker, $item );
|
396 |
+
|
397 |
+
echo $this->tracking_progress_bar( $tracker );
|
398 |
+
|
399 |
+
if ( in_array( $tracker->ep_status, array( 'pending_trackship', 'carrier_unsupported', 'unknown' ) ) ) {
|
400 |
+
|
401 |
+
$pending_message = __( 'Tracking information is not available, please try again in a few minutes.', 'woo-advanced-shipment-tracking' );
|
402 |
+
?>
|
403 |
+
<p class="pending_message"><?php esc_html_e( apply_filters( "trackship_pending_status_message", $pending_message, $tracker->ep_status ) ); ?></p>
|
404 |
+
<?php
|
405 |
+
}
|
406 |
+
|
407 |
+
if ( !empty( $trackind_detail_by_status_rev ) ) {
|
408 |
+
echo $this->layout1_tracking_details( $trackind_detail_by_status_rev, $tracking_details_by_date, $trackind_destination_detail_by_status_rev, $tracking_destination_details_by_date, $tracker , $order_id, $tracking_provider, $tracking_number );
|
409 |
+
}
|
410 |
+
?>
|
411 |
+
</div>
|
412 |
+
<div class="trackship_branding">
|
413 |
+
<p>Shipment Tracking info by <a href="https://trackship.info/trackings/?number=<?php esc_html_e( $tracking_number ); ?>" title="TrackShip" target="blank"><img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-logo.png"></a></p>
|
414 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
</div>
|
416 |
+
<?php
|
417 |
+
} else {
|
418 |
+
?>
|
419 |
<div class="tracking-detail col">
|
420 |
+
<h1 class="shipment_status_heading text-secondary text-center"><?php esc_html_e( 'Tracking # ' . $tracking_number, 'woo-advanced-shipment-tracking' ); ?></h1>
|
421 |
+
<h3 class="text-center"><?php esc_html_e( 'Tracking details not found in TrackShip', 'woo-advanced-shipment-tracking' ); ?></h3>
|
422 |
</div>
|
423 |
+
<?php
|
424 |
+
}
|
425 |
$num++;
|
426 |
}
|
427 |
}
|
429 |
/*
|
430 |
* Tracking Page Header
|
431 |
*/
|
432 |
+
public function tracking_page_header( $order_id, $tracker, $item ) {
|
433 |
+
|
|
|
|
|
|
|
|
|
434 |
$ts_tracking_page_customizer = new ts_tracking_page_customizer();
|
435 |
$wc_ast_link_to_shipping_provider = get_option('wc_ast_link_to_shipping_provider', $ts_tracking_page_customizer->defaults['wc_ast_link_to_shipping_provider'] );
|
436 |
$hide_tracking_provider_image = get_option('wc_ast_hide_tracking_provider_image', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_provider_image'] );
|
437 |
|
438 |
+
include 'views/front/tracking_page_header.php';
|
439 |
+
}
|
440 |
+
|
441 |
+
public function tracking_progress_bar( $tracker ) {
|
|
|
|
|
|
|
|
|
|
|
442 |
|
443 |
+
if( in_array( $tracker->ep_status, array( 'INVALID_TRACKING_NUM', 'carrier_unsupported', 'invalid_user_key', 'wrong_shipping_provider', 'deleted', 'pending' ) ) ) {
|
444 |
+
return;
|
|
|
|
|
|
|
445 |
}
|
446 |
|
447 |
+
if( in_array( $tracker->ep_status, array( 'pending_trackship', 'pending', 'unknown', 'carrier_unsupported' ) ) ){
|
448 |
+
$width = '17%';
|
449 |
+
} else if( in_array( $tracker->ep_status, array( 'in_transit', 'on_hold' ) ) ){
|
450 |
+
$width = '33%';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
} else if($tracker->ep_status == 'out_for_delivery'){
|
452 |
$width = '67%';
|
453 |
} else if($tracker->ep_status == 'available_for_pickup'){
|
456 |
$width = '67%';
|
457 |
} else if($tracker->ep_status == 'delivered'){
|
458 |
$width = '100%';
|
459 |
+
} else {
|
460 |
+
$width = '0';
|
461 |
+
}
|
462 |
+
$tracking_page_layout = get_option( 'wc_ast_select_tracking_page_layout', 't_layout_1' );
|
463 |
+
?>
|
464 |
+
<div class="tracker-progress-bar <?php esc_html_e( $tracking_page_layout == 't_layout_1' ? 'tracking_layout_1' : '' ); ?>">
|
465 |
<div class="progress">
|
466 |
+
<div class="progress-bar <?php esc_html_e( $tracker->ep_status ); ?>" style="width: <?php esc_html_e( $width ); ?>;"></div>
|
467 |
</div>
|
468 |
</div>
|
469 |
+
<?php
|
470 |
+
}
|
471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
|
473 |
+
public function layout1_tracking_details( $trackind_detail_by_status_rev, $tracking_details_by_date, $trackind_destination_detail_by_status_rev, $tracking_destination_details_by_date, $tracker, $order_id, $tracking_provider, $tracking_number ) {
|
474 |
$ts_tracking_page_customizer = new ts_tracking_page_customizer();
|
475 |
$hide_tracking_events = get_option( 'wc_ast_hide_tracking_events', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_events'] );
|
476 |
include 'views/front/layout1_tracking_details.php';
|
479 |
/**
|
480 |
* convert string to date
|
481 |
*/
|
482 |
+
public static function convertString ($date) {
|
|
|
483 |
// convert date and time to seconds
|
484 |
$sec = strtotime($date);
|
485 |
|
488 |
|
489 |
// print final date and time
|
490 |
return $date;
|
491 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
|
493 |
/*
|
494 |
* Tracking Page preview
|
495 |
*/
|
496 |
+
public static function preview_tracking_page() {
|
497 |
+
|
498 |
+
$action = ( isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : "" );
|
499 |
+
if ( 'preview_tracking_page' != $action ) {
|
500 |
+
return;
|
501 |
+
}
|
502 |
|
503 |
wp_head();
|
504 |
|
509 |
$wc_ast_link_to_shipping_provider = get_option('wc_ast_link_to_shipping_provider', $ts_tracking_page_customizer->defaults['wc_ast_link_to_shipping_provider'] );
|
510 |
$hide_tracking_provider_image = get_option('wc_ast_hide_tracking_provider_image', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_provider_image'] );
|
511 |
$hide_tracking_events = get_option('wc_ast_hide_tracking_events', $ts_tracking_page_customizer->defaults['wc_ast_hide_tracking_events'] );
|
512 |
+
$tracking_page_layout = get_option('wc_ast_select_tracking_page_layout', $ts_tracking_page_customizer->defaults['wc_ast_select_tracking_page_layout'] );
|
|
|
|
|
|
|
|
|
|
|
513 |
|
514 |
include 'views/front/preview_tracking_page.php';
|
515 |
wp_footer();
|
includes/class-wc-advanced-shipment-tracking-install.php
CHANGED
@@ -18,19 +18,22 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
18 |
public function __construct() {
|
19 |
|
20 |
global $wpdb;
|
21 |
-
$this->table = $wpdb->prefix."woo_shippment_provider";
|
22 |
-
|
|
|
|
|
23 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
24 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
25 |
}
|
|
|
26 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
27 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
28 |
-
$this->table = $main_blog_prefix.
|
29 |
-
} else{
|
30 |
-
$this->table = $wpdb->prefix.
|
31 |
}
|
32 |
-
} else{
|
33 |
-
$this->table = $wpdb->prefix.
|
34 |
}
|
35 |
|
36 |
$this->init();
|
@@ -44,7 +47,7 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
44 |
public static function get_instance() {
|
45 |
|
46 |
if ( null === self::$instance ) {
|
47 |
-
self::$instance = new self;
|
48 |
}
|
49 |
|
50 |
return self::$instance;
|
@@ -53,9 +56,9 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
53 |
/*
|
54 |
* init from parent mail class
|
55 |
*/
|
56 |
-
public function init(){
|
57 |
-
add_action( 'init', array( $this, 'update_database_check'));
|
58 |
-
add_action( 'update_ts_shipment_status_order_mete', array( $this, 'update_ts_shipment_status_order_mete'));
|
59 |
add_action( 'wp_ajax_update_ts_shipment_status_order_mete', array( $this, 'update_ts_shipment_status_order_mete' ) );
|
60 |
}
|
61 |
|
@@ -68,7 +71,7 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
68 |
*
|
69 |
*
|
70 |
*/
|
71 |
-
public function woo_shippment_tracking_install(){
|
72 |
|
73 |
// Add transient to trigger redirect.
|
74 |
set_transient( '_ast_activation_redirect', 1, 30 );
|
@@ -76,33 +79,33 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
76 |
$this->create_shippment_tracking_table();
|
77 |
$this->update_shipping_providers();
|
78 |
|
79 |
-
$wc_ast_default_mark_shipped = get_option('wc_ast_default_mark_shipped');
|
80 |
-
if($wc_ast_default_mark_shipped
|
81 |
-
update_option('wc_ast_default_mark_shipped',1);
|
82 |
}
|
83 |
|
84 |
-
$wc_ast_unclude_tracking_info = get_option('wc_ast_unclude_tracking_info');
|
85 |
-
if(empty($wc_ast_unclude_tracking_info)){
|
86 |
-
$data_array = array('completed' => 1,'partial-shipped' => 1,'updated-tracking' => 1);
|
87 |
update_option( 'wc_ast_unclude_tracking_info', $data_array );
|
88 |
}
|
89 |
|
90 |
-
$wc_ast_show_orders_actions = get_option('wc_ast_show_orders_actions');
|
91 |
-
if(empty($wc_ast_show_orders_actions)){
|
92 |
-
$data_array = array('processing' => 1,'completed' => 1,'partial-shipped' => 1,'updated-tracking' => 1);
|
93 |
update_option( 'wc_ast_show_orders_actions', $data_array );
|
94 |
}
|
95 |
-
update_option( 'wc_advanced_shipment_tracking', '3.21');
|
96 |
}
|
97 |
|
98 |
/*
|
99 |
* function for create shipping provider table
|
100 |
*/
|
101 |
-
public function create_shippment_tracking_table(){
|
102 |
|
103 |
global $wpdb;
|
104 |
|
105 |
-
if(!$wpdb->query($wpdb->prepare("show tables like %s"
|
106 |
$charset_collate = $wpdb->get_charset_collate();
|
107 |
$sql = "CREATE TABLE $this->table (
|
108 |
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
@@ -121,7 +124,7 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
121 |
) $charset_collate;";
|
122 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
123 |
dbDelta( $sql );
|
124 |
-
} else{
|
125 |
$this->check_all_column_exist();
|
126 |
}
|
127 |
}
|
@@ -129,81 +132,84 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
129 |
/*
|
130 |
* check if all column exist in shipping provider database
|
131 |
*/
|
132 |
-
public function check_all_column_exist(){
|
133 |
|
134 |
global $wpdb;
|
135 |
$results = $wpdb->get_row( "SELECT * FROM $this->table LIMIT 1" );
|
136 |
$db_update_need = false;
|
137 |
|
138 |
-
if(!isset($results->provider_name)) {
|
139 |
$wpdb->query( "ALTER TABLE $this->table ADD provider_name varchar(500) DEFAULT '' NOT NULL AFTER id" );
|
140 |
-
$db_update_need = true;
|
141 |
}
|
142 |
|
143 |
-
if(!isset($results->api_provider_name)) {
|
144 |
$wpdb->query( "ALTER TABLE $this->table ADD api_provider_name text NULL DEFAULT NULL AFTER provider_name" );
|
145 |
$db_update_need = true;
|
146 |
}
|
147 |
|
148 |
-
if(!isset($results->custom_provider_name)) {
|
149 |
$wpdb->query( "ALTER TABLE $this->table ADD custom_provider_name text NULL DEFAULT NULL AFTER api_provider_name" );
|
150 |
$db_update_need = true;
|
151 |
}
|
152 |
|
153 |
-
if(!isset($results->ts_slug)) {
|
154 |
$wpdb->query( "ALTER TABLE $this->table ADD ts_slug text NULL DEFAULT NULL AFTER custom_provider_name" );
|
155 |
$db_update_need = true;
|
156 |
}
|
157 |
|
158 |
-
if(!isset($results->provider_url)) {
|
159 |
$wpdb->query( "ALTER TABLE $this->table ADD provider_url varchar(500) DEFAULT '' NULL AFTER ts_slug" );
|
160 |
$db_update_need = true;
|
161 |
}
|
162 |
|
163 |
-
if(!isset($results->shipping_country)) {
|
164 |
$wpdb->query( "ALTER TABLE $this->table ADD shipping_country varchar(45) DEFAULT '' NULL AFTER provider_url" );
|
165 |
$db_update_need = true;
|
166 |
}
|
167 |
|
168 |
-
if(!isset($results->shipping_default)) {
|
169 |
$wpdb->query( "ALTER TABLE $this->table ADD shipping_default tinyint(4) NULL DEFAULT '0' AFTER shipping_country" );
|
170 |
$db_update_need = true;
|
171 |
}
|
172 |
|
173 |
-
if(!isset($results->custom_thumb_id)) {
|
174 |
$wpdb->query( "ALTER TABLE $this->table ADD custom_thumb_id int(11) NOT NULL DEFAULT '0' AFTER shipping_default" );
|
175 |
$db_update_need = true;
|
176 |
}
|
177 |
|
178 |
-
if(!isset($results->display_in_order)) {
|
179 |
$wpdb->query( "ALTER TABLE $this->table ADD display_in_order tinyint(4) NOT NULL DEFAULT '1' AFTER custom_thumb_id" );
|
180 |
$db_update_need = true;
|
181 |
}
|
182 |
|
183 |
-
if(!isset($results->trackship_supported)) {
|
184 |
$wpdb->query( "ALTER TABLE $this->table ADD trackship_supported int(11) NOT NULL DEFAULT '0' AFTER display_in_order" );
|
185 |
$db_update_need = true;
|
186 |
}
|
187 |
|
188 |
-
if(!isset($results->sort_order)) {
|
189 |
$wpdb->query( "ALTER TABLE $this->table ADD sort_order int(11) NOT NULL DEFAULT '0' AFTER trackship_supported" );
|
190 |
$db_update_need = true;
|
191 |
}
|
192 |
-
|
|
|
|
|
|
|
193 |
}
|
194 |
|
195 |
/*
|
196 |
* database update
|
197 |
*/
|
198 |
-
public function update_database_check(){
|
199 |
-
if ( is_admin() ){
|
200 |
|
201 |
-
if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.14', '<') ){
|
202 |
$this->add_provider_image_in_upload_directory();
|
203 |
update_option( 'wc_advanced_shipment_tracking', '3.14');
|
204 |
}
|
205 |
|
206 |
-
if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.20', '<') ){
|
207 |
as_schedule_single_action( time(), 'update_ts_shipment_status_order_mete' , array( 'order_page' => 1 ), '' );
|
208 |
as_schedule_single_action( time(), 'update_ts_shipment_status_order_mete' , array( 'order_page' => 2 ), '' );
|
209 |
as_schedule_single_action( time(), 'update_ts_shipment_status_order_mete' , array( 'order_page' => 3 ), '' );
|
@@ -217,7 +223,7 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
217 |
update_option( 'wc_advanced_shipment_tracking', '3.20');
|
218 |
}
|
219 |
|
220 |
-
if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.21', '<') ){
|
221 |
$this->check_all_column_exist();
|
222 |
update_option( 'wc_advanced_shipment_tracking', '3.21');
|
223 |
}
|
@@ -227,9 +233,12 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
227 |
/*
|
228 |
* function for update order meta from shipment_status to ts_shipment_status for filter order by shipment status
|
229 |
*/
|
230 |
-
public function update_ts_shipment_status_order_mete( $page ){
|
231 |
-
|
232 |
-
|
|
|
|
|
|
|
233 |
|
234 |
$args = array(
|
235 |
'limit' => 100,
|
@@ -239,12 +248,12 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
239 |
|
240 |
$orders = wc_get_orders( $args );
|
241 |
|
242 |
-
foreach( $orders as $order_id ){
|
243 |
-
$shipment_status = get_post_meta( $order_id,
|
244 |
-
if( !empty($shipment_status) ){
|
245 |
-
foreach( $shipment_status as $key => $shipment ){
|
246 |
-
$ts_shipment_status[$key]['status'] = $shipment['status'];
|
247 |
-
update_post_meta( $order_id,
|
248 |
}
|
249 |
}
|
250 |
}
|
@@ -253,19 +262,20 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
253 |
/**
|
254 |
* function for add provider image in uploads directory under wp-content/uploads/ast-shipping-providers
|
255 |
*/
|
256 |
-
public function add_provider_image_in_upload_directory(){
|
257 |
$upload_dir = wp_upload_dir();
|
258 |
$ast_directory = $upload_dir['basedir'] . '/ast-shipping-providers';
|
259 |
|
260 |
-
if(!is_dir($ast_directory)) {
|
261 |
wp_mkdir_p( $ast_directory );
|
262 |
}
|
263 |
|
264 |
$url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
|
265 |
$resp = wp_remote_get( $url );
|
|
|
266 |
if ( is_array( $resp ) && ! is_wp_error( $resp ) ) {
|
267 |
$providers = json_decode($resp['body'],true);
|
268 |
-
foreach($providers as $provider){
|
269 |
$provider_name = $provider['shipping_provider'];
|
270 |
$img_url = $provider['img_url'];
|
271 |
$img_slug = sanitize_title($provider_name);
|
@@ -286,7 +296,7 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
286 |
/**
|
287 |
* get providers list from trackship and update providers in database
|
288 |
*/
|
289 |
-
public function update_shipping_providers(){
|
290 |
global $wpdb;
|
291 |
$url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
|
292 |
$resp = wp_remote_get( $url );
|
@@ -294,7 +304,7 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
294 |
$upload_dir = wp_upload_dir();
|
295 |
$ast_directory = $upload_dir['basedir'] . '/ast-shipping-providers';
|
296 |
|
297 |
-
if(!is_dir($ast_directory)) {
|
298 |
wp_mkdir_p( $ast_directory );
|
299 |
}
|
300 |
|
@@ -305,16 +315,16 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
305 |
$providers_name = array();
|
306 |
|
307 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_default = 1" );
|
308 |
-
foreach ( $default_shippment_providers as $key => $val ){
|
309 |
$shippment_providers[ $val->provider_name ] = $val;
|
310 |
}
|
311 |
|
312 |
-
foreach ( $providers as $key => $val ){
|
313 |
$providers_name[ $val['provider_name'] ] = $val;
|
314 |
}
|
315 |
|
316 |
$n = 0;
|
317 |
-
foreach($providers as $provider){
|
318 |
|
319 |
$provider_name = $provider['shipping_provider'];
|
320 |
$provider_url = $provider['provider_url'];
|
@@ -322,13 +332,13 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
322 |
$ts_slug = $provider['shipping_provider_slug'];
|
323 |
$trackship_supported = $provider['trackship_supported'];
|
324 |
|
325 |
-
if(isset($shippment_providers[$provider_name])){
|
326 |
$db_provider_url = $shippment_providers[$provider_name]->provider_url;
|
327 |
$db_shipping_country = $shippment_providers[$provider_name]->shipping_country;
|
328 |
$db_ts_slug = $shippment_providers[$provider_name]->ts_slug;
|
329 |
$db_trackship_supported = $shippment_providers[$provider_name]->trackship_supported;
|
330 |
|
331 |
-
if(($db_provider_url != $provider_url) || ($db_shipping_country != $shipping_country) || ($db_ts_slug != $ts_slug) || ($db_trackship_supported != $trackship_supported)){
|
332 |
$data_array = array(
|
333 |
'ts_slug' => $ts_slug,
|
334 |
'provider_url' => $provider_url,
|
@@ -340,7 +350,7 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
340 |
);
|
341 |
$wpdb->update( $this->table, $data_array, $where_array);
|
342 |
}
|
343 |
-
} else{
|
344 |
$img_url = $provider['img_url'];
|
345 |
$img_slug = sanitize_title($provider_name);
|
346 |
$img = $ast_directory.'/'.$img_slug.'.png';
|
@@ -357,7 +367,9 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
357 |
file_put_contents($img, $data);
|
358 |
|
359 |
$display_in_order = 1;
|
360 |
-
if($n > 14)
|
|
|
|
|
361 |
|
362 |
$data_array = array(
|
363 |
'shipping_country' => sanitize_text_field($shipping_country),
|
@@ -373,9 +385,9 @@ class WC_Advanced_Shipment_Tracking_Install {
|
|
373 |
}
|
374 |
}
|
375 |
|
376 |
-
foreach($default_shippment_providers as $db_provider){
|
377 |
|
378 |
-
if(!isset($providers_name[$db_provider->provider_name])){
|
379 |
$where = array(
|
380 |
'provider_name' => $db_provider->provider_name,
|
381 |
'shipping_default' => 1
|
18 |
public function __construct() {
|
19 |
|
20 |
global $wpdb;
|
21 |
+
$this->table = $wpdb->prefix . "woo_shippment_provider";
|
22 |
+
|
23 |
+
if ( is_multisite() ) {
|
24 |
+
|
25 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
26 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
27 |
}
|
28 |
+
|
29 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
30 |
+
$main_blog_prefix = $wpdb->get_blog_prefix( BLOG_ID_CURRENT_SITE );
|
31 |
+
$this->table = $main_blog_prefix . 'woo_shippment_provider';
|
32 |
+
} else {
|
33 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
34 |
}
|
35 |
+
} else {
|
36 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
37 |
}
|
38 |
|
39 |
$this->init();
|
47 |
public static function get_instance() {
|
48 |
|
49 |
if ( null === self::$instance ) {
|
50 |
+
self::$instance = new self();
|
51 |
}
|
52 |
|
53 |
return self::$instance;
|
56 |
/*
|
57 |
* init from parent mail class
|
58 |
*/
|
59 |
+
public function init() {
|
60 |
+
add_action( 'init', array( $this, 'update_database_check' ) );
|
61 |
+
add_action( 'update_ts_shipment_status_order_mete', array( $this, 'update_ts_shipment_status_order_mete' ) );
|
62 |
add_action( 'wp_ajax_update_ts_shipment_status_order_mete', array( $this, 'update_ts_shipment_status_order_mete' ) );
|
63 |
}
|
64 |
|
71 |
*
|
72 |
*
|
73 |
*/
|
74 |
+
public function woo_shippment_tracking_install() {
|
75 |
|
76 |
// Add transient to trigger redirect.
|
77 |
set_transient( '_ast_activation_redirect', 1, 30 );
|
79 |
$this->create_shippment_tracking_table();
|
80 |
$this->update_shipping_providers();
|
81 |
|
82 |
+
$wc_ast_default_mark_shipped = get_option( 'wc_ast_default_mark_shipped' );
|
83 |
+
if ( '' == $wc_ast_default_mark_shipped ) {
|
84 |
+
update_option( 'wc_ast_default_mark_shipped', 1 );
|
85 |
}
|
86 |
|
87 |
+
$wc_ast_unclude_tracking_info = get_option( 'wc_ast_unclude_tracking_info' );
|
88 |
+
if ( empty( $wc_ast_unclude_tracking_info ) ) {
|
89 |
+
$data_array = array( 'completed' => 1, 'partial-shipped' => 1, 'updated-tracking' => 1 );
|
90 |
update_option( 'wc_ast_unclude_tracking_info', $data_array );
|
91 |
}
|
92 |
|
93 |
+
$wc_ast_show_orders_actions = get_option( 'wc_ast_show_orders_actions' );
|
94 |
+
if ( empty( $wc_ast_show_orders_actions ) ) {
|
95 |
+
$data_array = array( 'processing' => 1, 'completed' => 1, 'partial-shipped' => 1, 'updated-tracking' => 1 );
|
96 |
update_option( 'wc_ast_show_orders_actions', $data_array );
|
97 |
}
|
98 |
+
update_option( 'wc_advanced_shipment_tracking', '3.21' );
|
99 |
}
|
100 |
|
101 |
/*
|
102 |
* function for create shipping provider table
|
103 |
*/
|
104 |
+
public function create_shippment_tracking_table() {
|
105 |
|
106 |
global $wpdb;
|
107 |
|
108 |
+
if ( !$wpdb->query( $wpdb->prepare( "show tables like %s", $this->table ) ) ) {
|
109 |
$charset_collate = $wpdb->get_charset_collate();
|
110 |
$sql = "CREATE TABLE $this->table (
|
111 |
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
124 |
) $charset_collate;";
|
125 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
126 |
dbDelta( $sql );
|
127 |
+
} else {
|
128 |
$this->check_all_column_exist();
|
129 |
}
|
130 |
}
|
132 |
/*
|
133 |
* check if all column exist in shipping provider database
|
134 |
*/
|
135 |
+
public function check_all_column_exist() {
|
136 |
|
137 |
global $wpdb;
|
138 |
$results = $wpdb->get_row( "SELECT * FROM $this->table LIMIT 1" );
|
139 |
$db_update_need = false;
|
140 |
|
141 |
+
if ( !isset( $results->provider_name ) ) {
|
142 |
$wpdb->query( "ALTER TABLE $this->table ADD provider_name varchar(500) DEFAULT '' NOT NULL AFTER id" );
|
143 |
+
$db_update_need = true;
|
144 |
}
|
145 |
|
146 |
+
if ( !isset( $results->api_provider_name ) ) {
|
147 |
$wpdb->query( "ALTER TABLE $this->table ADD api_provider_name text NULL DEFAULT NULL AFTER provider_name" );
|
148 |
$db_update_need = true;
|
149 |
}
|
150 |
|
151 |
+
if ( !isset( $results->custom_provider_name ) ) {
|
152 |
$wpdb->query( "ALTER TABLE $this->table ADD custom_provider_name text NULL DEFAULT NULL AFTER api_provider_name" );
|
153 |
$db_update_need = true;
|
154 |
}
|
155 |
|
156 |
+
if ( !isset( $results->ts_slug ) ) {
|
157 |
$wpdb->query( "ALTER TABLE $this->table ADD ts_slug text NULL DEFAULT NULL AFTER custom_provider_name" );
|
158 |
$db_update_need = true;
|
159 |
}
|
160 |
|
161 |
+
if ( !isset( $results->provider_url ) ) {
|
162 |
$wpdb->query( "ALTER TABLE $this->table ADD provider_url varchar(500) DEFAULT '' NULL AFTER ts_slug" );
|
163 |
$db_update_need = true;
|
164 |
}
|
165 |
|
166 |
+
if ( !isset( $results->shipping_country ) ) {
|
167 |
$wpdb->query( "ALTER TABLE $this->table ADD shipping_country varchar(45) DEFAULT '' NULL AFTER provider_url" );
|
168 |
$db_update_need = true;
|
169 |
}
|
170 |
|
171 |
+
if ( !isset( $results->shipping_default ) ) {
|
172 |
$wpdb->query( "ALTER TABLE $this->table ADD shipping_default tinyint(4) NULL DEFAULT '0' AFTER shipping_country" );
|
173 |
$db_update_need = true;
|
174 |
}
|
175 |
|
176 |
+
if ( !isset( $results->custom_thumb_id ) ) {
|
177 |
$wpdb->query( "ALTER TABLE $this->table ADD custom_thumb_id int(11) NOT NULL DEFAULT '0' AFTER shipping_default" );
|
178 |
$db_update_need = true;
|
179 |
}
|
180 |
|
181 |
+
if ( !isset( $results->display_in_order ) ) {
|
182 |
$wpdb->query( "ALTER TABLE $this->table ADD display_in_order tinyint(4) NOT NULL DEFAULT '1' AFTER custom_thumb_id" );
|
183 |
$db_update_need = true;
|
184 |
}
|
185 |
|
186 |
+
if ( !isset( $results->trackship_supported ) ) {
|
187 |
$wpdb->query( "ALTER TABLE $this->table ADD trackship_supported int(11) NOT NULL DEFAULT '0' AFTER display_in_order" );
|
188 |
$db_update_need = true;
|
189 |
}
|
190 |
|
191 |
+
if ( !isset( $results->sort_order ) ) {
|
192 |
$wpdb->query( "ALTER TABLE $this->table ADD sort_order int(11) NOT NULL DEFAULT '0' AFTER trackship_supported" );
|
193 |
$db_update_need = true;
|
194 |
}
|
195 |
+
|
196 |
+
if ( $db_update_need ) {
|
197 |
+
$this->update_shipping_providers();
|
198 |
+
}
|
199 |
}
|
200 |
|
201 |
/*
|
202 |
* database update
|
203 |
*/
|
204 |
+
public function update_database_check() {
|
205 |
+
if ( is_admin() ) {
|
206 |
|
207 |
+
if ( version_compare( get_option( 'wc_advanced_shipment_tracking' ), '3.14', '<' ) ) {
|
208 |
$this->add_provider_image_in_upload_directory();
|
209 |
update_option( 'wc_advanced_shipment_tracking', '3.14');
|
210 |
}
|
211 |
|
212 |
+
if ( version_compare( get_option( 'wc_advanced_shipment_tracking' ), '3.20', '<' ) ) {
|
213 |
as_schedule_single_action( time(), 'update_ts_shipment_status_order_mete' , array( 'order_page' => 1 ), '' );
|
214 |
as_schedule_single_action( time(), 'update_ts_shipment_status_order_mete' , array( 'order_page' => 2 ), '' );
|
215 |
as_schedule_single_action( time(), 'update_ts_shipment_status_order_mete' , array( 'order_page' => 3 ), '' );
|
223 |
update_option( 'wc_advanced_shipment_tracking', '3.20');
|
224 |
}
|
225 |
|
226 |
+
if ( version_compare( get_option( 'wc_advanced_shipment_tracking' ), '3.21', '<') ) {
|
227 |
$this->check_all_column_exist();
|
228 |
update_option( 'wc_advanced_shipment_tracking', '3.21');
|
229 |
}
|
233 |
/*
|
234 |
* function for update order meta from shipment_status to ts_shipment_status for filter order by shipment status
|
235 |
*/
|
236 |
+
public function update_ts_shipment_status_order_mete( $page ) {
|
237 |
+
|
238 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
239 |
+
if( !$wc_ast_api_key ) {
|
240 |
+
return;
|
241 |
+
}
|
242 |
|
243 |
$args = array(
|
244 |
'limit' => 100,
|
248 |
|
249 |
$orders = wc_get_orders( $args );
|
250 |
|
251 |
+
foreach ( $orders as $order_id ) {
|
252 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true );
|
253 |
+
if ( !empty( $shipment_status ) ) {
|
254 |
+
foreach ( $shipment_status as $key => $shipment ) {
|
255 |
+
$ts_shipment_status[ $key ][ 'status' ] = $shipment[ 'status' ];
|
256 |
+
update_post_meta( $order_id, 'ts_shipment_status', $ts_shipment_status );
|
257 |
}
|
258 |
}
|
259 |
}
|
262 |
/**
|
263 |
* function for add provider image in uploads directory under wp-content/uploads/ast-shipping-providers
|
264 |
*/
|
265 |
+
public function add_provider_image_in_upload_directory() {
|
266 |
$upload_dir = wp_upload_dir();
|
267 |
$ast_directory = $upload_dir['basedir'] . '/ast-shipping-providers';
|
268 |
|
269 |
+
if ( !is_dir( $ast_directory ) ) {
|
270 |
wp_mkdir_p( $ast_directory );
|
271 |
}
|
272 |
|
273 |
$url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
|
274 |
$resp = wp_remote_get( $url );
|
275 |
+
|
276 |
if ( is_array( $resp ) && ! is_wp_error( $resp ) ) {
|
277 |
$providers = json_decode($resp['body'],true);
|
278 |
+
foreach ( $providers as $provider ) {
|
279 |
$provider_name = $provider['shipping_provider'];
|
280 |
$img_url = $provider['img_url'];
|
281 |
$img_slug = sanitize_title($provider_name);
|
296 |
/**
|
297 |
* get providers list from trackship and update providers in database
|
298 |
*/
|
299 |
+
public function update_shipping_providers() {
|
300 |
global $wpdb;
|
301 |
$url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
|
302 |
$resp = wp_remote_get( $url );
|
304 |
$upload_dir = wp_upload_dir();
|
305 |
$ast_directory = $upload_dir['basedir'] . '/ast-shipping-providers';
|
306 |
|
307 |
+
if( !is_dir( $ast_directory ) ) {
|
308 |
wp_mkdir_p( $ast_directory );
|
309 |
}
|
310 |
|
315 |
$providers_name = array();
|
316 |
|
317 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_default = 1" );
|
318 |
+
foreach ( $default_shippment_providers as $key => $val ) {
|
319 |
$shippment_providers[ $val->provider_name ] = $val;
|
320 |
}
|
321 |
|
322 |
+
foreach ( $providers as $key => $val ) {
|
323 |
$providers_name[ $val['provider_name'] ] = $val;
|
324 |
}
|
325 |
|
326 |
$n = 0;
|
327 |
+
foreach ( $providers as $provider ) {
|
328 |
|
329 |
$provider_name = $provider['shipping_provider'];
|
330 |
$provider_url = $provider['provider_url'];
|
332 |
$ts_slug = $provider['shipping_provider_slug'];
|
333 |
$trackship_supported = $provider['trackship_supported'];
|
334 |
|
335 |
+
if ( isset( $shippment_providers[ $provider_name ] ) ) {
|
336 |
$db_provider_url = $shippment_providers[$provider_name]->provider_url;
|
337 |
$db_shipping_country = $shippment_providers[$provider_name]->shipping_country;
|
338 |
$db_ts_slug = $shippment_providers[$provider_name]->ts_slug;
|
339 |
$db_trackship_supported = $shippment_providers[$provider_name]->trackship_supported;
|
340 |
|
341 |
+
if ( ( $db_provider_url != $provider_url ) || ( $db_shipping_country != $shipping_country ) || ( $db_ts_slug != $ts_slug ) || ( $db_trackship_supported != $trackship_supported ) ) {
|
342 |
$data_array = array(
|
343 |
'ts_slug' => $ts_slug,
|
344 |
'provider_url' => $provider_url,
|
350 |
);
|
351 |
$wpdb->update( $this->table, $data_array, $where_array);
|
352 |
}
|
353 |
+
} else {
|
354 |
$img_url = $provider['img_url'];
|
355 |
$img_slug = sanitize_title($provider_name);
|
356 |
$img = $ast_directory.'/'.$img_slug.'.png';
|
367 |
file_put_contents($img, $data);
|
368 |
|
369 |
$display_in_order = 1;
|
370 |
+
if( $n > 14 ) {
|
371 |
+
$display_in_order = 0;
|
372 |
+
}
|
373 |
|
374 |
$data_array = array(
|
375 |
'shipping_country' => sanitize_text_field($shipping_country),
|
385 |
}
|
386 |
}
|
387 |
|
388 |
+
foreach ( $default_shippment_providers as $db_provider ) {
|
389 |
|
390 |
+
if ( !isset( $providers_name[ $db_provider->provider_name ] ) ) {
|
391 |
$where = array(
|
392 |
'provider_name' => $db_provider->provider_name,
|
393 |
'shipping_default' => 1
|
includes/class-wc-advanced-shipment-tracking-late-shipments.php
CHANGED
@@ -23,7 +23,7 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
23 |
public static function get_instance() {
|
24 |
|
25 |
if ( null === self::$instance ) {
|
26 |
-
self::$instance = new self;
|
27 |
}
|
28 |
|
29 |
return self::$instance;
|
@@ -44,15 +44,16 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
44 |
*
|
45 |
* @since 1.0
|
46 |
*/
|
47 |
-
public function init(){
|
|
|
48 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
49 |
|
50 |
-
$wcast_enable_late_shipments_email = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_enable_late_shipments_admin_email','');
|
51 |
|
52 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
53 |
-
if(!$wcast_enable_late_shipments_email || !$wc_ast_api_key){
|
54 |
-
return;
|
55 |
-
}
|
56 |
|
57 |
//cron schedule added
|
58 |
add_filter( 'cron_schedules', array( $this, 'late_shipments_cron_schedule') );
|
@@ -62,7 +63,7 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
62 |
//Send Late Shipments Email
|
63 |
add_action( self::CRON_HOOK, array( $this, 'send_late_shipments_email' ) );
|
64 |
|
65 |
-
if (!wp_next_scheduled( self::CRON_HOOK ) ) {
|
66 |
wp_schedule_event( time() , 'ast_late_shipments_cron_events', self::CRON_HOOK );
|
67 |
}
|
68 |
}
|
@@ -88,26 +89,24 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
88 |
|
89 |
$wcast_late_shipments_trigger_alert = isset( $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] ) ? $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] : '';
|
90 |
|
91 |
-
if(
|
92 |
|
93 |
$wcast_late_shipments_daily_digest_time = isset( $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] ) ? $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] : '';
|
94 |
|
95 |
// Create a Date Time object when the cron should run for the first time
|
96 |
$first_cron = new DateTime( date( 'Y-m-d' ) .' '. $wcast_late_shipments_daily_digest_time .':00', new DateTimeZone( wc_timezone_string() ) );
|
97 |
-
|
98 |
-
|
99 |
$first_cron->setTimeZone(new DateTimeZone("GMT"));
|
100 |
|
101 |
$time = new DateTime( date( 'Y-m-d H:i:s' ), new DateTimeZone( wc_timezone_string() ) );
|
102 |
|
103 |
-
if( $time->getTimestamp() >
|
104 |
$first_cron->modify( '+1 day' );
|
105 |
}
|
106 |
|
107 |
wp_schedule_event( $first_cron->format( 'U' ) + $first_cron->getOffset(), 'daily', self::CRON_HOOK );
|
108 |
|
109 |
-
} else{
|
110 |
-
if (!wp_next_scheduled( self::CRON_HOOK ) ) {
|
111 |
wp_schedule_event( time() , 'ast_late_shipments_cron_events', self::CRON_HOOK );
|
112 |
}
|
113 |
}
|
@@ -120,7 +119,7 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
120 |
*
|
121 |
* @return array
|
122 |
*/
|
123 |
-
function late_shipments_cron_schedule( $schedules ){
|
124 |
|
125 |
$schedules[ 'ast_late_shipments_cron_events' ] = array(
|
126 |
'interval' => 86400,
|
@@ -155,32 +154,35 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
155 |
$wcast_late_shipments_settings = new wcast_late_shipments_customizer_email();
|
156 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
157 |
|
158 |
-
$wcast_late_shipments_days = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_late_shipments_days'
|
159 |
|
160 |
foreach ( $orders->posts as $order ) {
|
161 |
$order_object = new WC_Order( $order->ID );
|
162 |
$shipment_status = get_post_meta( $order_object->get_id(), "shipment_status", true);
|
163 |
|
164 |
-
foreach($shipment_status as $key => $tracker){
|
165 |
-
|
166 |
-
|
167 |
$shipment_length = $this->get_shipment_length($tracker);
|
168 |
|
169 |
-
if($tracker['status']
|
170 |
-
|
|
|
|
|
171 |
$late_shipments = get_post_meta( $order_object->get_id(), 'late_shipments_email', true );
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
177 |
update_post_meta( $order_object->get_id(), 'late_shipments_email', $late_shipments_array );
|
178 |
}
|
179 |
}
|
180 |
-
} else{
|
181 |
-
$email_send = $this->late_shippment_email_trigger($order_object->get_id(), $order_object, $tracker, $tracking_items[$key]['tracking_number']);
|
182 |
-
if($email_send){
|
183 |
-
$late_shipments_array[$tracking_items[$key]['tracking_number']] = array( 'email_send'
|
184 |
update_post_meta( $order_object->get_id(), 'late_shipments_email', $late_shipments_array );
|
185 |
}
|
186 |
}
|
@@ -195,17 +197,23 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
195 |
* get shiment lenth of tracker
|
196 |
* return (int)days
|
197 |
*/
|
198 |
-
function get_shipment_length($ep_tracker){
|
199 |
-
|
200 |
-
if(
|
|
|
|
|
201 |
|
202 |
-
|
|
|
|
|
|
|
|
|
203 |
$first_date = $first->datetime;
|
204 |
-
$last = ( isset( $ep_tracker['tracking_destination_events'] ) && count( $ep_tracker['tracking_destination_events'] ) > 0
|
205 |
$last_date = $last->datetime;
|
206 |
|
207 |
$status = $ep_tracker['status'];
|
208 |
-
if(
|
209 |
$last_date = date("Y-m-d H:i:s");
|
210 |
}
|
211 |
|
@@ -214,9 +222,9 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
214 |
}
|
215 |
|
216 |
/*
|
217 |
-
*
|
218 |
*/
|
219 |
-
function get_num_of_days( $first_date, $last_date ){
|
220 |
$date1 = strtotime($first_date);
|
221 |
$date2 = strtotime($last_date);
|
222 |
$diff = abs($date2 - $date1);
|
@@ -226,45 +234,38 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
226 |
/**
|
227 |
* code for send shipment status email
|
228 |
*/
|
229 |
-
public function late_shippment_email_trigger($order_id, $order, $tracker, $tracking_number){
|
230 |
|
231 |
$wcast_late_shipments_settings = new wcast_late_shipments_customizer_email();
|
232 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
233 |
|
234 |
-
$email_subject = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_late_shipments_email_subject'
|
235 |
|
236 |
-
$subject = wc_trackship_email_manager()->email_subject($email_subject
|
237 |
|
238 |
-
$email_to = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_late_shipments_email_to'
|
239 |
-
|
240 |
-
$email_to = explode(",",$email_to);
|
241 |
|
242 |
-
foreach($email_to as $email){
|
243 |
-
$email_heading = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_late_shipments_email_heading',$wcast_late_shipments_settings->defaults['wcast_late_shipments_email_heading']);
|
244 |
-
|
245 |
-
$email_content = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_late_shipments_email_content',$wcast_late_shipments_settings->defaults['wcast_late_shipments_email_content']);
|
246 |
|
247 |
-
$
|
248 |
-
$plain_text = false;
|
249 |
|
|
|
|
|
250 |
$wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
251 |
$tracking_items = $wast->get_tracking_items( $order_id, true );
|
252 |
|
253 |
-
foreach($tracking_items as $key => $item){
|
254 |
-
if($item['tracking_number'] != $tracking_number){
|
255 |
-
unset($tracking_items[$key]);
|
256 |
}
|
257 |
}
|
258 |
|
259 |
-
$recipient = wc_trackship_email_manager()->email_to($email
|
260 |
|
261 |
-
$email_content =
|
262 |
-
|
263 |
-
$email_content = $this->email_content($email_content,$order_id, $order, $tracker);
|
264 |
-
|
265 |
-
$mailer = WC()->mailer();
|
266 |
|
267 |
-
$email_heading = wc_trackship_email_manager()->email_heading($email_heading
|
268 |
|
269 |
ob_start();
|
270 |
|
@@ -272,7 +273,12 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
272 |
|
273 |
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
274 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $tracking_items, 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
275 |
-
}
|
|
|
|
|
|
|
|
|
|
|
276 |
wc_get_template( 'emails/tracking-info.php', array(
|
277 |
'tracking_items' => $tracking_items,
|
278 |
'order_id' => $order_id,
|
@@ -282,10 +288,11 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
282 |
|
283 |
// create a new email
|
284 |
$email = new WC_Email();
|
285 |
-
|
|
|
286 |
// wrap the content with the email template and then add styles
|
287 |
$email_content = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $email_content ) ) );
|
288 |
-
|
289 |
add_filter( 'wp_mail_from', array( wc_trackship_email_manager(), 'get_from_address' ) );
|
290 |
add_filter( 'wp_mail_from_name', array( wc_trackship_email_manager(), 'get_from_name' ) );
|
291 |
|
@@ -296,12 +303,17 @@ class WC_Advanced_Shipment_Tracking_Late_Shipments {
|
|
296 |
return $email_send;
|
297 |
}
|
298 |
}
|
|
|
299 |
/**
|
300 |
* code for format email content
|
301 |
*/
|
302 |
-
public function email_content($email_content, $order_id, $order, $tracker){
|
303 |
-
$shipment_length = $this->get_shipment_length($tracker);
|
304 |
-
$
|
|
|
|
|
|
|
|
|
305 |
return $email_content;
|
306 |
}
|
307 |
}
|
23 |
public static function get_instance() {
|
24 |
|
25 |
if ( null === self::$instance ) {
|
26 |
+
self::$instance = new self();
|
27 |
}
|
28 |
|
29 |
return self::$instance;
|
44 |
*
|
45 |
* @since 1.0
|
46 |
*/
|
47 |
+
public function init() {
|
48 |
+
|
49 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
50 |
|
51 |
+
$wcast_enable_late_shipments_email = $ast->get_option_value_from_array( 'late_shipments_email_settings', 'wcast_enable_late_shipments_admin_email', '' );
|
52 |
|
53 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
54 |
+
if ( !$wcast_enable_late_shipments_email || !$wc_ast_api_key ) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
|
58 |
//cron schedule added
|
59 |
add_filter( 'cron_schedules', array( $this, 'late_shipments_cron_schedule') );
|
63 |
//Send Late Shipments Email
|
64 |
add_action( self::CRON_HOOK, array( $this, 'send_late_shipments_email' ) );
|
65 |
|
66 |
+
if ( !wp_next_scheduled( self::CRON_HOOK ) ) {
|
67 |
wp_schedule_event( time() , 'ast_late_shipments_cron_events', self::CRON_HOOK );
|
68 |
}
|
69 |
}
|
89 |
|
90 |
$wcast_late_shipments_trigger_alert = isset( $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] ) ? $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] : '';
|
91 |
|
92 |
+
if ( 'daily_digest_on' == $wcast_late_shipments_trigger_alert ) {
|
93 |
|
94 |
$wcast_late_shipments_daily_digest_time = isset( $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] ) ? $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] : '';
|
95 |
|
96 |
// Create a Date Time object when the cron should run for the first time
|
97 |
$first_cron = new DateTime( date( 'Y-m-d' ) .' '. $wcast_late_shipments_daily_digest_time .':00', new DateTimeZone( wc_timezone_string() ) );
|
|
|
|
|
98 |
$first_cron->setTimeZone(new DateTimeZone("GMT"));
|
99 |
|
100 |
$time = new DateTime( date( 'Y-m-d H:i:s' ), new DateTimeZone( wc_timezone_string() ) );
|
101 |
|
102 |
+
if ( $time->getTimestamp() > $first_cron->getTimestamp() ) {
|
103 |
$first_cron->modify( '+1 day' );
|
104 |
}
|
105 |
|
106 |
wp_schedule_event( $first_cron->format( 'U' ) + $first_cron->getOffset(), 'daily', self::CRON_HOOK );
|
107 |
|
108 |
+
} else {
|
109 |
+
if ( !wp_next_scheduled( self::CRON_HOOK ) ) {
|
110 |
wp_schedule_event( time() , 'ast_late_shipments_cron_events', self::CRON_HOOK );
|
111 |
}
|
112 |
}
|
119 |
*
|
120 |
* @return array
|
121 |
*/
|
122 |
+
public function late_shipments_cron_schedule( $schedules ) {
|
123 |
|
124 |
$schedules[ 'ast_late_shipments_cron_events' ] = array(
|
125 |
'interval' => 86400,
|
154 |
$wcast_late_shipments_settings = new wcast_late_shipments_customizer_email();
|
155 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
156 |
|
157 |
+
$wcast_late_shipments_days = $ast->get_option_value_from_array( 'late_shipments_email_settings', 'wcast_late_shipments_days', $wcast_late_shipments_settings->defaults['wcast_late_shipments_days'] );
|
158 |
|
159 |
foreach ( $orders->posts as $order ) {
|
160 |
$order_object = new WC_Order( $order->ID );
|
161 |
$shipment_status = get_post_meta( $order_object->get_id(), "shipment_status", true);
|
162 |
|
163 |
+
foreach ( $shipment_status as $key => $tracker ) {
|
164 |
+
|
165 |
+
$tracking_items = ast_get_tracking_items( $order_object->get_id() );
|
166 |
$shipment_length = $this->get_shipment_length($tracker);
|
167 |
|
168 |
+
if ( 'available_for_pickup' != $tracker['status'] && 'delivered' != $tracker['status'] ) {
|
169 |
+
|
170 |
+
if ( $shipment_length >= $wcast_late_shipments_days ) {
|
171 |
+
|
172 |
$late_shipments = get_post_meta( $order_object->get_id(), 'late_shipments_email', true );
|
173 |
+
|
174 |
+
if ( isset( $late_shipments[$tracking_items[ $key ][ 'tracking_number' ] ] ) ) {
|
175 |
+
if ( 1 != $late_shipments[$tracking_items[ $key ][ 'tracking_number' ] ][ 'email_send' ] ) {
|
176 |
+
$email_send = $this->late_shippment_email_trigger( $order_object->get_id(), $order_object, $tracker, $tracking_items[ $key ][ 'tracking_number' ] );
|
177 |
+
if ( $email_send ) {
|
178 |
+
$late_shipments_array[ $tracking_items[ $key ][ 'tracking_number' ] ] = array( 'email_send' => '1' );
|
179 |
update_post_meta( $order_object->get_id(), 'late_shipments_email', $late_shipments_array );
|
180 |
}
|
181 |
}
|
182 |
+
} else {
|
183 |
+
$email_send = $this->late_shippment_email_trigger( $order_object->get_id(), $order_object, $tracker, $tracking_items[ $key ][ 'tracking_number' ] );
|
184 |
+
if ( $email_send ) {
|
185 |
+
$late_shipments_array[ $tracking_items[ $key ][ 'tracking_number' ] ] = array( 'email_send' => '1' );
|
186 |
update_post_meta( $order_object->get_id(), 'late_shipments_email', $late_shipments_array );
|
187 |
}
|
188 |
}
|
197 |
* get shiment lenth of tracker
|
198 |
* return (int)days
|
199 |
*/
|
200 |
+
public function get_shipment_length ( $ep_tracker ) {
|
201 |
+
|
202 |
+
if ( empty( $ep_tracker[ 'tracking_events' ] ) ) {
|
203 |
+
return 0;
|
204 |
+
}
|
205 |
|
206 |
+
if ( 0 == count( $ep_tracker[ 'tracking_events' ] ) ) {
|
207 |
+
return 0;
|
208 |
+
}
|
209 |
+
|
210 |
+
$first = reset( $ep_tracker['tracking_events'] );
|
211 |
$first_date = $first->datetime;
|
212 |
+
$last = ( isset( $ep_tracker['tracking_destination_events'] ) && count( $ep_tracker['tracking_destination_events'] ) > 0 ) ? end( $ep_tracker['tracking_destination_events'] ) : end( $ep_tracker['tracking_events'] );
|
213 |
$last_date = $last->datetime;
|
214 |
|
215 |
$status = $ep_tracker['status'];
|
216 |
+
if( 'delivered' != $status ) {
|
217 |
$last_date = date("Y-m-d H:i:s");
|
218 |
}
|
219 |
|
222 |
}
|
223 |
|
224 |
/*
|
225 |
+
* Get number of days from start date and end date
|
226 |
*/
|
227 |
+
public function get_num_of_days ( $first_date, $last_date ) {
|
228 |
$date1 = strtotime($first_date);
|
229 |
$date2 = strtotime($last_date);
|
230 |
$diff = abs($date2 - $date1);
|
234 |
/**
|
235 |
* code for send shipment status email
|
236 |
*/
|
237 |
+
public function late_shippment_email_trigger ( $order_id, $order, $tracker, $tracking_number ) {
|
238 |
|
239 |
$wcast_late_shipments_settings = new wcast_late_shipments_customizer_email();
|
240 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
241 |
|
242 |
+
$email_subject = $ast->get_option_value_from_array( 'late_shipments_email_settings', 'wcast_late_shipments_email_subject', $wcast_late_shipments_settings->defaults[ 'wcast_late_shipments_email_subject' ] );
|
243 |
|
244 |
+
$subject = wc_trackship_email_manager()->email_subject( $email_subject, $order_id, $order );
|
245 |
|
246 |
+
$email_to = $ast->get_option_value_from_array( 'late_shipments_email_settings', 'wcast_late_shipments_email_to', $wcast_late_shipments_settings->defaults[ 'wcast_late_shipments_email_to' ] );$email_to = explode( ",", $email_to );
|
|
|
|
|
247 |
|
248 |
+
foreach ( $email_to as $email ) {
|
|
|
|
|
|
|
249 |
|
250 |
+
$email_heading = $ast->get_option_value_from_array( 'late_shipments_email_settings', 'wcast_late_shipments_email_heading', $wcast_late_shipments_settings->defaults[ 'wcast_late_shipments_email_heading' ] );
|
|
|
251 |
|
252 |
+
$email_content = $ast->get_option_value_from_array( 'late_shipments_email_settings', 'wcast_late_shipments_email_content', $wcast_late_shipments_settings->defaults['wcast_late_shipments_email_content' ] );
|
253 |
+
|
254 |
$wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
255 |
$tracking_items = $wast->get_tracking_items( $order_id, true );
|
256 |
|
257 |
+
foreach ( $tracking_items as $key => $item ) {
|
258 |
+
if ( $item['tracking_number'] != $tracking_number ) {
|
259 |
+
unset( $tracking_items[ $key ] );
|
260 |
}
|
261 |
}
|
262 |
|
263 |
+
$recipient = wc_trackship_email_manager()->email_to( $email, $order, $order_id );
|
264 |
|
265 |
+
$email_content = $this->email_content( $email_content, $order_id, $order, $tracker );
|
266 |
+
$email_content = wc_trackship_email_manager()->email_content( $email_content, $order_id, $order );
|
|
|
|
|
|
|
267 |
|
268 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $order_id, $order );
|
269 |
|
270 |
ob_start();
|
271 |
|
273 |
|
274 |
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
275 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $tracking_items, 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
276 |
+
} elseif ( class_exists( 'ast_pro' ) ) {
|
277 |
+
wc_get_template( 'emails/fluid-tracking-info.php', array(
|
278 |
+
'tracking_items' => $tracking_items,
|
279 |
+
'order_id'=> $order_id
|
280 |
+
), 'woocommerce-advanced-shipment-tracking/', ast_pro()->get_plugin_path() . '/templates/' );
|
281 |
+
} else {
|
282 |
wc_get_template( 'emails/tracking-info.php', array(
|
283 |
'tracking_items' => $tracking_items,
|
284 |
'order_id' => $order_id,
|
288 |
|
289 |
// create a new email
|
290 |
$email = new WC_Email();
|
291 |
+
$mailer = WC()->mailer();
|
292 |
+
|
293 |
// wrap the content with the email template and then add styles
|
294 |
$email_content = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $email_content ) ) );
|
295 |
+
|
296 |
add_filter( 'wp_mail_from', array( wc_trackship_email_manager(), 'get_from_address' ) );
|
297 |
add_filter( 'wp_mail_from_name', array( wc_trackship_email_manager(), 'get_from_name' ) );
|
298 |
|
303 |
return $email_send;
|
304 |
}
|
305 |
}
|
306 |
+
|
307 |
/**
|
308 |
* code for format email content
|
309 |
*/
|
310 |
+
public function email_content ( $email_content, $order_id, $order, $tracker ) {
|
311 |
+
$shipment_length = $this->get_shipment_length( $tracker );
|
312 |
+
$shipment_status = apply_filters( 'trackship_status_filter', $tracker['status'] );
|
313 |
+
$est_delivery_date = $tracker['est_delivery_date'];
|
314 |
+
$email_content = str_replace( '{shipment_length}', $shipment_length, $email_content );
|
315 |
+
$email_content = str_replace( '{shipment_status}', $shipment_status, $email_content );
|
316 |
+
$email_content = str_replace( '{est_delivery_date}', $est_delivery_date, $email_content );
|
317 |
return $email_content;
|
318 |
}
|
319 |
}
|
includes/class-wc-advanced-shipment-tracking-license.php
CHANGED
@@ -28,7 +28,7 @@ class WC_Advanced_Shipment_Tracking_License {
|
|
28 |
public static function get_instance() {
|
29 |
|
30 |
if ( null === self::$instance ) {
|
31 |
-
self::$instance = new self;
|
32 |
}
|
33 |
|
34 |
return self::$instance;
|
@@ -74,7 +74,7 @@ class WC_Advanced_Shipment_Tracking_License {
|
|
74 |
*
|
75 |
*/
|
76 |
public function get_license_key() {
|
77 |
-
return get_option( 'ast_product_license_key', false);
|
78 |
}
|
79 |
|
80 |
/**
|
@@ -96,13 +96,13 @@ class WC_Advanced_Shipment_Tracking_License {
|
|
96 |
*
|
97 |
*/
|
98 |
public function get_license_status() {
|
99 |
-
return get_option( 'ast_product_license_status', false);
|
100 |
}
|
101 |
/*
|
102 |
//below line remove if in future not in use
|
103 |
*/
|
104 |
public function licence_valid() {
|
105 |
-
return get_option( 'ast_product_license_status', false);
|
106 |
}
|
107 |
|
108 |
|
@@ -136,7 +136,7 @@ class WC_Advanced_Shipment_Tracking_License {
|
|
136 |
*
|
137 |
*/
|
138 |
public function get_instance_id() {
|
139 |
-
return get_option( $this->get_item_code().'_instance_id', false);
|
140 |
}
|
141 |
|
142 |
/**
|
28 |
public static function get_instance() {
|
29 |
|
30 |
if ( null === self::$instance ) {
|
31 |
+
self::$instance = new self();
|
32 |
}
|
33 |
|
34 |
return self::$instance;
|
74 |
*
|
75 |
*/
|
76 |
public function get_license_key() {
|
77 |
+
return get_option( 'ast_product_license_key', false );
|
78 |
}
|
79 |
|
80 |
/**
|
96 |
*
|
97 |
*/
|
98 |
public function get_license_status() {
|
99 |
+
return get_option( 'ast_product_license_status', false );
|
100 |
}
|
101 |
/*
|
102 |
//below line remove if in future not in use
|
103 |
*/
|
104 |
public function licence_valid() {
|
105 |
+
return get_option( 'ast_product_license_status', false );
|
106 |
}
|
107 |
|
108 |
|
136 |
*
|
137 |
*/
|
138 |
public function get_instance_id() {
|
139 |
+
return get_option( $this->get_item_code().'_instance_id', false );
|
140 |
}
|
141 |
|
142 |
/**
|
includes/class-wc-advanced-shipment-tracking-settings.php
CHANGED
@@ -11,20 +11,23 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
11 |
public function __construct() {
|
12 |
|
13 |
global $wpdb;
|
14 |
-
|
|
|
|
|
|
|
15 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
16 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
17 |
}
|
18 |
-
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
19 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
20 |
-
$this->table = $main_blog_prefix."woo_shippment_provider";
|
21 |
-
} else{
|
22 |
-
$this->table = $wpdb->prefix."woo_shippment_provider";
|
23 |
-
}
|
24 |
-
} else{
|
25 |
-
$this->table = $wpdb->prefix."woo_shippment_provider";
|
26 |
-
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -42,7 +45,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
42 |
public static function get_instance() {
|
43 |
|
44 |
if ( null === self::$instance ) {
|
45 |
-
self::$instance = new self;
|
46 |
}
|
47 |
|
48 |
return self::$instance;
|
@@ -51,65 +54,66 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
51 |
/*
|
52 |
* init from parent mail class
|
53 |
*/
|
54 |
-
public function init(){
|
55 |
|
56 |
//rename order status + rename bulk action + rename filter
|
57 |
-
add_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status') );
|
58 |
-
add_filter( 'woocommerce_register_shop_order_post_statuses', array( $this, 'filter_woocommerce_register_shop_order_post_statuses'), 10, 1 );
|
59 |
-
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'modify_bulk_actions'), 50, 1 );
|
60 |
|
61 |
add_action( 'woocommerce_update_options_email_customer_partial_shipped_order', array( $this, 'save_partial_shipped_email' ) ,100, 1);
|
62 |
-
add_action( 'wp_ajax_sync_providers', array( $this, 'sync_providers_fun') );
|
63 |
|
64 |
//new order status
|
65 |
-
$newstatus = get_option(
|
66 |
-
if(
|
67 |
//register order status
|
68 |
-
add_action( 'init', array( $this, 'register_order_status') );
|
69 |
//add status after completed
|
70 |
-
add_filter( 'wc_order_statuses', array( $this, 'add_delivered_to_order_statuses') );
|
71 |
//Custom Statuses in admin reports
|
72 |
-
add_filter( 'woocommerce_reports_order_statuses', array( $this, 'include_custom_order_status_to_reports'), 20, 1 );
|
73 |
// for automate woo to check order is paid
|
74 |
add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'delivered_woocommerce_order_is_paid_statuses' ) );
|
75 |
//add bulk action
|
76 |
-
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions'), 50, 1 );
|
77 |
//add reorder button
|
78 |
-
add_filter( 'woocommerce_valid_order_statuses_for_order_again', array( $this, 'add_reorder_button_delivered'), 50, 1 );
|
79 |
}
|
80 |
|
81 |
//new order status
|
82 |
-
$updated_tracking_status = get_option(
|
83 |
-
if(
|
84 |
//register order status
|
85 |
-
add_action( 'init', array( $this, 'register_updated_tracking_order_status') );
|
86 |
//add status after completed
|
87 |
-
add_filter( 'wc_order_statuses', array( $this, 'add_updated_tracking_to_order_statuses') );
|
88 |
//Custom Statuses in admin reports
|
89 |
-
add_filter( 'woocommerce_reports_order_statuses', array( $this, 'include_updated_tracking_order_status_to_reports'), 20, 1 );
|
90 |
// for automate woo to check order is paid
|
91 |
add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'updated_tracking_woocommerce_order_is_paid_statuses' ) );
|
92 |
//add bulk action
|
93 |
-
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions_updated_tracking'), 50, 1 );
|
94 |
//add reorder button
|
95 |
-
add_filter( 'woocommerce_valid_order_statuses_for_order_again', array( $this, 'add_reorder_button_updated_tracking'), 50, 1 );
|
|
|
96 |
}
|
97 |
|
98 |
//new order status
|
99 |
-
$partial_shipped_status = get_option(
|
100 |
-
if(
|
101 |
//register order status
|
102 |
-
add_action( 'init', array( $this, 'register_partial_shipped_order_status') );
|
103 |
//add status after completed
|
104 |
-
add_filter( 'wc_order_statuses', array( $this, 'add_partial_shipped_to_order_statuses') );
|
105 |
//Custom Statuses in admin reports
|
106 |
-
add_filter( 'woocommerce_reports_order_statuses', array( $this, 'include_partial_shipped_order_status_to_reports'), 20, 1 );
|
107 |
// for automate woo to check order is paid
|
108 |
add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'partial_shipped_woocommerce_order_is_paid_statuses' ) );
|
109 |
//add bulk action
|
110 |
-
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions_partial_shipped'), 50, 1 );
|
111 |
//add reorder button
|
112 |
-
add_filter( 'woocommerce_valid_order_statuses_for_order_again', array( $this, 'add_reorder_button_partial_shipped'), 50, 1 );
|
113 |
}
|
114 |
|
115 |
// Hook for add admin body class in settings page
|
@@ -122,7 +126,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
122 |
/**
|
123 |
* Register new status : Delivered
|
124 |
**/
|
125 |
-
function register_order_status() {
|
126 |
register_post_status( 'wc-delivered', array(
|
127 |
'label' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
|
128 |
'public' => true,
|
@@ -136,7 +140,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
136 |
/**
|
137 |
* Register new status : Updated Tracking
|
138 |
**/
|
139 |
-
function register_updated_tracking_order_status() {
|
140 |
register_post_status( 'wc-updated-tracking', array(
|
141 |
'label' => __( 'Updated Tracking', 'woo-advanced-shipment-tracking' ),
|
142 |
'public' => true,
|
@@ -150,7 +154,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
150 |
/**
|
151 |
* Register new status : Partially Shipped
|
152 |
**/
|
153 |
-
function register_partial_shipped_order_status() {
|
154 |
register_post_status( 'wc-partial-shipped', array(
|
155 |
'label' => __( 'Partially Shipped', 'woo-advanced-shipment-tracking' ),
|
156 |
'public' => true,
|
@@ -164,7 +168,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
164 |
/*
|
165 |
* add status after completed
|
166 |
*/
|
167 |
-
function add_delivered_to_order_statuses( $order_statuses ) {
|
168 |
$new_order_statuses = array();
|
169 |
foreach ( $order_statuses as $key => $status ) {
|
170 |
$new_order_statuses[ $key ] = $status;
|
@@ -179,7 +183,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
179 |
/*
|
180 |
* add status after completed
|
181 |
*/
|
182 |
-
function add_updated_tracking_to_order_statuses( $order_statuses ) {
|
183 |
$new_order_statuses = array();
|
184 |
foreach ( $order_statuses as $key => $status ) {
|
185 |
$new_order_statuses[ $key ] = $status;
|
@@ -193,7 +197,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
193 |
/*
|
194 |
* add status after completed
|
195 |
*/
|
196 |
-
function add_partial_shipped_to_order_statuses( $order_statuses ) {
|
197 |
$new_order_statuses = array();
|
198 |
foreach ( $order_statuses as $key => $status ) {
|
199 |
$new_order_statuses[ $key ] = $status;
|
@@ -207,31 +211,37 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
207 |
/*
|
208 |
* Adding the custom order status to the default woocommerce order statuses
|
209 |
*/
|
210 |
-
function include_custom_order_status_to_reports( $statuses ){
|
211 |
-
if($statuses)
|
|
|
|
|
212 |
return $statuses;
|
213 |
}
|
214 |
|
215 |
/*
|
216 |
* Adding the updated-tracking order status to the default woocommerce order statuses
|
217 |
*/
|
218 |
-
function include_updated_tracking_order_status_to_reports( $statuses ){
|
219 |
-
if($statuses)
|
|
|
|
|
220 |
return $statuses;
|
221 |
}
|
222 |
|
223 |
/*
|
224 |
* Adding the partial-shipped order status to the default woocommerce order statuses
|
225 |
*/
|
226 |
-
function include_partial_shipped_order_status_to_reports( $statuses ){
|
227 |
-
if($statuses)
|
|
|
|
|
228 |
return $statuses;
|
229 |
}
|
230 |
|
231 |
/*
|
232 |
* mark status as a paid.
|
233 |
*/
|
234 |
-
function delivered_woocommerce_order_is_paid_statuses( $statuses ) {
|
235 |
$statuses[] = 'delivered';
|
236 |
return $statuses;
|
237 |
}
|
@@ -239,7 +249,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
239 |
/*
|
240 |
* mark status as a paid.
|
241 |
*/
|
242 |
-
function updated_tracking_woocommerce_order_is_paid_statuses( $statuses ) {
|
243 |
$statuses[] = 'updated-tracking';
|
244 |
return $statuses;
|
245 |
}
|
@@ -247,7 +257,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
247 |
/*
|
248 |
* mark status as a paid.
|
249 |
*/
|
250 |
-
function partial_shipped_woocommerce_order_is_paid_statuses( $statuses ) {
|
251 |
$statuses[] = 'partial-shipped';
|
252 |
return $statuses;
|
253 |
}
|
@@ -256,7 +266,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
256 |
* add bulk action
|
257 |
* Change order status to delivered
|
258 |
*/
|
259 |
-
function add_bulk_actions( $bulk_actions ){
|
260 |
$lable = wc_get_order_status_name( 'delivered' );
|
261 |
$bulk_actions['mark_delivered'] = __( 'Change status to '.$lable.'', 'woo-advanced-shipment-tracking' );
|
262 |
return $bulk_actions;
|
@@ -266,7 +276,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
266 |
* add bulk action
|
267 |
* Change order status to Updated Tracking
|
268 |
*/
|
269 |
-
function add_bulk_actions_updated_tracking( $bulk_actions ){
|
270 |
$lable = wc_get_order_status_name( 'updated-tracking' );
|
271 |
$bulk_actions['mark_updated-tracking'] = __( 'Change status to '.$lable.'', 'woo-advanced-shipment-tracking' );
|
272 |
return $bulk_actions;
|
@@ -276,7 +286,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
276 |
* add bulk action
|
277 |
* Change order status to Partially Shipped
|
278 |
*/
|
279 |
-
function add_bulk_actions_partial_shipped( $bulk_actions ){
|
280 |
$lable = wc_get_order_status_name( 'partial-shipped' );
|
281 |
$bulk_actions['mark_partial-shipped'] = __( 'Change status to '.$lable.'', 'woo-advanced-shipment-tracking' );
|
282 |
return $bulk_actions;
|
@@ -285,7 +295,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
285 |
/*
|
286 |
* add order again button for delivered order status
|
287 |
*/
|
288 |
-
function add_reorder_button_delivered( $statuses ){
|
289 |
$statuses[] = 'delivered';
|
290 |
return $statuses;
|
291 |
}
|
@@ -293,7 +303,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
293 |
/*
|
294 |
* add order again button for delivered order status
|
295 |
*/
|
296 |
-
function add_reorder_button_partial_shipped( $statuses ){
|
297 |
$statuses[] = 'partial-shipped';
|
298 |
return $statuses;
|
299 |
}
|
@@ -301,18 +311,31 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
301 |
/*
|
302 |
* add order again button for delivered order status
|
303 |
*/
|
304 |
-
function add_reorder_button_updated_tracking( $statuses ){
|
305 |
$statuses[] = 'updated-tracking';
|
306 |
return $statuses;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
}
|
308 |
|
309 |
/*
|
310 |
* Rename WooCommerce Order Status
|
311 |
*/
|
312 |
-
function wc_renaming_order_status( $order_statuses ) {
|
313 |
|
314 |
-
$enable = get_option(
|
315 |
-
if(
|
|
|
|
|
316 |
|
317 |
foreach ( $order_statuses as $key => $status ) {
|
318 |
$new_order_statuses[ $key ] = $status;
|
@@ -328,12 +351,14 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
328 |
* rename filter
|
329 |
* rename from completed to shipped
|
330 |
*/
|
331 |
-
function filter_woocommerce_register_shop_order_post_statuses( $array ) {
|
332 |
|
333 |
-
$enable = get_option(
|
334 |
-
if(
|
|
|
|
|
335 |
|
336 |
-
if( isset( $array[ 'wc-completed' ] ) ){
|
337 |
$array[ 'wc-completed' ]['label_count'] = _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>', 'woo-advanced-shipment-tracking' );
|
338 |
}
|
339 |
return $array;
|
@@ -342,12 +367,14 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
342 |
/*
|
343 |
* rename bulk action
|
344 |
*/
|
345 |
-
function modify_bulk_actions($bulk_actions) {
|
346 |
|
347 |
-
$enable = get_option(
|
348 |
-
if(
|
|
|
|
|
349 |
|
350 |
-
if( isset( $bulk_actions['mark_completed'] ) ){
|
351 |
$bulk_actions['mark_completed'] = __( 'Change status to shipped', 'woo-advanced-shipment-tracking' );
|
352 |
}
|
353 |
return $bulk_actions;
|
@@ -356,95 +383,62 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
356 |
/*
|
357 |
* Add class in admin settings page
|
358 |
*/
|
359 |
-
public function ahipment_tracking_admin_body_class($classes){
|
360 |
-
$page = (isset($_REQUEST[
|
361 |
-
if(
|
362 |
$classes .= ' shipment_tracking_admin_settings';
|
363 |
}
|
364 |
-
if(
|
365 |
$classes .= ' trackship_admin_settings';
|
366 |
}
|
367 |
return $classes;
|
368 |
}
|
369 |
|
370 |
-
public function ast_open_inline_tracking_form_fun(){
|
371 |
-
$order_id = wc_clean($_POST['order_id']);
|
372 |
|
373 |
-
$
|
374 |
-
$
|
375 |
-
|
376 |
-
if(empty($custom_order_number)){
|
377 |
-
$custom_order_number = $order_id;
|
378 |
-
}
|
379 |
|
380 |
global $wpdb;
|
381 |
$WC_Countries = new WC_Countries();
|
382 |
$countries = $WC_Countries->get_countries();
|
383 |
|
384 |
-
$
|
385 |
-
|
386 |
-
if( is_multisite() ){
|
387 |
-
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
388 |
-
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
389 |
-
}
|
390 |
-
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
391 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
392 |
-
$woo_shippment_table_name = $main_blog_prefix."woo_shippment_provider";
|
393 |
-
} else{
|
394 |
-
$woo_shippment_table_name = $wpdb->prefix."woo_shippment_provider";
|
395 |
-
}
|
396 |
-
} else{
|
397 |
-
$woo_shippment_table_name = $wpdb->prefix."woo_shippment_provider";
|
398 |
-
}
|
399 |
-
|
400 |
-
$shippment_countries = $wpdb->get_results( "SELECT shipping_country FROM $woo_shippment_table_name WHERE display_in_order = 1 GROUP BY shipping_country" );
|
401 |
-
|
402 |
-
$shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name" );
|
403 |
|
404 |
$default_provider = get_option("wc_ast_default_provider" );
|
405 |
-
$wc_ast_default_mark_shipped = get_option("wc_ast_default_mark_shipped" );
|
406 |
|
407 |
-
$wc_ast_status_shipped = get_option('wc_ast_status_shipped',0);
|
408 |
-
if($wc_ast_status_shipped == 1){
|
409 |
-
$change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
|
410 |
-
$shipped_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
|
411 |
-
} else{
|
412 |
-
$change_order_status_label = __( 'Mark as Completed?', 'woo-advanced-shipment-tracking' );
|
413 |
-
$shipped_label = __( 'Completed', 'woo-advanced-shipment-tracking' );
|
414 |
-
}
|
415 |
-
|
416 |
-
$wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
|
417 |
ob_start();
|
418 |
?>
|
419 |
<div id="" class="trackingpopup_wrapper add_tracking_popup" style="display:none;">
|
420 |
<div class="trackingpopup_row">
|
421 |
<div class="popup_header">
|
422 |
-
<h3 class="popup_title"><?php
|
423 |
<span class="dashicons dashicons-no-alt popup_close_icon"></span>
|
424 |
</div>
|
425 |
<div class="popup_body">
|
426 |
<form id="add_tracking_number_form" method="POST" class="add_tracking_number_form">
|
427 |
-
<?php do_action(
|
428 |
<p class="form-field tracking_number_field form-50">
|
429 |
-
<label for="tracking_number"><?php
|
430 |
<input type="text" class="short" name="tracking_number" id="tracking_number" value="" autocomplete="off">
|
431 |
</p>
|
432 |
<p class="form-field form-50">
|
433 |
-
<label for="tracking_number"><?php
|
434 |
<select class="chosen_select" id="tracking_provider" name="tracking_provider">
|
435 |
-
<option value=""><?php
|
436 |
<?php
|
437 |
-
foreach($shippment_countries as $s_c){
|
438 |
-
if($s_c->shipping_country
|
439 |
-
$country_name = esc_attr( $WC_Countries->countries[$s_c->shipping_country] );
|
440 |
-
} else{
|
441 |
$country_name = 'Global';
|
442 |
}
|
443 |
echo '<optgroup label="' . $country_name . '">';
|
444 |
$country = $s_c->shipping_country;
|
445 |
-
$shippment_providers_by_country = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $
|
446 |
foreach ( $shippment_providers_by_country as $providers ) {
|
447 |
-
$selected = ( $default_provider == esc_attr( $providers->ts_slug )
|
448 |
echo '<option value="' . esc_attr( $providers->ts_slug ) . '" '.$selected. '>' . esc_html( $providers->provider_name ) . '</option>';
|
449 |
}
|
450 |
echo '</optgroup>';
|
@@ -452,34 +446,21 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
452 |
</select>
|
453 |
</p>
|
454 |
<p class="form-field tracking_product_code_field form-50">
|
455 |
-
<label for="tracking_product_code"><?php
|
456 |
<input type="text" class="short" name="tracking_product_code" id="tracking_product_code" value="">
|
457 |
</p>
|
458 |
<p class="form-field date_shipped_field form-50">
|
459 |
-
<label for="date_shipped"><?php
|
460 |
-
<input type="text" class="date-picker-field" name="date_shipped" id="date_shipped" value="<?php echo date_i18n( __( 'Y-m-d', 'woo-advanced-shipment-tracking' ), current_time( 'timestamp' ) ); ?>" placeholder="<?php echo date_i18n(
|
461 |
</p>
|
462 |
-
<?php do_action(
|
463 |
<hr>
|
464 |
-
<?php
|
465 |
-
<fieldset class="form-field change_order_to_shipped_field">
|
466 |
-
<span><?php _e( 'Mark order as:', 'woo-advanced-shipment-tracking'); ?></span>
|
467 |
-
<ul class="wc-radios">
|
468 |
-
<li><label><input name="change_order_to_shipped" value="change_order_to_shipped" type="checkbox" class="select short mark_shipped_checkbox" <?php if($wc_ast_default_mark_shipped == 1){ echo 'checked'; }?>><?php _e( $shipped_label, 'woo-advanced-shipment-tracking'); ?></label></li>
|
469 |
-
<li><label><input name="change_order_to_shipped" value="change_order_to_partial_shipped" type="checkbox" class="select short mark_shipped_checkbox"><?php _e( 'Partial Shipped', 'woo-advanced-shipment-tracking'); ?></label></li>
|
470 |
-
</ul>
|
471 |
-
</fieldset>
|
472 |
-
<?php } else{ ?>
|
473 |
-
<p class="form-field change_order_to_shipped_field ">
|
474 |
-
<label for="change_order_to_shipped"><?php echo $change_order_status_label; ?></label>
|
475 |
-
<input type="checkbox" class="checkbox" style="" name="change_order_to_shipped" id="change_order_to_shipped" value="yes" <?php if($wc_ast_default_mark_shipped == 1){ echo 'checked'; }?>>
|
476 |
-
</p>
|
477 |
-
<?php } ?>
|
478 |
<hr>
|
479 |
<p>
|
480 |
<input type="hidden" name="action" value="add_inline_tracking_number">
|
481 |
-
<input type="hidden" name="order_id" id="order_id" value="<?php
|
482 |
-
<input type="submit" name="Submit" value="<?php
|
483 |
</p>
|
484 |
</form>
|
485 |
</div>
|
@@ -494,16 +475,16 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
494 |
/**
|
495 |
* Update Partially Shipped order email enable/disable in customizer
|
496 |
*/
|
497 |
-
public function save_partial_shipped_email($data){
|
498 |
-
$woocommerce_customer_partial_shipped_order_enabled = (isset($_POST[
|
499 |
-
update_option( 'customizer_partial_shipped_order_settings_enabled'
|
500 |
}
|
501 |
|
502 |
/**
|
503 |
* Synch provider function
|
504 |
*/
|
505 |
-
public function sync_providers_fun(){
|
506 |
-
$reset_checked = sanitize_text_field($_POST['reset_checked']);
|
507 |
global $wpdb;
|
508 |
|
509 |
$url = apply_filters( 'ast_sync_provider_url', 'https://trackship.info/wp-json/WCAST/v1/Provider' );
|
@@ -511,74 +492,76 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
511 |
|
512 |
$upload_dir = wp_upload_dir();
|
513 |
$ast_directory = $upload_dir['basedir'] . '/ast-shipping-providers';
|
514 |
-
|
|
|
515 |
wp_mkdir_p( $ast_directory );
|
516 |
}
|
517 |
|
518 |
if ( is_array( $resp ) && ! is_wp_error( $resp ) ) {
|
519 |
-
$providers = json_decode($resp['body'],true);
|
520 |
|
521 |
-
if($reset_checked
|
522 |
|
523 |
-
$wpdb->query(
|
524 |
|
525 |
$install = WC_Advanced_Shipment_Tracking_Install::get_instance();
|
526 |
$install->create_shippment_tracking_table();
|
527 |
|
528 |
-
foreach($providers as $provider){
|
529 |
$provider_name = $provider['shipping_provider'];
|
530 |
$provider_url = $provider['provider_url'];
|
531 |
$shipping_country = $provider['shipping_country'];
|
532 |
$ts_slug = $provider['shipping_provider_slug'];
|
533 |
$img_url = $provider['img_url'];
|
534 |
$trackship_supported = $provider['trackship_supported'];
|
535 |
-
$img_slug = sanitize_title($provider_name);
|
536 |
|
537 |
-
$img = $ast_directory.'/'
|
538 |
|
539 |
$ch = curl_init();
|
540 |
|
541 |
-
curl_setopt($ch, CURLOPT_HEADER, 0);
|
542 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
543 |
-
curl_setopt($ch, CURLOPT_URL, $img_url);
|
544 |
|
545 |
-
$data = curl_exec($ch);
|
546 |
-
curl_close($ch);
|
547 |
|
548 |
-
file_put_contents($img, $data);
|
549 |
|
550 |
-
|
551 |
$data_array = array(
|
552 |
-
'shipping_country' => sanitize_text_field($shipping_country),
|
553 |
-
'provider_name' => sanitize_text_field($provider_name),
|
554 |
'ts_slug' => $ts_slug,
|
555 |
-
'provider_url' => sanitize_text_field($provider_url),
|
556 |
'display_in_order' => 1,
|
557 |
'shipping_default' => 1,
|
558 |
-
'trackship_supported' => sanitize_text_field($trackship_supported),
|
559 |
);
|
560 |
|
561 |
$data_array = apply_filters( 'ast_sync_provider_data_array', $data_array, $provider );
|
562 |
|
563 |
$result = $wpdb->insert( $this->table, $data_array );
|
564 |
}
|
|
|
565 |
$status = 'active';
|
566 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
567 |
ob_start();
|
568 |
$admin = new WC_Advanced_Shipment_Tracking_Admin;
|
569 |
-
$html = $admin->get_provider_html($default_shippment_providers
|
570 |
$html = ob_get_clean();
|
571 |
|
572 |
-
echo json_encode( array( 'html' => $html) );
|
573 |
-
|
|
|
574 |
|
575 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
576 |
|
577 |
-
foreach ( $default_shippment_providers as $key => $val ){
|
578 |
$shippment_providers[ $val->provider_name ] = $val;
|
579 |
}
|
580 |
|
581 |
-
foreach ( $providers as $key => $val ){
|
582 |
$providers_name[ $val['provider_name'] ] = $val;
|
583 |
}
|
584 |
|
@@ -589,7 +572,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
589 |
$updated_html = '';
|
590 |
$deleted_html = '';
|
591 |
|
592 |
-
foreach($providers as $provider){
|
593 |
|
594 |
$provider_name = $provider['shipping_provider'];
|
595 |
$provider_url = $provider['provider_url'];
|
@@ -597,25 +580,25 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
597 |
$ts_slug = $provider['shipping_provider_slug'];
|
598 |
$trackship_supported = $provider['trackship_supported'];
|
599 |
|
600 |
-
if(isset($shippment_providers[$provider_name])){
|
601 |
-
$db_provider_url = $shippment_providers[$provider_name]->provider_url;
|
602 |
-
$db_shipping_country = $shippment_providers[$provider_name]->shipping_country;
|
603 |
-
$db_ts_slug = $shippment_providers[$provider_name]->ts_slug;
|
604 |
-
$db_trackship_supported = $shippment_providers[$provider_name]->trackship_supported;
|
605 |
|
606 |
$update_needed = apply_filters( 'ast_sync_provider_update', false, $provider, $shippment_providers );
|
607 |
|
608 |
-
if( $db_provider_url != $provider_url ){
|
609 |
$update_needed = true;
|
610 |
-
} elseif( $db_shipping_country != $shipping_country ){
|
611 |
$update_needed = true;
|
612 |
-
} elseif( $db_ts_slug != $ts_slug ){
|
613 |
$update_needed = true;
|
614 |
-
} elseif( $db_trackship_supported != $trackship_supported ){
|
615 |
$update_needed = true;
|
616 |
}
|
617 |
|
618 |
-
if( $update_needed ){
|
619 |
|
620 |
$data_array = array(
|
621 |
'ts_slug' => $ts_slug,
|
@@ -629,67 +612,71 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
629 |
$where_array = array(
|
630 |
'provider_name' => $provider_name,
|
631 |
);
|
632 |
-
$wpdb->update( $this->table, $data_array, $where_array);
|
633 |
-
$updated_data[$updated] = array('provider_name' => $provider_name);
|
634 |
$updated++;
|
635 |
}
|
636 |
-
} else{
|
637 |
$img_url = $provider['img_url'];
|
638 |
-
$img_slug = sanitize_title($provider_name);
|
639 |
-
$img = $ast_directory.'/'
|
640 |
|
641 |
$ch = curl_init();
|
642 |
|
643 |
-
curl_setopt($ch, CURLOPT_HEADER, 0);
|
644 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
645 |
-
curl_setopt($ch, CURLOPT_URL, $img_url);
|
646 |
|
647 |
-
$data = curl_exec($ch);
|
648 |
-
curl_close($ch);
|
649 |
|
650 |
-
file_put_contents($img, $data);
|
651 |
|
652 |
$data_array = array(
|
653 |
-
'shipping_country' => sanitize_text_field($shipping_country),
|
654 |
-
'provider_name' => sanitize_text_field($provider_name),
|
655 |
'ts_slug' => $ts_slug,
|
656 |
-
'provider_url' => sanitize_text_field($provider_url),
|
657 |
'display_in_order' => 0,
|
658 |
'shipping_default' => 1,
|
659 |
-
'trackship_supported' => sanitize_text_field($trackship_supported),
|
660 |
);
|
661 |
|
662 |
$data_array = apply_filters( 'ast_sync_provider_data_array', $data_array, $provider );
|
663 |
|
664 |
$result = $wpdb->insert( $this->table, $data_array );
|
665 |
-
$added_data[$added] = array('provider_name' => $provider_name);
|
666 |
$added++;
|
667 |
}
|
668 |
-
}
|
669 |
-
|
670 |
-
|
|
|
671 |
$where = array(
|
672 |
'provider_name' => $db_provider->provider_name,
|
673 |
'shipping_default' => 1
|
674 |
);
|
675 |
$wpdb->delete( $this->table, $where );
|
676 |
-
$deleted_data[$deleted] = array('provider_name' => $db_provider->provider_name);
|
677 |
$deleted++;
|
678 |
}
|
679 |
}
|
680 |
-
|
|
|
681 |
ob_start();
|
682 |
-
$added_html = $this->added_html($added_data);
|
683 |
$added_html = ob_get_clean();
|
684 |
}
|
685 |
-
|
|
|
686 |
ob_start();
|
687 |
-
$updated_html = $this->updated_html($updated_data);
|
688 |
$updated_html = ob_get_clean();
|
689 |
}
|
690 |
-
|
|
|
691 |
ob_start();
|
692 |
-
$deleted_html = $this->deleted_html($deleted_data);
|
693 |
$deleted_html = ob_get_clean();
|
694 |
}
|
695 |
|
@@ -697,58 +684,66 @@ class WC_Advanced_Shipment_Tracking_Settings {
|
|
697 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
698 |
ob_start();
|
699 |
$admin = new WC_Advanced_Shipment_Tracking_Admin;
|
700 |
-
$html = $admin->get_provider_html($default_shippment_providers
|
701 |
$html = ob_get_clean();
|
702 |
|
703 |
-
echo json_encode( array('added' => $added,'added_html'
|
|
|
704 |
}
|
705 |
-
} else{
|
706 |
-
echo json_encode( array('sync_error' => 1, 'message' => __( 'There are some issue with sync, Please Retry.', 'woo-advanced-shipment-tracking')) );
|
|
|
707 |
}
|
708 |
}
|
709 |
|
710 |
/**
|
711 |
* Output html of added provider from sync providers
|
712 |
*/
|
713 |
-
public function added_html($added_data){
|
|
|
714 |
<ul class="updated_details" id="added_providers">
|
715 |
<?php
|
716 |
-
foreach ( $added_data as $added ){
|
717 |
-
|
718 |
-
|
719 |
-
?>
|
720 |
</ul>
|
721 |
-
<a class="view_synch_details" id="view_added_details" href="javaScript:void(0);" style="display: block;"><?php
|
722 |
-
<a class="view_synch_details" id="hide_added_details" href="javaScript:void(0);" style="display: none;"><?php
|
723 |
-
<?php
|
|
|
724 |
|
725 |
/**
|
726 |
* Output html of updated provider from sync providers
|
727 |
*/
|
728 |
-
public function updated_html($updated_data){
|
|
|
729 |
<ul class="updated_details" id="updated_providers">
|
730 |
<?php
|
731 |
-
foreach ( $updated_data as $updated ){
|
732 |
-
|
733 |
-
|
734 |
-
?>
|
735 |
</ul>
|
736 |
-
<a class="view_synch_details" id="view_updated_details" href="javaScript:void(0);" style="display: block;"><?php
|
737 |
-
<a class="view_synch_details" id="hide_updated_details" href="javaScript:void(0);" style="display: none;"><?php
|
738 |
-
<?php
|
|
|
739 |
|
740 |
/**
|
741 |
* Output html of deleted provider from sync providers
|
742 |
*/
|
743 |
-
public function deleted_html($deleted_data){
|
|
|
744 |
<ul class="updated_details" id="deleted_providers">
|
745 |
<?php
|
746 |
-
foreach ( $deleted_data as $deleted ){
|
747 |
-
|
748 |
-
|
749 |
-
?>
|
750 |
</ul>
|
751 |
-
<a class="view_synch_details" id="view_deleted_details" href="javaScript:void(0);" style="display: block;"><?php
|
752 |
-
<a class="view_synch_details" id="hide_deleted_details" href="javaScript:void(0);" style="display: none;"><?php
|
753 |
-
<?php
|
|
|
754 |
}
|
11 |
public function __construct() {
|
12 |
|
13 |
global $wpdb;
|
14 |
+
$this->table = $wpdb->prefix . "woo_shippment_provider";
|
15 |
+
|
16 |
+
if ( is_multisite() ) {
|
17 |
+
|
18 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
19 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
23 |
+
$main_blog_prefix = $wpdb->get_blog_prefix( BLOG_ID_CURRENT_SITE );
|
24 |
+
$this->table = $main_blog_prefix . 'woo_shippment_provider';
|
25 |
+
} else {
|
26 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
27 |
+
}
|
28 |
+
} else {
|
29 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
30 |
+
}
|
31 |
}
|
32 |
|
33 |
/**
|
45 |
public static function get_instance() {
|
46 |
|
47 |
if ( null === self::$instance ) {
|
48 |
+
self::$instance = new self();
|
49 |
}
|
50 |
|
51 |
return self::$instance;
|
54 |
/*
|
55 |
* init from parent mail class
|
56 |
*/
|
57 |
+
public function init() {
|
58 |
|
59 |
//rename order status + rename bulk action + rename filter
|
60 |
+
add_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status' ) );
|
61 |
+
add_filter( 'woocommerce_register_shop_order_post_statuses', array( $this, 'filter_woocommerce_register_shop_order_post_statuses' ), 10, 1 );
|
62 |
+
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'modify_bulk_actions' ), 50, 1 );
|
63 |
|
64 |
add_action( 'woocommerce_update_options_email_customer_partial_shipped_order', array( $this, 'save_partial_shipped_email' ) ,100, 1);
|
65 |
+
add_action( 'wp_ajax_sync_providers', array( $this, 'sync_providers_fun' ) );
|
66 |
|
67 |
//new order status
|
68 |
+
$newstatus = get_option( 'wc_ast_status_delivered', 0 );
|
69 |
+
if ( true == $newstatus ) {
|
70 |
//register order status
|
71 |
+
add_action( 'init', array( $this, 'register_order_status' ) );
|
72 |
//add status after completed
|
73 |
+
add_filter( 'wc_order_statuses', array( $this, 'add_delivered_to_order_statuses' ) );
|
74 |
//Custom Statuses in admin reports
|
75 |
+
add_filter( 'woocommerce_reports_order_statuses', array( $this, 'include_custom_order_status_to_reports' ), 20, 1 );
|
76 |
// for automate woo to check order is paid
|
77 |
add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'delivered_woocommerce_order_is_paid_statuses' ) );
|
78 |
//add bulk action
|
79 |
+
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions' ), 50, 1 );
|
80 |
//add reorder button
|
81 |
+
add_filter( 'woocommerce_valid_order_statuses_for_order_again', array( $this, 'add_reorder_button_delivered' ), 50, 1 );
|
82 |
}
|
83 |
|
84 |
//new order status
|
85 |
+
$updated_tracking_status = get_option( 'wc_ast_status_updated_tracking', 0 );
|
86 |
+
if ( true == $updated_tracking_status ) {
|
87 |
//register order status
|
88 |
+
add_action( 'init', array( $this, 'register_updated_tracking_order_status' ) );
|
89 |
//add status after completed
|
90 |
+
add_filter( 'wc_order_statuses', array( $this, 'add_updated_tracking_to_order_statuses' ) );
|
91 |
//Custom Statuses in admin reports
|
92 |
+
add_filter( 'woocommerce_reports_order_statuses', array( $this, 'include_updated_tracking_order_status_to_reports' ), 20, 1 );
|
93 |
// for automate woo to check order is paid
|
94 |
add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'updated_tracking_woocommerce_order_is_paid_statuses' ) );
|
95 |
//add bulk action
|
96 |
+
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions_updated_tracking' ), 50, 1 );
|
97 |
//add reorder button
|
98 |
+
add_filter( 'woocommerce_valid_order_statuses_for_order_again', array( $this, 'add_reorder_button_updated_tracking' ), 50, 1 );
|
99 |
+
add_filter( 'wcast_order_status_email_type', array( $this, 'wcast_order_status_email_type' ), 50, 1 );
|
100 |
}
|
101 |
|
102 |
//new order status
|
103 |
+
$partial_shipped_status = get_option( 'wc_ast_status_partial_shipped', 0 );
|
104 |
+
if ( true == $partial_shipped_status ) {
|
105 |
//register order status
|
106 |
+
add_action( 'init', array( $this, 'register_partial_shipped_order_status' ) );
|
107 |
//add status after completed
|
108 |
+
add_filter( 'wc_order_statuses', array( $this, 'add_partial_shipped_to_order_statuses' ) );
|
109 |
//Custom Statuses in admin reports
|
110 |
+
add_filter( 'woocommerce_reports_order_statuses', array( $this, 'include_partial_shipped_order_status_to_reports' ), 20, 1 );
|
111 |
// for automate woo to check order is paid
|
112 |
add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'partial_shipped_woocommerce_order_is_paid_statuses' ) );
|
113 |
//add bulk action
|
114 |
+
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions_partial_shipped' ), 50, 1 );
|
115 |
//add reorder button
|
116 |
+
add_filter( 'woocommerce_valid_order_statuses_for_order_again', array( $this, 'add_reorder_button_partial_shipped' ), 50, 1 );
|
117 |
}
|
118 |
|
119 |
// Hook for add admin body class in settings page
|
126 |
/**
|
127 |
* Register new status : Delivered
|
128 |
**/
|
129 |
+
public function register_order_status() {
|
130 |
register_post_status( 'wc-delivered', array(
|
131 |
'label' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
|
132 |
'public' => true,
|
140 |
/**
|
141 |
* Register new status : Updated Tracking
|
142 |
**/
|
143 |
+
public function register_updated_tracking_order_status() {
|
144 |
register_post_status( 'wc-updated-tracking', array(
|
145 |
'label' => __( 'Updated Tracking', 'woo-advanced-shipment-tracking' ),
|
146 |
'public' => true,
|
154 |
/**
|
155 |
* Register new status : Partially Shipped
|
156 |
**/
|
157 |
+
public function register_partial_shipped_order_status() {
|
158 |
register_post_status( 'wc-partial-shipped', array(
|
159 |
'label' => __( 'Partially Shipped', 'woo-advanced-shipment-tracking' ),
|
160 |
'public' => true,
|
168 |
/*
|
169 |
* add status after completed
|
170 |
*/
|
171 |
+
public function add_delivered_to_order_statuses( $order_statuses ) {
|
172 |
$new_order_statuses = array();
|
173 |
foreach ( $order_statuses as $key => $status ) {
|
174 |
$new_order_statuses[ $key ] = $status;
|
183 |
/*
|
184 |
* add status after completed
|
185 |
*/
|
186 |
+
public function add_updated_tracking_to_order_statuses( $order_statuses ) {
|
187 |
$new_order_statuses = array();
|
188 |
foreach ( $order_statuses as $key => $status ) {
|
189 |
$new_order_statuses[ $key ] = $status;
|
197 |
/*
|
198 |
* add status after completed
|
199 |
*/
|
200 |
+
public function add_partial_shipped_to_order_statuses( $order_statuses ) {
|
201 |
$new_order_statuses = array();
|
202 |
foreach ( $order_statuses as $key => $status ) {
|
203 |
$new_order_statuses[ $key ] = $status;
|
211 |
/*
|
212 |
* Adding the custom order status to the default woocommerce order statuses
|
213 |
*/
|
214 |
+
public function include_custom_order_status_to_reports( $statuses ){
|
215 |
+
if ( $statuses ) {
|
216 |
+
$statuses[] = 'delivered';
|
217 |
+
}
|
218 |
return $statuses;
|
219 |
}
|
220 |
|
221 |
/*
|
222 |
* Adding the updated-tracking order status to the default woocommerce order statuses
|
223 |
*/
|
224 |
+
public function include_updated_tracking_order_status_to_reports( $statuses ){
|
225 |
+
if ( $statuses ) {
|
226 |
+
$statuses[] = 'updated-tracking';
|
227 |
+
}
|
228 |
return $statuses;
|
229 |
}
|
230 |
|
231 |
/*
|
232 |
* Adding the partial-shipped order status to the default woocommerce order statuses
|
233 |
*/
|
234 |
+
public function include_partial_shipped_order_status_to_reports( $statuses ){
|
235 |
+
if ( $statuses ) {
|
236 |
+
$statuses[] = 'partial-shipped';
|
237 |
+
}
|
238 |
return $statuses;
|
239 |
}
|
240 |
|
241 |
/*
|
242 |
* mark status as a paid.
|
243 |
*/
|
244 |
+
public function delivered_woocommerce_order_is_paid_statuses( $statuses ) {
|
245 |
$statuses[] = 'delivered';
|
246 |
return $statuses;
|
247 |
}
|
249 |
/*
|
250 |
* mark status as a paid.
|
251 |
*/
|
252 |
+
public function updated_tracking_woocommerce_order_is_paid_statuses( $statuses ) {
|
253 |
$statuses[] = 'updated-tracking';
|
254 |
return $statuses;
|
255 |
}
|
257 |
/*
|
258 |
* mark status as a paid.
|
259 |
*/
|
260 |
+
public function partial_shipped_woocommerce_order_is_paid_statuses( $statuses ) {
|
261 |
$statuses[] = 'partial-shipped';
|
262 |
return $statuses;
|
263 |
}
|
266 |
* add bulk action
|
267 |
* Change order status to delivered
|
268 |
*/
|
269 |
+
public function add_bulk_actions( $bulk_actions ) {
|
270 |
$lable = wc_get_order_status_name( 'delivered' );
|
271 |
$bulk_actions['mark_delivered'] = __( 'Change status to '.$lable.'', 'woo-advanced-shipment-tracking' );
|
272 |
return $bulk_actions;
|
276 |
* add bulk action
|
277 |
* Change order status to Updated Tracking
|
278 |
*/
|
279 |
+
public function add_bulk_actions_updated_tracking( $bulk_actions ) {
|
280 |
$lable = wc_get_order_status_name( 'updated-tracking' );
|
281 |
$bulk_actions['mark_updated-tracking'] = __( 'Change status to '.$lable.'', 'woo-advanced-shipment-tracking' );
|
282 |
return $bulk_actions;
|
286 |
* add bulk action
|
287 |
* Change order status to Partially Shipped
|
288 |
*/
|
289 |
+
public function add_bulk_actions_partial_shipped( $bulk_actions ) {
|
290 |
$lable = wc_get_order_status_name( 'partial-shipped' );
|
291 |
$bulk_actions['mark_partial-shipped'] = __( 'Change status to '.$lable.'', 'woo-advanced-shipment-tracking' );
|
292 |
return $bulk_actions;
|
295 |
/*
|
296 |
* add order again button for delivered order status
|
297 |
*/
|
298 |
+
public function add_reorder_button_delivered( $statuses ) {
|
299 |
$statuses[] = 'delivered';
|
300 |
return $statuses;
|
301 |
}
|
303 |
/*
|
304 |
* add order again button for delivered order status
|
305 |
*/
|
306 |
+
public function add_reorder_button_partial_shipped( $statuses ) {
|
307 |
$statuses[] = 'partial-shipped';
|
308 |
return $statuses;
|
309 |
}
|
311 |
/*
|
312 |
* add order again button for delivered order status
|
313 |
*/
|
314 |
+
public function add_reorder_button_updated_tracking( $statuses ) {
|
315 |
$statuses[] = 'updated-tracking';
|
316 |
return $statuses;
|
317 |
+
}
|
318 |
+
|
319 |
+
/*
|
320 |
+
* add Updated Tracking in order status email customizer
|
321 |
+
*/
|
322 |
+
public function wcast_order_status_email_type( $order_status ) {
|
323 |
+
$updated_tracking_status = array(
|
324 |
+
'updated_tracking' => __( 'Updated Tracking', 'woo-advanced-shipment-tracking' ),
|
325 |
+
);
|
326 |
+
$order_status = array_merge( $order_status, $updated_tracking_status );
|
327 |
+
return $order_status;
|
328 |
}
|
329 |
|
330 |
/*
|
331 |
* Rename WooCommerce Order Status
|
332 |
*/
|
333 |
+
public function wc_renaming_order_status( $order_statuses ) {
|
334 |
|
335 |
+
$enable = get_option( 'wc_ast_status_shipped', 0);
|
336 |
+
if ( false == $enable ) {
|
337 |
+
return $order_statuses;
|
338 |
+
}
|
339 |
|
340 |
foreach ( $order_statuses as $key => $status ) {
|
341 |
$new_order_statuses[ $key ] = $status;
|
351 |
* rename filter
|
352 |
* rename from completed to shipped
|
353 |
*/
|
354 |
+
public function filter_woocommerce_register_shop_order_post_statuses( $array ) {
|
355 |
|
356 |
+
$enable = get_option( 'wc_ast_status_shipped', 0);
|
357 |
+
if ( false == $enable ) {
|
358 |
+
return $array;
|
359 |
+
}
|
360 |
|
361 |
+
if ( isset( $array[ 'wc-completed' ] ) ) {
|
362 |
$array[ 'wc-completed' ]['label_count'] = _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>', 'woo-advanced-shipment-tracking' );
|
363 |
}
|
364 |
return $array;
|
367 |
/*
|
368 |
* rename bulk action
|
369 |
*/
|
370 |
+
public function modify_bulk_actions( $bulk_actions ) {
|
371 |
|
372 |
+
$enable = get_option( 'wc_ast_status_shipped', 0);
|
373 |
+
if ( false == $enable ) {
|
374 |
+
return $bulk_actions;
|
375 |
+
}
|
376 |
|
377 |
+
if ( isset( $bulk_actions['mark_completed'] ) ) {
|
378 |
$bulk_actions['mark_completed'] = __( 'Change status to shipped', 'woo-advanced-shipment-tracking' );
|
379 |
}
|
380 |
return $bulk_actions;
|
383 |
/*
|
384 |
* Add class in admin settings page
|
385 |
*/
|
386 |
+
public function ahipment_tracking_admin_body_class( $classes ) {
|
387 |
+
$page = ( isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '' );
|
388 |
+
if ( 'woocommerce-advanced-shipment-tracking' == $page ) {
|
389 |
$classes .= ' shipment_tracking_admin_settings';
|
390 |
}
|
391 |
+
if ( 'trackship-for-woocommerce' == $page ) {
|
392 |
$classes .= ' trackship_admin_settings';
|
393 |
}
|
394 |
return $classes;
|
395 |
}
|
396 |
|
397 |
+
public function ast_open_inline_tracking_form_fun() {
|
|
|
398 |
|
399 |
+
$order_id = wc_clean( $_POST['order_id'] );
|
400 |
+
$order = wc_get_order( $order_id );
|
401 |
+
$order_number = $order->get_order_number();
|
|
|
|
|
|
|
402 |
|
403 |
global $wpdb;
|
404 |
$WC_Countries = new WC_Countries();
|
405 |
$countries = $WC_Countries->get_countries();
|
406 |
|
407 |
+
$shippment_countries = $wpdb->get_results( "SELECT shipping_country FROM $this->table WHERE display_in_order = 1 GROUP BY shipping_country" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
|
409 |
$default_provider = get_option("wc_ast_default_provider" );
|
|
|
410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
ob_start();
|
412 |
?>
|
413 |
<div id="" class="trackingpopup_wrapper add_tracking_popup" style="display:none;">
|
414 |
<div class="trackingpopup_row">
|
415 |
<div class="popup_header">
|
416 |
+
<h3 class="popup_title"><?php esc_html_e( 'Add Tracking - order ', 'woo-advanced-shipment-tracking'); ?> - #<?php esc_html_e( $order_number ); ?></h2>
|
417 |
<span class="dashicons dashicons-no-alt popup_close_icon"></span>
|
418 |
</div>
|
419 |
<div class="popup_body">
|
420 |
<form id="add_tracking_number_form" method="POST" class="add_tracking_number_form">
|
421 |
+
<?php do_action( 'ast_tracking_form_between_form', $order_id, 'inline' ); ?>
|
422 |
<p class="form-field tracking_number_field form-50">
|
423 |
+
<label for="tracking_number"><?php esc_html_e( 'Tracking number:', 'woo-advanced-shipment-tracking'); ?></label>
|
424 |
<input type="text" class="short" name="tracking_number" id="tracking_number" value="" autocomplete="off">
|
425 |
</p>
|
426 |
<p class="form-field form-50">
|
427 |
+
<label for="tracking_number"><?php esc_html_e( 'Shipping Provider:', 'woo-advanced-shipment-tracking'); ?></label>
|
428 |
<select class="chosen_select" id="tracking_provider" name="tracking_provider">
|
429 |
+
<option value=""><?php esc_html_e( 'Shipping Provider:', 'woo-advanced-shipment-tracking' ); ?></option>
|
430 |
<?php
|
431 |
+
foreach ( $shippment_countries as $s_c ) {
|
432 |
+
if ( 'Global' != $s_c->shipping_country ) {
|
433 |
+
$country_name = esc_attr( $WC_Countries->countries[ $s_c->shipping_country ] );
|
434 |
+
} else {
|
435 |
$country_name = 'Global';
|
436 |
}
|
437 |
echo '<optgroup label="' . $country_name . '">';
|
438 |
$country = $s_c->shipping_country;
|
439 |
+
$shippment_providers_by_country = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table WHERE shipping_country = %s AND display_in_order = 1",$country ) );
|
440 |
foreach ( $shippment_providers_by_country as $providers ) {
|
441 |
+
$selected = ( $default_provider == esc_attr( $providers->ts_slug ) ) ? 'selected' : '';
|
442 |
echo '<option value="' . esc_attr( $providers->ts_slug ) . '" '.$selected. '>' . esc_html( $providers->provider_name ) . '</option>';
|
443 |
}
|
444 |
echo '</optgroup>';
|
446 |
</select>
|
447 |
</p>
|
448 |
<p class="form-field tracking_product_code_field form-50">
|
449 |
+
<label for="tracking_product_code"><?php esc_html_e( 'Product Code:', 'woo-advanced-shipment-tracking'); ?></label>
|
450 |
<input type="text" class="short" name="tracking_product_code" id="tracking_product_code" value="">
|
451 |
</p>
|
452 |
<p class="form-field date_shipped_field form-50">
|
453 |
+
<label for="date_shipped"><?php esc_html_e( 'Date shipped:', 'woo-advanced-shipment-tracking'); ?></label>
|
454 |
+
<input type="text" class="date-picker-field" name="date_shipped" id="date_shipped" value="<?php echo date_i18n( __( 'Y-m-d', 'woo-advanced-shipment-tracking' ), current_time( 'timestamp' ) ); ?>" placeholder="<?php echo date_i18n( esc_html_e( 'Y-m-d', 'woo-advanced-shipment-tracking' ), time() ); ?>">
|
455 |
</p>
|
456 |
+
<?php do_action( 'ast_after_tracking_field', $order_id ); ?>
|
457 |
<hr>
|
458 |
+
<?php wc_advanced_shipment_tracking()->actions->mark_order_as_fields_html(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
<hr>
|
460 |
<p>
|
461 |
<input type="hidden" name="action" value="add_inline_tracking_number">
|
462 |
+
<input type="hidden" name="order_id" id="order_id" value="<?php esc_html_e( $order_id ); ?>">
|
463 |
+
<input type="submit" name="Submit" value="<?php esc_html_e( 'Fulfill Order', 'woo-advanced-shipment-tracking' ); ?>" class="button-primary btn_green">
|
464 |
</p>
|
465 |
</form>
|
466 |
</div>
|
475 |
/**
|
476 |
* Update Partially Shipped order email enable/disable in customizer
|
477 |
*/
|
478 |
+
public function save_partial_shipped_email( $data ) {
|
479 |
+
$woocommerce_customer_partial_shipped_order_enabled = ( isset( $_POST['woocommerce_customer_partial_shipped_order_enabled'] ) ? wc_clean( $_REQUEST['woocommerce_customer_partial_shipped_order_enabled'] ) : "" );
|
480 |
+
update_option( 'customizer_partial_shipped_order_settings_enabled', $woocommerce_customer_partial_shipped_order_enabled );
|
481 |
}
|
482 |
|
483 |
/**
|
484 |
* Synch provider function
|
485 |
*/
|
486 |
+
public function sync_providers_fun() {
|
487 |
+
$reset_checked = sanitize_text_field( $_POST[ 'reset_checked' ] );
|
488 |
global $wpdb;
|
489 |
|
490 |
$url = apply_filters( 'ast_sync_provider_url', 'https://trackship.info/wp-json/WCAST/v1/Provider' );
|
492 |
|
493 |
$upload_dir = wp_upload_dir();
|
494 |
$ast_directory = $upload_dir['basedir'] . '/ast-shipping-providers';
|
495 |
+
|
496 |
+
if ( !is_dir( $ast_directory ) ) {
|
497 |
wp_mkdir_p( $ast_directory );
|
498 |
}
|
499 |
|
500 |
if ( is_array( $resp ) && ! is_wp_error( $resp ) ) {
|
501 |
+
$providers = json_decode( $resp['body'], true );
|
502 |
|
503 |
+
if ( 1 == $reset_checked ) {
|
504 |
|
505 |
+
$wpdb->query( 'DROP TABLE IF EXISTS $this->table' );
|
506 |
|
507 |
$install = WC_Advanced_Shipment_Tracking_Install::get_instance();
|
508 |
$install->create_shippment_tracking_table();
|
509 |
|
510 |
+
foreach ( $providers as $provider ) {
|
511 |
$provider_name = $provider['shipping_provider'];
|
512 |
$provider_url = $provider['provider_url'];
|
513 |
$shipping_country = $provider['shipping_country'];
|
514 |
$ts_slug = $provider['shipping_provider_slug'];
|
515 |
$img_url = $provider['img_url'];
|
516 |
$trackship_supported = $provider['trackship_supported'];
|
517 |
+
$img_slug = sanitize_title( $provider_name );
|
518 |
|
519 |
+
$img = $ast_directory . '/' . $img_slug . '.png';
|
520 |
|
521 |
$ch = curl_init();
|
522 |
|
523 |
+
curl_setopt( $ch, CURLOPT_HEADER, 0 );
|
524 |
+
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
525 |
+
curl_setopt( $ch, CURLOPT_URL, $img_url );
|
526 |
|
527 |
+
$data = curl_exec( $ch );
|
528 |
+
curl_close( $ch );
|
529 |
|
530 |
+
file_put_contents( $img, $data );
|
531 |
|
|
|
532 |
$data_array = array(
|
533 |
+
'shipping_country' => sanitize_text_field( $shipping_country ),
|
534 |
+
'provider_name' => sanitize_text_field( $provider_name ),
|
535 |
'ts_slug' => $ts_slug,
|
536 |
+
'provider_url' => sanitize_text_field( $provider_url ),
|
537 |
'display_in_order' => 1,
|
538 |
'shipping_default' => 1,
|
539 |
+
'trackship_supported' => sanitize_text_field( $trackship_supported ),
|
540 |
);
|
541 |
|
542 |
$data_array = apply_filters( 'ast_sync_provider_data_array', $data_array, $provider );
|
543 |
|
544 |
$result = $wpdb->insert( $this->table, $data_array );
|
545 |
}
|
546 |
+
|
547 |
$status = 'active';
|
548 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
549 |
ob_start();
|
550 |
$admin = new WC_Advanced_Shipment_Tracking_Admin;
|
551 |
+
$html = $admin->get_provider_html( $default_shippment_providers, $status );
|
552 |
$html = ob_get_clean();
|
553 |
|
554 |
+
echo json_encode( array( 'html' => $html ) );
|
555 |
+
exit;
|
556 |
+
} else {
|
557 |
|
558 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
559 |
|
560 |
+
foreach ( $default_shippment_providers as $key => $val ) {
|
561 |
$shippment_providers[ $val->provider_name ] = $val;
|
562 |
}
|
563 |
|
564 |
+
foreach ( $providers as $key => $val ) {
|
565 |
$providers_name[ $val['provider_name'] ] = $val;
|
566 |
}
|
567 |
|
572 |
$updated_html = '';
|
573 |
$deleted_html = '';
|
574 |
|
575 |
+
foreach ( $providers as $provider ) {
|
576 |
|
577 |
$provider_name = $provider['shipping_provider'];
|
578 |
$provider_url = $provider['provider_url'];
|
580 |
$ts_slug = $provider['shipping_provider_slug'];
|
581 |
$trackship_supported = $provider['trackship_supported'];
|
582 |
|
583 |
+
if ( isset( $shippment_providers[ $provider_name ] ) ) {
|
584 |
+
$db_provider_url = $shippment_providers[ $provider_name ]->provider_url;
|
585 |
+
$db_shipping_country = $shippment_providers[ $provider_name ]->shipping_country;
|
586 |
+
$db_ts_slug = $shippment_providers[ $provider_name ]->ts_slug;
|
587 |
+
$db_trackship_supported = $shippment_providers[ $provider_name ]->trackship_supported;
|
588 |
|
589 |
$update_needed = apply_filters( 'ast_sync_provider_update', false, $provider, $shippment_providers );
|
590 |
|
591 |
+
if ( $db_provider_url != $provider_url ) {
|
592 |
$update_needed = true;
|
593 |
+
} elseif ( $db_shipping_country != $shipping_country ) {
|
594 |
$update_needed = true;
|
595 |
+
} elseif ( $db_ts_slug != $ts_slug ) {
|
596 |
$update_needed = true;
|
597 |
+
} elseif ( $db_trackship_supported != $trackship_supported ) {
|
598 |
$update_needed = true;
|
599 |
}
|
600 |
|
601 |
+
if ( $update_needed ) {
|
602 |
|
603 |
$data_array = array(
|
604 |
'ts_slug' => $ts_slug,
|
612 |
$where_array = array(
|
613 |
'provider_name' => $provider_name,
|
614 |
);
|
615 |
+
$wpdb->update( $this->table, $data_array, $where_array );
|
616 |
+
$updated_data[ $updated ] = array( 'provider_name' => $provider_name );
|
617 |
$updated++;
|
618 |
}
|
619 |
+
} else {
|
620 |
$img_url = $provider['img_url'];
|
621 |
+
$img_slug = sanitize_title( $provider_name );
|
622 |
+
$img = $ast_directory . '/' . $img_slug . '.png';
|
623 |
|
624 |
$ch = curl_init();
|
625 |
|
626 |
+
curl_setopt( $ch, CURLOPT_HEADER, 0 );
|
627 |
+
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
628 |
+
curl_setopt( $ch, CURLOPT_URL, $img_url );
|
629 |
|
630 |
+
$data = curl_exec( $ch );
|
631 |
+
curl_close( $ch );
|
632 |
|
633 |
+
file_put_contents( $img, $data );
|
634 |
|
635 |
$data_array = array(
|
636 |
+
'shipping_country' => sanitize_text_field( $shipping_country ),
|
637 |
+
'provider_name' => sanitize_text_field( $provider_name ),
|
638 |
'ts_slug' => $ts_slug,
|
639 |
+
'provider_url' => sanitize_text_field( $provider_url ),
|
640 |
'display_in_order' => 0,
|
641 |
'shipping_default' => 1,
|
642 |
+
'trackship_supported' => sanitize_text_field( $trackship_supported ),
|
643 |
);
|
644 |
|
645 |
$data_array = apply_filters( 'ast_sync_provider_data_array', $data_array, $provider );
|
646 |
|
647 |
$result = $wpdb->insert( $this->table, $data_array );
|
648 |
+
$added_data[ $added ] = array( 'provider_name' => $provider_name );
|
649 |
$added++;
|
650 |
}
|
651 |
+
}
|
652 |
+
|
653 |
+
foreach ( $default_shippment_providers as $db_provider ) {
|
654 |
+
if ( !isset( $providers_name[ $db_provider->provider_name ] ) ) {
|
655 |
$where = array(
|
656 |
'provider_name' => $db_provider->provider_name,
|
657 |
'shipping_default' => 1
|
658 |
);
|
659 |
$wpdb->delete( $this->table, $where );
|
660 |
+
$deleted_data[ $deleted ] = array( 'provider_name' => $db_provider->provider_name );
|
661 |
$deleted++;
|
662 |
}
|
663 |
}
|
664 |
+
|
665 |
+
if ( $added > 0 ) {
|
666 |
ob_start();
|
667 |
+
$added_html = $this->added_html( $added_data );
|
668 |
$added_html = ob_get_clean();
|
669 |
}
|
670 |
+
|
671 |
+
if ( $updated > 0 ) {
|
672 |
ob_start();
|
673 |
+
$updated_html = $this->updated_html( $updated_data );
|
674 |
$updated_html = ob_get_clean();
|
675 |
}
|
676 |
+
|
677 |
+
if ( $deleted > 0 ) {
|
678 |
ob_start();
|
679 |
+
$deleted_html = $this->deleted_html( $deleted_data );
|
680 |
$deleted_html = ob_get_clean();
|
681 |
}
|
682 |
|
684 |
$default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table ORDER BY shipping_default ASC, display_in_order DESC, trackship_supported DESC, id ASC" );
|
685 |
ob_start();
|
686 |
$admin = new WC_Advanced_Shipment_Tracking_Admin;
|
687 |
+
$html = $admin->get_provider_html( $default_shippment_providers, $status );
|
688 |
$html = ob_get_clean();
|
689 |
|
690 |
+
echo json_encode( array( 'added' => $added, 'added_html' => $added_html, 'updated' => $updated, 'updated_html' => $updated_html, 'deleted' => $deleted, 'deleted_html' => $deleted_html,'html' => $html ) );
|
691 |
+
exit;
|
692 |
}
|
693 |
+
} else {
|
694 |
+
echo json_encode( array( 'sync_error' => 1, 'message' => __( 'There are some issue with sync, Please Retry.', 'woo-advanced-shipment-tracking') ) );
|
695 |
+
exit;
|
696 |
}
|
697 |
}
|
698 |
|
699 |
/**
|
700 |
* Output html of added provider from sync providers
|
701 |
*/
|
702 |
+
public function added_html( $added_data ) {
|
703 |
+
?>
|
704 |
<ul class="updated_details" id="added_providers">
|
705 |
<?php
|
706 |
+
foreach ( $added_data as $added ) {
|
707 |
+
?>
|
708 |
+
<li><?php esc_html_e( $added['provider_name'] ); ?></li>
|
709 |
+
<?php } ?>
|
710 |
</ul>
|
711 |
+
<a class="view_synch_details" id="view_added_details" href="javaScript:void(0);" style="display: block;"><?php esc_html_e( 'view details', 'woo-advanced-shipment-tracking' ); ?></a>
|
712 |
+
<a class="view_synch_details" id="hide_added_details" href="javaScript:void(0);" style="display: none;"><?php esc_html_e( 'hide details', 'woo-advanced-shipment-tracking' ); ?></a>
|
713 |
+
<?php
|
714 |
+
}
|
715 |
|
716 |
/**
|
717 |
* Output html of updated provider from sync providers
|
718 |
*/
|
719 |
+
public function updated_html( $updated_data ) {
|
720 |
+
?>
|
721 |
<ul class="updated_details" id="updated_providers">
|
722 |
<?php
|
723 |
+
foreach ( $updated_data as $updated ) {
|
724 |
+
?>
|
725 |
+
<li><?php esc_html_e( $updated['provider_name'] ); ?></li>
|
726 |
+
<?php } ?>
|
727 |
</ul>
|
728 |
+
<a class="view_synch_details" id="view_updated_details" href="javaScript:void(0);" style="display: block;"><?php esc_html_e( 'view details', 'woo-advanced-shipment-tracking' ); ?></a>
|
729 |
+
<a class="view_synch_details" id="hide_updated_details" href="javaScript:void(0);" style="display: none;"><?php esc_html_e( 'hide details', 'woo-advanced-shipment-tracking' ); ?></a>
|
730 |
+
<?php
|
731 |
+
}
|
732 |
|
733 |
/**
|
734 |
* Output html of deleted provider from sync providers
|
735 |
*/
|
736 |
+
public function deleted_html( $deleted_data ) {
|
737 |
+
?>
|
738 |
<ul class="updated_details" id="deleted_providers">
|
739 |
<?php
|
740 |
+
foreach ( $deleted_data as $deleted ) {
|
741 |
+
?>
|
742 |
+
<li><?php esc_html_e( $deleted['provider_name'] ); ?></li>
|
743 |
+
<?php } ?>
|
744 |
</ul>
|
745 |
+
<a class="view_synch_details" id="view_deleted_details" href="javaScript:void(0);" style="display: block;"><?php esc_html_e( 'view details', 'woo-advanced-shipment-tracking'); ?></a>
|
746 |
+
<a class="view_synch_details" id="hide_deleted_details" href="javaScript:void(0);" style="display: none;"><?php esc_html_e( 'hide details', 'woo-advanced-shipment-tracking'); ?></a>
|
747 |
+
<?php
|
748 |
+
}
|
749 |
}
|
includes/class-wc-advanced-shipment-tracking-trackship.php
CHANGED
@@ -11,18 +11,22 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
11 |
public function __construct() {
|
12 |
|
13 |
global $wpdb;
|
14 |
-
|
|
|
|
|
|
|
15 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
16 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
17 |
}
|
|
|
18 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
19 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
20 |
-
$this->table = $main_blog_prefix.
|
21 |
-
} else{
|
22 |
-
$this->table = $wpdb->prefix.
|
23 |
-
}
|
24 |
-
} else{
|
25 |
-
$this->table = $wpdb->prefix.
|
26 |
}
|
27 |
|
28 |
}
|
@@ -43,7 +47,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
43 |
public static function get_instance() {
|
44 |
|
45 |
if ( null === self::$instance ) {
|
46 |
-
self::$instance = new self;
|
47 |
}
|
48 |
|
49 |
return self::$instance;
|
@@ -54,20 +58,15 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
54 |
*
|
55 |
* @since 1.0
|
56 |
*/
|
57 |
-
public function init(){
|
58 |
-
|
59 |
-
|
60 |
-
add_action(
|
61 |
|
62 |
-
|
63 |
-
$wc_ast_api_key
|
64 |
-
if($wc_ast_api_key){
|
65 |
|
66 |
-
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
|
67 |
-
|
68 |
-
//load trackship css js
|
69 |
-
|
70 |
-
//add_action('admin_menu', array( $this, 'register_woocommerce_trackship_menu' ), 99 );
|
71 |
|
72 |
//ajax save admin trackship settings
|
73 |
add_action( 'wp_ajax_wc_ast_trackship_form_update', array( $this, 'wc_ast_trackship_form_update_callback' ) );
|
@@ -75,14 +74,14 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
75 |
add_action( 'wp_ajax_ts_late_shipments_email_form_update', array( $this, 'ts_late_shipments_email_form_update_callback' ) );
|
76 |
|
77 |
//add Shipment status column after tracking
|
78 |
-
add_filter( 'manage_edit-shop_order_columns', array( $this, 'wc_add_order_shipment_status_column_header'), 20 );
|
79 |
-
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'wc_add_order_shipment_status_column_content') );
|
80 |
|
81 |
//add bulk action - get shipment status
|
82 |
-
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions_get_shipment_status'), 10, 1 );
|
83 |
|
84 |
// Make the action from selected orders to get shipment status
|
85 |
-
add_filter( 'handle_bulk_actions-edit-shop_order', array( $this, 'get_shipment_status_handle_bulk_action_edit_shop_order'), 10, 3 );
|
86 |
|
87 |
// Bulk shipment status sync ajax call from settings
|
88 |
add_action( 'wp_ajax_bulk_shipment_status_from_settings', array( $this, 'bulk_shipment_status_from_settings_fun' ) );
|
@@ -102,51 +101,51 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
102 |
|
103 |
// add bulk order filter for exported / non-exported orders
|
104 |
$wc_ast_show_shipment_status_filter = get_option( 'wc_ast_show_shipment_status_filter', 0 );
|
105 |
-
if(
|
106 |
-
add_action( 'restrict_manage_posts', array( $this, 'filter_orders_by_shipment_status') , 20 );
|
107 |
add_filter( 'request', array( $this, 'filter_orders_by_shipment_status_query' ) );
|
108 |
}
|
109 |
|
110 |
// trigger when order status changed to shipped or completed
|
111 |
-
add_action( 'woocommerce_order_status_completed', array( $this, 'trigger_woocommerce_order_status_completed'), 10, 1 );
|
112 |
|
113 |
-
add_action( 'send_order_to_trackship', array( $this, 'trigger_woocommerce_order_status_completed'), 10, 1 );
|
114 |
|
115 |
-
add_action( 'woocommerce_order_status_updated-tracking', array( $this, 'trigger_woocommerce_order_status_completed'), 10, 1 );
|
116 |
|
117 |
// filter for shipment status
|
118 |
-
add_filter(
|
119 |
|
120 |
// filter for shipment status icon
|
121 |
-
add_filter(
|
122 |
|
123 |
add_action( 'wcast_retry_trackship_apicall', array( $this, 'wcast_retry_trackship_apicall_func' ) );
|
124 |
|
125 |
-
add_action( 'wp_ajax_update_shipment_status_email_status', array( $this, 'update_shipment_status_email_status_fun') );
|
126 |
|
127 |
-
add_action( 'wp_ajax_update_enable_late_shipments_email', array( $this, 'update_enable_late_shipments_email_fun') );
|
128 |
|
129 |
-
add_action( 'ast_shipment_tracking_end', array( $this, 'display_shipment_tracking_info'), 10, 2 );
|
130 |
|
131 |
-
add_action( 'delete_tracking_number_from_trackship', array( $this, 'delete_tracking_number_from_trackship'), 10, 3 );
|
132 |
|
133 |
//fix shipment tracking for deleted tracking
|
134 |
-
add_action(
|
135 |
|
136 |
-
add_action( 'wp_dashboard_setup', array( $this, 'ast_add_dashboard_widgets') );
|
137 |
|
138 |
//filter in shipped orders
|
139 |
-
add_filter( 'is_order_shipped', array( $this,
|
140 |
-
add_filter( 'is_order_shipped', array( $this,
|
141 |
|
142 |
-
add_action( 'wp_ajax_wc_ast_trackship_automation_form_update', array( $this, 'wc_ast_trackship_automation_form_update') );
|
143 |
}
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
* Load trackship styles.
|
148 |
*/
|
149 |
-
public function trackship_styles($hook) {
|
150 |
|
151 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
152 |
|
@@ -154,40 +153,113 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
154 |
wp_register_script( 'trackship_script', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/trackship.js', array( 'jquery', 'wp-util' ), wc_advanced_shipment_tracking()->version, true );
|
155 |
wp_localize_script( 'trackship_script', 'trackship_script', array(
|
156 |
'i18n' => array(
|
157 |
-
'data_saved'
|
158 |
),
|
159 |
) );
|
160 |
|
161 |
-
if(!isset($_GET['page'])) {
|
162 |
return;
|
163 |
-
}
|
164 |
|
165 |
-
if( $_GET['page']
|
166 |
return;
|
167 |
-
}
|
168 |
|
169 |
wp_enqueue_style( 'trackship_styles' );
|
170 |
wp_enqueue_script( 'trackship_script' );
|
171 |
}
|
172 |
|
173 |
-
|
|
|
|
|
|
|
174 |
$trackship_tab = array(
|
175 |
-
'
|
176 |
-
'title' => '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
'show' => true,
|
178 |
'class' => 'tab_label',
|
179 |
-
'data-tab' => '
|
180 |
-
'data-label' => '
|
181 |
'name' => 'tabs',
|
182 |
-
),
|
183 |
);
|
184 |
-
|
185 |
-
|
186 |
-
return $setting_data;
|
187 |
-
}
|
188 |
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
}
|
192 |
|
193 |
/*
|
@@ -195,30 +267,74 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
195 |
* WC sub menu
|
196 |
*/
|
197 |
public function register_woocommerce_trackship_menu() {
|
198 |
-
|
199 |
-
if($wc_ast_api_key){
|
200 |
-
add_submenu_page( 'woocommerce', 'TrackShip', 'TrackShip', 'manage_woocommerce', 'trackship-for-woocommerce', array( $this, 'trackship_page_callback' ) );
|
201 |
-
}
|
202 |
}
|
203 |
|
204 |
/*
|
205 |
* callback for Shipment Tracking page
|
206 |
*/
|
207 |
-
public function trackship_page_callback(){
|
208 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
|
|
209 |
<div class="zorem-layout">
|
210 |
<div class="zorem-layout__header">
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
<?php } ?>
|
216 |
</div>
|
217 |
-
<?php
|
|
|
|
|
|
|
|
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
/*
|
224 |
* include file on plugin load
|
@@ -227,61 +343,66 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
227 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-tracking-page-customizer.php';
|
228 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-intransit-email-customizer.php';
|
229 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-failure-email-customizer.php';
|
|
|
230 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-outfordelivery-email-customizer.php';
|
231 |
-
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-delivered-email-customizer.php';
|
|
|
232 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-availableforpickup-email-customizer.php';
|
233 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-onhold-email-customizer.php';
|
234 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-late-shipments-email-customizer.php';
|
235 |
-
|
236 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/trackship-email-manager.php';
|
237 |
}
|
238 |
|
239 |
/*
|
240 |
* settings form save
|
241 |
*/
|
242 |
-
function wc_ast_trackship_form_update_callback(){
|
243 |
|
244 |
if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_trackship_form', 'wc_ast_trackship_form_nonce' ) ) {
|
245 |
|
246 |
$data2 = $this->get_trackship_general_data();
|
247 |
|
248 |
-
foreach( $data2 as $key2 => $val2 ){
|
249 |
update_option( $key2, sanitize_text_field( $_POST[ $key2 ] ) );
|
250 |
}
|
251 |
update_option( 'wc_ast_trackship_other_page', sanitize_text_field( $_POST[ 'wc_ast_trackship_other_page' ] ) );
|
252 |
-
echo json_encode( array('success' => 'true') );
|
|
|
253 |
}
|
254 |
}
|
255 |
|
256 |
/*
|
257 |
* tracking page form save
|
258 |
*/
|
259 |
-
public function trackship_tracking_page_form_update_callback(){
|
|
|
260 |
if ( ! empty( $_POST ) && check_admin_referer( 'trackship_tracking_page_form', 'trackship_tracking_page_form_nonce' ) ) {
|
261 |
|
262 |
-
$data1 = $this->
|
263 |
|
264 |
-
foreach( $data1 as $key1 => $val1 ){
|
265 |
update_option( $key1, sanitize_text_field( $_POST[ $key1 ] ) );
|
266 |
}
|
267 |
|
268 |
-
echo json_encode( array('success' => 'true') );
|
|
|
269 |
}
|
270 |
}
|
271 |
|
272 |
/*
|
273 |
* late shipmenta form save
|
274 |
*/
|
275 |
-
public function ts_late_shipments_email_form_update_callback(){
|
|
|
276 |
if ( ! empty( $_POST ) && check_admin_referer( 'ts_late_shipments_email_form', 'ts_late_shipments_email_form_nonce' ) ) {
|
277 |
|
278 |
-
$wcast_late_shipments_days = isset( $_POST['wcast_late_shipments_days'] ) ? $_POST['wcast_late_shipments_days'] : '';
|
279 |
-
$wcast_late_shipments_email_to = isset( $_POST['wcast_late_shipments_email_to'] ) ? $_POST['wcast_late_shipments_email_to'] : '';
|
280 |
-
$wcast_late_shipments_email_subject = isset( $_POST['wcast_late_shipments_email_subject'] ) ? $_POST['wcast_late_shipments_email_subject'] : '';
|
281 |
-
$wcast_late_shipments_email_content = isset( $_POST['wcast_late_shipments_email_content'] ) ? $_POST['wcast_late_shipments_email_content'] : '';
|
282 |
-
$wcast_late_shipments_trigger_alert = isset( $_POST['wcast_late_shipments_trigger_alert'] ) ? $_POST['wcast_late_shipments_trigger_alert'] : '';
|
283 |
-
$wcast_late_shipments_daily_digest_time = isset( $_POST['wcast_late_shipments_daily_digest_time'] ) ? $_POST['wcast_late_shipments_daily_digest_time'] : '';
|
284 |
-
$wcast_enable_late_shipments_admin_email = isset( $_POST['wcast_enable_late_shipments_admin_email'] ) ? $_POST['wcast_enable_late_shipments_admin_email'] : '';
|
285 |
|
286 |
$late_shipments_email_settings = array(
|
287 |
'wcast_enable_late_shipments_admin_email' => $wcast_enable_late_shipments_admin_email,
|
@@ -299,151 +420,79 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
299 |
$Late_Shipments->remove_cron();
|
300 |
$Late_Shipments->setup_cron();
|
301 |
}
|
302 |
-
}
|
303 |
-
|
304 |
/*
|
305 |
* get settings tab array data
|
306 |
* return array
|
307 |
*/
|
308 |
-
function
|
309 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
310 |
-
$trackers_balance = get_option( 'trackers_balance' );
|
311 |
-
if($wc_ast_api_key){
|
312 |
-
$connected = true;
|
313 |
-
$show_trackship_field = true;
|
314 |
-
$show_trackship_description = false;
|
315 |
-
} else{
|
316 |
-
$connected = false;
|
317 |
-
$show_trackship_field = false;
|
318 |
-
$show_trackship_description = true;
|
319 |
-
}
|
320 |
-
|
321 |
-
$page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' );
|
322 |
-
$wc_ast_trackship_page_id = get_option('wc_ast_trackship_page_id');
|
323 |
-
$post = get_post($wc_ast_trackship_page_id);
|
324 |
-
$slug = $post->post_name;
|
325 |
-
|
326 |
-
if($slug != 'ts-shipment-tracking'){
|
327 |
-
$page_desc = __( 'You must add the shortcode [wcast-track-order] to the selected page in order for the tracking page to work.', 'woo-advanced-shipment-tracking' );
|
328 |
-
} else{
|
329 |
-
$page_desc = '';
|
330 |
-
}
|
331 |
|
332 |
-
$
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
'
|
338 |
-
'
|
339 |
-
'
|
340 |
-
),
|
341 |
-
'wc_ast_trackship_other_page' => array(
|
342 |
-
'type' => 'text',
|
343 |
-
'title' => __( 'Select Tracking Page', 'woo-advanced-shipment-tracking' ),
|
344 |
-
'show' => $show_trackship_field,
|
345 |
-
'class' => '',
|
346 |
-
),
|
347 |
-
'wc_ast_use_tracking_page' => array(
|
348 |
-
'type' => 'checkbox',
|
349 |
-
'title' => __( 'Use the tracking page in the customer email/my account tracking link', 'woo-advanced-shipment-tracking' ),
|
350 |
-
'show' => $show_trackship_field,
|
351 |
-
'class' => '',
|
352 |
-
),
|
353 |
-
'wc_ast_select_tracking_page_layout' => array(
|
354 |
-
'type' => 'radio',
|
355 |
-
'title' => __( 'Tracking Page Layout', 'woo-advanced-shipment-tracking' ),
|
356 |
-
'show' => $show_trackship_field,
|
357 |
-
'options' => array(
|
358 |
-
"" =>__( 'Select', 'woocommerce' ),
|
359 |
-
"t_layout_1" =>__( 'Layout 1', '' ),
|
360 |
-
"t_layout_2" =>__( 'Layout 2', '' ),
|
361 |
-
),
|
362 |
-
'class' => '',
|
363 |
-
),
|
364 |
-
'wc_ast_select_border_color' => array(
|
365 |
-
'type' => 'color',
|
366 |
-
'title' => __( 'Select content border color for tracking page', 'woo-advanced-shipment-tracking' ),
|
367 |
-
'class' => 'color_field',
|
368 |
-
'show' => $show_trackship_field,
|
369 |
-
),
|
370 |
-
'wc_ast_link_to_shipping_provider' => array(
|
371 |
-
'type' => 'checkbox',
|
372 |
-
'title' => __( 'Add a link to the Shipping provider page', 'woo-advanced-shipment-tracking' ),
|
373 |
-
'show' => $show_trackship_field,
|
374 |
-
'class' => '',
|
375 |
-
),
|
376 |
-
'wc_ast_hide_tracking_provider_image' => array(
|
377 |
-
'type' => 'checkbox',
|
378 |
-
'title' => __( 'Hide Shipping Provider Image', 'woo-advanced-shipment-tracking' ),
|
379 |
-
'show' => $show_trackship_field,
|
380 |
-
'class' => '',
|
381 |
-
),
|
382 |
-
'wc_ast_hide_tracking_events' => array(
|
383 |
-
'type' => 'checkbox',
|
384 |
-
'title' => __( 'Hide tracking events details', 'woo-advanced-shipment-tracking' ),
|
385 |
-
'show' => $show_trackship_field,
|
386 |
-
'class' => '',
|
387 |
-
),
|
388 |
-
'wc_ast_remove_trackship_branding' => array(
|
389 |
-
'type' => 'checkbox',
|
390 |
-
'title' => __( 'Remove TrackShip branding', 'woo-advanced-shipment-tracking' ),
|
391 |
'show' => $show_trackship_field,
|
392 |
-
'class' => '',
|
393 |
),
|
394 |
);
|
395 |
return $form_data;
|
396 |
-
}
|
397 |
-
|
398 |
/*
|
399 |
* get settings tab array data
|
400 |
* return array
|
401 |
*/
|
402 |
-
function
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
$show_trackship_field = true;
|
407 |
-
} else{
|
408 |
-
$show_trackship_field = false;
|
409 |
-
}
|
410 |
|
411 |
$slug = '';
|
412 |
$page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' );
|
413 |
-
$wc_ast_trackship_page_id = get_option('wc_ast_trackship_page_id');
|
414 |
-
$post = get_post($wc_ast_trackship_page_id);
|
415 |
-
if( $post )$slug = $post->post_name;
|
416 |
|
417 |
-
if($
|
418 |
-
$
|
419 |
-
}
|
420 |
-
|
421 |
-
|
422 |
-
|
|
|
423 |
$form_data = array(
|
424 |
-
'wc_ast_show_shipment_status_filter' => array(
|
425 |
-
'type' => 'tgl_checkbox',
|
426 |
-
'tgl_color' => 'green',
|
427 |
-
'title' => __( 'Display shipment status filter on orders admin', 'woo-advanced-shipment-tracking' ),
|
428 |
-
'show' => $show_trackship_field,
|
429 |
-
'class' => '',
|
430 |
-
),
|
431 |
'wc_ast_use_tracking_page' => array(
|
432 |
'type' => 'tgl_checkbox',
|
433 |
'tgl_color' => 'green',
|
434 |
'title' => __( 'Enable a tracking page', 'woo-advanced-shipment-tracking' ),
|
435 |
-
'show'
|
436 |
-
'class' => '',
|
437 |
-
'customize_link' => ts_tracking_page_customizer::get_customizer_url('ast_tracking_page_section','trackship'),
|
438 |
),
|
439 |
'wc_ast_trackship_page_id' => array(
|
440 |
'type' => 'dropdown_tpage',
|
441 |
'title' => __( 'Select tracking page', 'woo-advanced-shipment-tracking' ),
|
442 |
'options' => $page_list,
|
443 |
-
'show'
|
444 |
-
'desc'
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
'class' => '',
|
446 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
447 |
);
|
448 |
return $form_data;
|
449 |
}
|
@@ -452,7 +501,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
452 |
* get settings tab array data
|
453 |
* return array
|
454 |
*/
|
455 |
-
function get_delivered_data(){
|
456 |
$form_data = array(
|
457 |
'wc_ast_status_delivered' => array(
|
458 |
'type' => 'checkbox',
|
@@ -479,22 +528,19 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
479 |
),
|
480 |
);
|
481 |
return $form_data;
|
482 |
-
|
483 |
}
|
|
|
484 |
/*
|
485 |
* Trackship Automation form save
|
486 |
*/
|
487 |
-
public function wc_ast_trackship_automation_form_update(){
|
488 |
-
update_option( 'wc_ast_status_change_to_delivered', wc_clean($_POST[ 'wc_ast_status_change_to_delivered' ]) );
|
489 |
-
|
490 |
$data = $this->get_delivered_data();
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
update_option( $key, wc_clean($_POST[ $key ]) );
|
495 |
}
|
496 |
}
|
497 |
-
}
|
498 |
|
499 |
/**
|
500 |
* Adds 'shipment_status' column header to 'Orders' page immediately after 'woocommerce-advanced-shipment-tracking' column.
|
@@ -502,7 +548,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
502 |
* @param string[] $columns
|
503 |
* @return string[] $new_columns
|
504 |
*/
|
505 |
-
function wc_add_order_shipment_status_column_header( $columns ) {
|
506 |
wp_enqueue_style( 'trackship_styles' );
|
507 |
$new_columns = array();
|
508 |
|
@@ -522,24 +568,26 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
522 |
*
|
523 |
* @param string[] $column name of column being displayed
|
524 |
*/
|
525 |
-
function wc_add_order_shipment_status_column_content( $column ) {
|
|
|
526 |
global $post;
|
|
|
527 |
if ( 'shipment_status_old' === $column ) {
|
528 |
|
529 |
-
$shipment_status = get_post_meta( $post->ID,
|
530 |
|
531 |
-
if( is_array($shipment_status) ){
|
532 |
-
foreach( $shipment_status as $data ){
|
533 |
$status = $data["status"];
|
534 |
$est_delivery_date = $data["est_delivery_date"];
|
535 |
-
echo "<div class='ast-shipment-status shipment-".sanitize_title($status)."' >".apply_filters(
|
536 |
|
537 |
$date = $data["status_date"];
|
538 |
-
if( $date ){
|
539 |
-
$date = date( "Y-m-d", strtotime($date) );
|
540 |
echo "<span class=description>on {$date}</span>";
|
541 |
}
|
542 |
-
if( $est_delivery_date ){
|
543 |
echo "<div>EST Delivery: {$est_delivery_date}</div>";
|
544 |
}
|
545 |
}
|
@@ -550,48 +598,39 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
550 |
|
551 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
552 |
$tracking_items = $ast->get_tracking_items( $post->ID );
|
553 |
-
$shipment_status = get_post_meta( $post->ID,
|
554 |
$wp_date_format = get_option( 'date_format' );
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
$date_format = 'm/d';
|
559 |
-
}
|
560 |
-
if ( count( $tracking_items ) > 0 ) {
|
561 |
?>
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
if(
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
<span class="wcast-shipment-est-delivery ft11">Est. Delivery(<?php echo date( $date_format, strtotime($est_delivery_date)); ?>)</span>
|
590 |
-
<?php } ?>
|
591 |
-
</div>
|
592 |
-
</li>
|
593 |
-
<?php } ?>
|
594 |
-
</ul>
|
595 |
<?php
|
596 |
} else {
|
597 |
echo '–';
|
@@ -603,7 +642,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
603 |
* add bulk action
|
604 |
* Change order status to delivered
|
605 |
*/
|
606 |
-
function add_bulk_actions_get_shipment_status($bulk_actions){
|
607 |
$bulk_actions['get_shipment_status'] = 'Get Shipment Status';
|
608 |
return $bulk_actions;
|
609 |
}
|
@@ -611,24 +650,19 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
611 |
/*
|
612 |
* order bulk action for get shipment status
|
613 |
*/
|
614 |
-
function get_shipment_status_handle_bulk_action_edit_shop_order( $redirect_to, $action, $post_ids ){
|
615 |
|
616 |
-
if (
|
617 |
return $redirect_to;
|
|
|
618 |
|
619 |
$processed_ids = array();
|
620 |
|
621 |
$order_count = count($post_ids);
|
622 |
|
623 |
-
if($order_count > 100){
|
624 |
-
//return $redirect_to;
|
625 |
-
}
|
626 |
-
|
627 |
foreach ( $post_ids as $post_id ) {
|
628 |
-
|
629 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $post_id ) );
|
630 |
-
$processed_ids[] = $post_id;
|
631 |
-
|
632 |
}
|
633 |
|
634 |
return $redirect_to = add_query_arg( array(
|
@@ -641,98 +675,54 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
641 |
/*
|
642 |
* bulk shipment status action for completed order with tracking details and without shipment status
|
643 |
*/
|
644 |
-
public static function bulk_shipment_status_from_settings_fun(){
|
|
|
645 |
$args = array(
|
646 |
'status' => 'wc-completed',
|
647 |
'limit' => 100,
|
648 |
'date_created' => '>' . ( time() - 2592000 ),
|
649 |
);
|
|
|
650 |
$orders = wc_get_orders( $args );
|
651 |
-
|
|
|
|
|
652 |
$order_id = $order->get_id();
|
653 |
|
654 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
655 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
656 |
-
|
657 |
-
|
|
|
658 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
659 |
-
|
|
|
660 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $order_id ) );
|
661 |
}
|
662 |
-
|
663 |
-
|
664 |
-
}
|
665 |
-
$url = admin_url('/edit.php?post_type=shop_order');
|
666 |
-
echo $url;die();
|
667 |
-
}
|
668 |
-
|
669 |
-
/*
|
670 |
-
* bulk shipment status action for "TrackShip balance is 0" status
|
671 |
-
*/
|
672 |
-
public static function bulk_shipment_status_for_empty_balance_from_settings_fun(){
|
673 |
-
$args = array(
|
674 |
-
'status' => 'wc-completed',
|
675 |
-
'limit' => 100,
|
676 |
-
'date_created' => '>' . ( time() - 2592000 ),
|
677 |
-
);
|
678 |
-
$orders = wc_get_orders( $args );
|
679 |
-
|
680 |
-
foreach($orders as $order){
|
681 |
-
$order_id = $order->get_id();
|
682 |
-
|
683 |
-
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
684 |
-
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
685 |
-
if($tracking_items){
|
686 |
-
|
687 |
-
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
688 |
-
|
689 |
-
foreach ( $tracking_items as $key => $tracking_item ) {
|
690 |
-
if($shipment_status[$key]['pending_status'] == 'TrackShip balance is 0'){
|
691 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $order_id ) );
|
692 |
}
|
693 |
-
|
694 |
-
|
695 |
-
}
|
696 |
-
|
697 |
-
$url = admin_url('/edit.php?post_type=shop_order');
|
698 |
-
echo $url;die();
|
699 |
-
}
|
700 |
-
|
701 |
-
/*
|
702 |
-
* bulk shipment status action for "TrackShip balance is 0" status
|
703 |
-
*/
|
704 |
-
public static function bulk_shipment_status_for_do_connection_from_settings_fun(){
|
705 |
-
$args = array(
|
706 |
-
'status' => 'wc-completed',
|
707 |
-
'limit' => 100,
|
708 |
-
'date_created' => '>' . ( time() - 2592000 ),
|
709 |
-
);
|
710 |
-
$orders = wc_get_orders( $args );
|
711 |
-
|
712 |
-
foreach($orders as $order){
|
713 |
-
$order_id = $order->get_id();
|
714 |
-
|
715 |
-
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
716 |
-
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
717 |
-
if($tracking_items){
|
718 |
-
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
719 |
-
foreach ( $tracking_items as $key => $tracking_item ) {
|
720 |
-
if( $shipment_status[$key]['pending_status'] == 'TrackShip connection issue' ){
|
721 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $order_id ) );
|
722 |
}
|
723 |
}
|
724 |
}
|
725 |
}
|
726 |
-
|
727 |
-
$url
|
728 |
-
|
729 |
-
}
|
730 |
|
731 |
/*
|
732 |
* The results notice from bulk action on orders
|
733 |
*/
|
734 |
-
function shipment_status_bulk_action_admin_notice() {
|
735 |
-
|
|
|
|
|
|
|
736 |
|
737 |
$count = intval( $_REQUEST['processed_count'] );
|
738 |
|
@@ -752,7 +742,6 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
752 |
* @return array
|
753 |
*/
|
754 |
public function add_order_meta_box_get_shipment_status_actions( $actions ) {
|
755 |
-
|
756 |
// add download to CSV action
|
757 |
$actions['get_shipment_status_edit_order'] = __( 'Get Shipment Status', 'woo-advanced-shipment-tracking' );
|
758 |
return $actions;
|
@@ -761,7 +750,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
761 |
/*
|
762 |
* order details meta box action
|
763 |
*/
|
764 |
-
public function process_order_meta_box_actions_get_shipment_status( $order ){
|
765 |
$this->trigger_woocommerce_order_status_completed( $order->get_id() );
|
766 |
}
|
767 |
|
@@ -770,7 +759,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
770 |
*
|
771 |
* @since 2.4
|
772 |
*/
|
773 |
-
public function filter_orders_by_shipment_status(){
|
774 |
global $typenow;
|
775 |
|
776 |
if ( 'shop_order' === $typenow ) {
|
@@ -810,16 +799,15 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
810 |
* @param array $vars query vars without filtering
|
811 |
* @return array $vars query vars with (maybe) filtering
|
812 |
*/
|
813 |
-
public function filter_orders_by_shipment_status_query( $vars ){
|
814 |
global $typenow;
|
815 |
-
if ( 'shop_order' === $typenow && isset( $_GET['_shop_order_shipment_status'] ) && $_GET['_shop_order_shipment_status'] != '') {
|
816 |
$vars['meta_query'][] = array(
|
817 |
'key' => 'ts_shipment_status',
|
818 |
'value' => $_GET['_shop_order_shipment_status'],
|
819 |
'compare' => 'LIKE'
|
820 |
);
|
821 |
}
|
822 |
-
|
823 |
return $vars;
|
824 |
}
|
825 |
|
@@ -827,14 +815,12 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
827 |
* trigger when order status changed to shipped or completed or update tracking
|
828 |
* param $order_id
|
829 |
*/
|
830 |
-
function trigger_woocommerce_order_status_completed( $order_id ){
|
831 |
-
|
832 |
-
//error_log( "Order complete for order $order_id", 0 );
|
833 |
$order = wc_get_order( $order_id );
|
834 |
$order_shipped = apply_filters( 'is_order_shipped', true, $order );
|
835 |
-
|
836 |
-
|
837 |
-
if( $order_shipped ){
|
838 |
$api = new WC_Advanced_Shipment_Tracking_Api_Call;
|
839 |
$array = $api->get_trackship_apicall( $order_id );
|
840 |
}
|
@@ -843,8 +829,8 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
843 |
/*
|
844 |
* filter for shipment status
|
845 |
*/
|
846 |
-
function trackship_status_filter_func( $status ){
|
847 |
-
switch ($status) {
|
848 |
case "in_transit":
|
849 |
$status = __( 'In Transit', 'woo-advanced-shipment-tracking' );
|
850 |
break;
|
@@ -892,8 +878,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
892 |
break;
|
893 |
case "deleted":
|
894 |
$status = __( 'Deleted', 'woocommerce' );
|
895 |
-
break;
|
896 |
-
|
897 |
}
|
898 |
return $status;
|
899 |
}
|
@@ -901,8 +886,8 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
901 |
/*
|
902 |
* filter for shipment status icon
|
903 |
*/
|
904 |
-
function trackship_status_icon_filter_func( $html, $status ){
|
905 |
-
switch ($status) {
|
906 |
case "in_transit":
|
907 |
$html = '<span class="shipment-icon icon-'.$status.'">';
|
908 |
break;
|
@@ -951,7 +936,6 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
951 |
default:
|
952 |
$html = '<span class="shipment-icon icon-default">';
|
953 |
break;
|
954 |
-
|
955 |
}
|
956 |
return $html;
|
957 |
}
|
@@ -959,25 +943,28 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
959 |
/*
|
960 |
* retry trackship api call
|
961 |
*/
|
962 |
-
function wcast_retry_trackship_apicall_func( $order_id ){
|
963 |
$logger = wc_get_logger();
|
964 |
$context = array( 'source' => 'retry_trackship_apicall' );
|
965 |
-
$logger->info( "Retry trackship api call for Order id : "
|
966 |
$this->trigger_woocommerce_order_status_completed( $order_id );
|
967 |
}
|
968 |
|
969 |
/*
|
970 |
* update all shipment status email status
|
971 |
*/
|
972 |
-
public function update_shipment_status_email_status_fun(){
|
973 |
-
$status_settings = get_option($_POST['settings_data']);
|
974 |
-
$status_settings[$_POST['id']] = wc_clean($_POST['wcast_enable_status_email']);
|
975 |
update_option( $_POST['settings_data'], $status_settings );
|
976 |
exit;
|
977 |
}
|
978 |
|
979 |
-
|
980 |
-
|
|
|
|
|
|
|
981 |
update_option( $_POST['settings_data'], $status_settings );
|
982 |
exit;
|
983 |
}
|
@@ -986,33 +973,19 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
986 |
* get trackship bulk actions tab array data
|
987 |
* return array
|
988 |
*/
|
989 |
-
function get_trackship_bulk_actions_data(){
|
990 |
|
991 |
$completed_order_with_tracking = $this->completed_order_with_tracking();
|
992 |
$completed_order_with_zero_balance = $this->completed_order_with_zero_balance();
|
993 |
$completed_order_with_do_connection = $this->completed_order_with_do_connection();
|
994 |
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
$disable_bulk_sync = true;
|
999 |
-
}
|
1000 |
-
|
1001 |
-
if($completed_order_with_zero_balance > 0){
|
1002 |
-
$disable_bulk_sync_zero_balance = false;
|
1003 |
-
} else{
|
1004 |
-
$disable_bulk_sync_zero_balance = true;
|
1005 |
-
}
|
1006 |
-
|
1007 |
-
if($completed_order_with_do_connection > 0){
|
1008 |
-
$disable_bulk_sync_do_connection = false;
|
1009 |
-
} else{
|
1010 |
-
$disable_bulk_sync_do_connection = true;
|
1011 |
-
}
|
1012 |
|
1013 |
$wc_ast_status_shipped = get_option('wc_ast_status_shipped');
|
1014 |
|
1015 |
-
if($wc_ast_status_shipped
|
1016 |
$completed_order_label = '<span class="shipped_label">shipped</span>';
|
1017 |
} else{
|
1018 |
$completed_order_label = '<span class="shipped_label">completed</span>';
|
@@ -1020,31 +993,31 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1020 |
|
1021 |
$form_data = array(
|
1022 |
'wc_ast_bulk_shipment_status' => array(
|
1023 |
-
'type'
|
1024 |
-
'title'
|
1025 |
-
'label'
|
1026 |
-
'show'
|
1027 |
-
'disable'
|
1028 |
-
'button_class'
|
1029 |
-
'class'
|
1030 |
),
|
1031 |
'wc_ast_bulk_shipment_status_for_zero_tracker_balace' => array(
|
1032 |
-
'type'
|
1033 |
-
'title'
|
1034 |
-
'label'
|
1035 |
-
'show'
|
1036 |
-
'disable'
|
1037 |
-
'button_class'
|
1038 |
-
'class'
|
1039 |
),
|
1040 |
'wc_ast_bulk_shipment_status_for_trackship_connection_issue' => array(
|
1041 |
-
'type'
|
1042 |
-
'title'
|
1043 |
-
'label'
|
1044 |
'show' => true,
|
1045 |
-
'disable'
|
1046 |
-
'button_class'
|
1047 |
-
'class'
|
1048 |
),
|
1049 |
);
|
1050 |
return $form_data;
|
@@ -1054,7 +1027,8 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1054 |
* get completed order with tracking that not sent to TrackShip
|
1055 |
* return number
|
1056 |
*/
|
1057 |
-
function completed_order_with_tracking(){
|
|
|
1058 |
// Get orders completed.
|
1059 |
$args = array(
|
1060 |
'status' => 'wc-completed',
|
@@ -1066,15 +1040,16 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1066 |
|
1067 |
$completed_order_with_tracking = 0;
|
1068 |
|
1069 |
-
foreach($orders as $order){
|
1070 |
$order_id = $order->get_id();
|
1071 |
|
1072 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1073 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1074 |
-
|
1075 |
-
|
|
|
1076 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
1077 |
-
if( !isset($shipment_status[$key]) ){
|
1078 |
$completed_order_with_tracking++;
|
1079 |
}
|
1080 |
}
|
@@ -1087,7 +1062,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1087 |
* get completed order with Trackship Balance 0 status
|
1088 |
* return number
|
1089 |
*/
|
1090 |
-
function completed_order_with_zero_balance(){
|
1091 |
|
1092 |
// Get orders completed.
|
1093 |
$args = array(
|
@@ -1100,17 +1075,17 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1100 |
|
1101 |
$completed_order_with_zero_balance = 0;
|
1102 |
|
1103 |
-
foreach($orders as $order){
|
1104 |
$order_id = $order->get_id();
|
1105 |
|
1106 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1107 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1108 |
|
1109 |
-
if($tracking_items){
|
1110 |
-
$shipment_status = get_post_meta( $order_id,
|
1111 |
-
foreach ( $tracking_items as $key => $tracking_item ) {
|
1112 |
-
if(isset($shipment_status[$key]['pending_status']) && $shipment_status[$key]['pending_status']
|
1113 |
-
$completed_order_with_zero_balance++;
|
1114 |
}
|
1115 |
}
|
1116 |
}
|
@@ -1122,7 +1097,7 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1122 |
* get completed order with Trackship connection issue status
|
1123 |
* return number
|
1124 |
*/
|
1125 |
-
function completed_order_with_do_connection(){
|
1126 |
|
1127 |
// Get orders completed.
|
1128 |
$args = array(
|
@@ -1135,15 +1110,16 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1135 |
|
1136 |
$completed_order_with_do_connection = 0;
|
1137 |
|
1138 |
-
foreach($orders as $order){
|
1139 |
$order_id = $order->get_id();
|
1140 |
|
1141 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1142 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1143 |
-
|
1144 |
-
|
|
|
1145 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
1146 |
-
if(isset($shipment_status[$key]['pending_status']) && $shipment_status[$key]['pending_status']
|
1147 |
$completed_order_with_do_connection++;
|
1148 |
}
|
1149 |
}
|
@@ -1155,12 +1131,10 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1155 |
/**
|
1156 |
* Shipment tracking info html in orders details page
|
1157 |
*/
|
1158 |
-
public function display_shipment_tracking_info( $order_id, $item ){
|
1159 |
-
|
1160 |
-
$
|
1161 |
-
|
1162 |
-
//echo '<pre>';print_r($shipment_status);echo '</pre>';
|
1163 |
-
//echo '<pre>';print_r($ts_shipment_status);echo '</pre>';
|
1164 |
|
1165 |
$tracking_id = $item['tracking_id'];
|
1166 |
|
@@ -1168,41 +1142,33 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1168 |
$tracking_items = $ast->get_tracking_items( $order_id );
|
1169 |
|
1170 |
$wp_date_format = get_option( 'date_format' );
|
1171 |
-
|
1172 |
-
if($wp_date_format == 'd/m/Y'){
|
1173 |
-
$date_format = 'd/m';
|
1174 |
-
} else{
|
1175 |
-
$date_format = 'm/d';
|
1176 |
-
}
|
1177 |
|
1178 |
if ( count( $tracking_items ) > 0 ) {
|
1179 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
1180 |
-
if( $tracking_id == $tracking_item['tracking_id'] ){
|
1181 |
-
if( isset( $shipment_status[$key] )){
|
1182 |
-
$has_est_delivery = false;
|
1183 |
-
$data = $shipment_status[$key];
|
1184 |
-
|
1185 |
-
if(isset($data['pending_status'])){
|
1186 |
-
$status = $data['pending_status'];
|
1187 |
-
} else{
|
1188 |
-
$status = $data['status'];
|
1189 |
-
}
|
1190 |
-
|
1191 |
-
$status_date = $data['status_date'];
|
1192 |
|
1193 |
-
|
|
|
|
|
1194 |
|
1195 |
-
if( $status != 'delivered' && $status != 'return_to_sender' && !empty($est_delivery_date) )
|
|
|
|
|
1196 |
?>
|
1197 |
<div class="ast-shipment-status-div">
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
|
|
|
|
1206 |
</div>
|
1207 |
<?php
|
1208 |
}
|
@@ -1214,10 +1180,10 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1214 |
/**
|
1215 |
* Delete tracking information from TrackShip when tracking deleted from AST
|
1216 |
*/
|
1217 |
-
public function delete_tracking_number_from_trackship( $tracking_items, $tracking_id, $order_id ){
|
1218 |
|
1219 |
-
foreach($tracking_items as $tracking_item){
|
1220 |
-
if($tracking_item['tracking_id'] == $_POST['tracking_id']){
|
1221 |
$tracking_number = $tracking_item['tracking_number'];
|
1222 |
$tracking_provider = $tracking_item['tracking_provider'];
|
1223 |
$api = new WC_Advanced_Shipment_Tracking_Api_Call;
|
@@ -1230,67 +1196,64 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1230 |
* fix shipment tracking for deleted tracking
|
1231 |
*/
|
1232 |
public function func_fix_shipment_tracking_for_deleted_tracking( $order_id, $key, $item ){
|
1233 |
-
$shipment_status = get_post_meta( $order_id,
|
1234 |
-
if( isset( $shipment_status[$key] ) ){
|
1235 |
unset($shipment_status[$key]);
|
1236 |
-
update_post_meta( $order_id,
|
1237 |
}
|
1238 |
|
1239 |
-
$ts_shipment_status = get_post_meta( $order_id,
|
1240 |
-
if( isset( $ts_shipment_status[$key] ) ){
|
1241 |
-
unset($ts_shipment_status[$key]);
|
1242 |
-
update_post_meta( $order_id,
|
1243 |
}
|
1244 |
}
|
1245 |
|
1246 |
/**
|
1247 |
* code for check if tracking number in order is delivered or not
|
1248 |
*/
|
1249 |
-
public function check_tracking_delivered( $order_id ){
|
|
|
1250 |
$delivered = true;
|
1251 |
-
$shipment_status = get_post_meta( $order_id,
|
1252 |
-
$wc_ast_status_delivered = get_option('wc_ast_status_delivered');
|
1253 |
|
1254 |
-
foreach( (array)$shipment_status as $shipment ){
|
1255 |
$status = $shipment['status'];
|
1256 |
-
if(
|
1257 |
$delivered = false;
|
1258 |
}
|
1259 |
}
|
1260 |
-
|
|
|
1261 |
|
1262 |
-
|
1263 |
-
$
|
1264 |
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
$change_to_delivered = apply_filters( 'ts_change_order_to_delivered', false, $order_status );
|
1270 |
-
|
1271 |
-
if( $order_status == 'completed' || $order_status == 'updated-tracking' || $order_status == 'shipped' ){
|
1272 |
-
$change_to_delivered = true;
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
if( $change_to_delivered ){
|
1276 |
-
$order->update_status('delivered');
|
1277 |
-
}
|
1278 |
}
|
|
|
|
|
|
|
|
|
1279 |
}
|
1280 |
}
|
1281 |
|
1282 |
/**
|
1283 |
* code for trigger shipment status email
|
1284 |
*/
|
1285 |
-
public function trigger_tracking_email( $order_id, $old_status, $new_status, $tracking_item, $shipment_status ){
|
1286 |
$order = wc_get_order( $order_id );
|
1287 |
require_once( 'email-manager.php' );
|
1288 |
|
1289 |
-
if( $old_status != $new_status){
|
1290 |
-
if($new_status == 'delivered'){
|
1291 |
-
wc_trackship_email_manager()->delivered_shippment_status_email_trigger($order_id, $order, $old_status, $new_status, $tracking_item);
|
1292 |
-
} elseif($new_status == 'failure' || $new_status == 'in_transit' || $new_status == 'on_hold' || $new_status == 'out_for_delivery' || $new_status == 'available_for_pickup' || $new_status == 'return_to_sender'){
|
1293 |
-
wc_trackship_email_manager()->shippment_status_email_trigger($order_id, $order, $old_status, $new_status, $tracking_item);
|
1294 |
}
|
1295 |
do_action( 'ast_trigger_ts_status_change',$order_id, $old_status, $new_status, $tracking_item, $shipment_status );
|
1296 |
}
|
@@ -1301,39 +1264,40 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1301 |
*/
|
1302 |
public function ast_add_dashboard_widgets() {
|
1303 |
wp_enqueue_style( 'trackship_styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/trackship.css', array(), wc_advanced_shipment_tracking()->version );
|
1304 |
-
wp_add_dashboard_widget( 'trackship_dashboard_widget', 'TrackShip Analytics <small>(last 30 days)</small>', array( $this, 'dashboard_widget_function') );
|
1305 |
}
|
1306 |
|
1307 |
/**
|
1308 |
* Output the contents of the dashboard widget
|
1309 |
*/
|
1310 |
public function dashboard_widget_function( $post, $callback_args ) {
|
1311 |
-
$tracking_analytics = $this->get_tracking_analytics_overview();
|
|
|
1312 |
<div class="ts-widget-content ">
|
1313 |
<div class="ts-widget-row">
|
1314 |
<div class="ts-widget__section ts-widget-rborder ts-widget-bborder">
|
1315 |
-
<h3><?php
|
1316 |
-
<span class="ts-widget-analytics-number"><?php
|
1317 |
-
<span>(<?php
|
1318 |
</div>
|
1319 |
<div class="ts-widget__section ts-widget-bborder">
|
1320 |
-
<h3><?php
|
1321 |
-
<span class="ts-widget-analytics-number"><?php
|
1322 |
-
<span><?php
|
1323 |
</div>
|
1324 |
</div>
|
1325 |
<div class="ts-widget-row">
|
1326 |
<div class="ts-widget__section ts-widget-rborder ts-widget-bborder">
|
1327 |
-
<h3><?php
|
1328 |
-
<span class="ts-widget-analytics-number"><?php
|
1329 |
</div>
|
1330 |
<div class="ts-widget__section ts-widget-bborder">
|
1331 |
-
<h3><?php
|
1332 |
-
<span class="ts-widget-analytics-number"><?php
|
1333 |
</div>
|
1334 |
</div>
|
1335 |
<div class="ts-widget-footer">
|
1336 |
-
<a class="" href="https://trackship.info/my-account/analytics/" target="blank"><?php
|
1337 |
<a class="ts_link" href="https://trackship.info" title="TrackShip" target="blank"><img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-logo.png"></a>
|
1338 |
</div>
|
1339 |
</div>
|
@@ -1343,15 +1307,15 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1343 |
/*
|
1344 |
* TrackShip Analytics Overview
|
1345 |
*/
|
1346 |
-
public function get_tracking_analytics_overview(){
|
1347 |
global $wpdb;
|
1348 |
-
$paid_order_statuses = array('completed','delivered','shipped');
|
1349 |
|
1350 |
-
$end_date = date('Y-m-d', strtotime('today - 30 days'));
|
1351 |
$start_date = date('Y-m-d');
|
1352 |
|
1353 |
global $wpdb;
|
1354 |
-
$paid_order_statuses =
|
1355 |
|
1356 |
$order_query = "
|
1357 |
SELECT
|
@@ -1374,18 +1338,19 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1374 |
|
1375 |
ORDER BY
|
1376 |
posts.ID DESC
|
1377 |
-
";
|
1378 |
-
|
|
|
1379 |
$shipment_status = array();
|
1380 |
$shipment_status_merge = array();
|
1381 |
$tracking_item_merge = array();
|
1382 |
|
1383 |
-
foreach($shipment_status_results as $order){
|
1384 |
$order_id = $order->ID;
|
1385 |
-
$shipment_status = unserialize($order->shipment_status);
|
1386 |
|
1387 |
-
if(is_array($shipment_status)){
|
1388 |
-
$shipment_status_merge = array_merge($shipment_status_merge, $shipment_status);
|
1389 |
}
|
1390 |
}
|
1391 |
|
@@ -1396,23 +1361,24 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1396 |
$avg_shipment_days_array = array();
|
1397 |
$avg_shipment_length = '';
|
1398 |
|
1399 |
-
foreach($shipment_status_merge as $key => $val){
|
1400 |
|
1401 |
$first = ( isset($val['tracking_events']) ) ? reset($val['tracking_events']) : '';
|
1402 |
$first_date = ( isset($first->datetime) ) ? $first->datetime : '';
|
1403 |
|
1404 |
-
if( isset( $val['tracking_destination_events'] ) && count( $val['tracking_destination_events'] ) > 0 ){
|
1405 |
$last = end($val['tracking_destination_events']);
|
1406 |
-
} elseif( isset( $val['tracking_events'] ) ){
|
1407 |
$last = end($val['tracking_events']);
|
1408 |
-
} else{
|
1409 |
$last = '';
|
1410 |
-
}
|
|
|
1411 |
$last_date = ( isset($last->datetime) ) ? $last->datetime : '';
|
1412 |
|
1413 |
$status = isset( $val['status'] ) ? $val['status'] : '';
|
1414 |
|
1415 |
-
if(
|
1416 |
$last_date = date("Y-m-d H:i:s");
|
1417 |
}
|
1418 |
|
@@ -1423,9 +1389,17 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1423 |
|
1424 |
$avg_shipment_length = $this->get_average( $avg_shipment_days_array );
|
1425 |
|
1426 |
-
if(
|
1427 |
-
|
1428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1429 |
}
|
1430 |
|
1431 |
$result = array();
|
@@ -1442,29 +1416,30 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1442 |
/*
|
1443 |
*
|
1444 |
*/
|
1445 |
-
function get_num_of_days( $first_date, $last_date ){
|
1446 |
$date1 = strtotime($first_date);
|
1447 |
$date2 = strtotime($last_date);
|
1448 |
$diff = abs($date2 - $date1);
|
1449 |
return date( "d", $diff );
|
1450 |
}
|
1451 |
|
1452 |
-
function get_average( $array ){
|
1453 |
-
return round(array_sum($array) / count($array), 2);
|
1454 |
}
|
1455 |
|
1456 |
/**
|
1457 |
* Create tracking page after store is connected
|
1458 |
*/
|
1459 |
-
public function create_tracking_page(){
|
1460 |
-
|
|
|
1461 |
$new_page_title = 'Shipment Tracking';
|
1462 |
$new_page_slug = 'ts-shipment-tracking';
|
1463 |
$new_page_content = '[wcast-track-order]';
|
1464 |
//don't change the code below, unless you know what you're doing
|
1465 |
-
$page_check = get_page_by_title($new_page_title);
|
1466 |
|
1467 |
-
if(!isset($page_check->ID)){
|
1468 |
$new_page = array(
|
1469 |
'post_type' => 'page',
|
1470 |
'post_title' => $new_page_title,
|
@@ -1473,10 +1448,10 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1473 |
'post_status' => 'publish',
|
1474 |
'post_author' => 1,
|
1475 |
);
|
1476 |
-
$new_page_id = wp_insert_post($new_page);
|
1477 |
update_option( 'wc_ast_trackship_page_id', $new_page_id );
|
1478 |
}
|
1479 |
-
update_option( 'wc_advanced_shipment_tracking_ts_page', '1.0');
|
1480 |
}
|
1481 |
}
|
1482 |
|
@@ -1485,26 +1460,28 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1485 |
* if number not found. return false
|
1486 |
* if number found. return true
|
1487 |
*/
|
1488 |
-
function check_tracking_exist( $value, $order ){
|
1489 |
|
1490 |
-
if($value
|
1491 |
|
1492 |
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
1493 |
-
|
|
|
1494 |
return true;
|
1495 |
} else {
|
1496 |
return false;
|
1497 |
}
|
1498 |
}
|
|
|
1499 |
return $value;
|
1500 |
}
|
1501 |
|
1502 |
/*
|
1503 |
* If order status is "Updated Tracking" or "Completed" than retrn true else return false
|
1504 |
*/
|
1505 |
-
function check_order_status($value, $order){
|
1506 |
-
$order_status = $order->get_status();
|
1507 |
|
|
|
1508 |
$all_order_status = wc_get_order_statuses();
|
1509 |
|
1510 |
$default_order_status = array(
|
@@ -1518,19 +1495,19 @@ class WC_Advanced_Shipment_Tracking_Trackship {
|
|
1518 |
'wc-failed' => 'Failed'
|
1519 |
);
|
1520 |
|
1521 |
-
foreach($default_order_status as $key
|
1522 |
-
unset($all_order_status[$key]);
|
1523 |
}
|
1524 |
|
1525 |
$custom_order_status = $all_order_status;
|
1526 |
|
1527 |
-
foreach($custom_order_status as $key
|
1528 |
-
unset($custom_order_status[$key]);
|
1529 |
-
$key = str_replace("wc-", "", $key);
|
1530 |
$custom_order_status[] = $key;
|
1531 |
}
|
1532 |
|
1533 |
-
if(
|
1534 |
return true;
|
1535 |
} else {
|
1536 |
return false;
|
11 |
public function __construct() {
|
12 |
|
13 |
global $wpdb;
|
14 |
+
$this->table = $wpdb->prefix . "woo_shippment_provider";
|
15 |
+
|
16 |
+
if ( is_multisite() ) {
|
17 |
+
|
18 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
19 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
20 |
}
|
21 |
+
|
22 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
23 |
+
$main_blog_prefix = $wpdb->get_blog_prefix( BLOG_ID_CURRENT_SITE );
|
24 |
+
$this->table = $main_blog_prefix . 'woo_shippment_provider';
|
25 |
+
} else {
|
26 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
27 |
+
}
|
28 |
+
} else {
|
29 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
30 |
}
|
31 |
|
32 |
}
|
47 |
public static function get_instance() {
|
48 |
|
49 |
if ( null === self::$instance ) {
|
50 |
+
self::$instance = new self();
|
51 |
}
|
52 |
|
53 |
return self::$instance;
|
58 |
*
|
59 |
* @since 1.0
|
60 |
*/
|
61 |
+
public function init() {
|
62 |
+
|
63 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'trackship_styles' ), 4 );
|
64 |
+
add_action('admin_menu', array( $this, 'register_woocommerce_trackship_menu' ), 99 );
|
65 |
|
66 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
67 |
+
if ( $wc_ast_api_key ) {
|
|
|
68 |
|
69 |
+
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
|
|
|
|
|
|
|
|
|
70 |
|
71 |
//ajax save admin trackship settings
|
72 |
add_action( 'wp_ajax_wc_ast_trackship_form_update', array( $this, 'wc_ast_trackship_form_update_callback' ) );
|
74 |
add_action( 'wp_ajax_ts_late_shipments_email_form_update', array( $this, 'ts_late_shipments_email_form_update_callback' ) );
|
75 |
|
76 |
//add Shipment status column after tracking
|
77 |
+
add_filter( 'manage_edit-shop_order_columns', array( $this, 'wc_add_order_shipment_status_column_header' ), 20 );
|
78 |
+
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'wc_add_order_shipment_status_column_content' ) );
|
79 |
|
80 |
//add bulk action - get shipment status
|
81 |
+
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions_get_shipment_status' ), 10, 1 );
|
82 |
|
83 |
// Make the action from selected orders to get shipment status
|
84 |
+
add_filter( 'handle_bulk_actions-edit-shop_order', array( $this, 'get_shipment_status_handle_bulk_action_edit_shop_order' ), 10, 3 );
|
85 |
|
86 |
// Bulk shipment status sync ajax call from settings
|
87 |
add_action( 'wp_ajax_bulk_shipment_status_from_settings', array( $this, 'bulk_shipment_status_from_settings_fun' ) );
|
101 |
|
102 |
// add bulk order filter for exported / non-exported orders
|
103 |
$wc_ast_show_shipment_status_filter = get_option( 'wc_ast_show_shipment_status_filter', 0 );
|
104 |
+
if ( 1 == $wc_ast_show_shipment_status_filter ) {
|
105 |
+
add_action( 'restrict_manage_posts', array( $this, 'filter_orders_by_shipment_status' ) , 20 );
|
106 |
add_filter( 'request', array( $this, 'filter_orders_by_shipment_status_query' ) );
|
107 |
}
|
108 |
|
109 |
// trigger when order status changed to shipped or completed
|
110 |
+
add_action( 'woocommerce_order_status_completed', array( $this, 'trigger_woocommerce_order_status_completed' ), 10, 1 );
|
111 |
|
112 |
+
add_action( 'send_order_to_trackship', array( $this, 'trigger_woocommerce_order_status_completed' ), 10, 1 );
|
113 |
|
114 |
+
add_action( 'woocommerce_order_status_updated-tracking', array( $this, 'trigger_woocommerce_order_status_completed' ), 10, 1 );
|
115 |
|
116 |
// filter for shipment status
|
117 |
+
add_filter( 'trackship_status_filter', array( $this, 'trackship_status_filter_func' ), 10 , 1 );
|
118 |
|
119 |
// filter for shipment status icon
|
120 |
+
add_filter( 'trackship_status_icon_filter', array( $this, 'trackship_status_icon_filter_func' ), 10 , 2 );
|
121 |
|
122 |
add_action( 'wcast_retry_trackship_apicall', array( $this, 'wcast_retry_trackship_apicall_func' ) );
|
123 |
|
124 |
+
add_action( 'wp_ajax_update_shipment_status_email_status', array( $this, 'update_shipment_status_email_status_fun' ) );
|
125 |
|
126 |
+
add_action( 'wp_ajax_update_enable_late_shipments_email', array( $this, 'update_enable_late_shipments_email_fun' ) );
|
127 |
|
128 |
+
add_action( 'ast_shipment_tracking_end', array( $this, 'display_shipment_tracking_info' ), 10, 2 );
|
129 |
|
130 |
+
add_action( 'delete_tracking_number_from_trackship', array( $this, 'delete_tracking_number_from_trackship' ), 10, 3 );
|
131 |
|
132 |
//fix shipment tracking for deleted tracking
|
133 |
+
add_action( 'fix_shipment_tracking_for_deleted_tracking', array( $this, 'func_fix_shipment_tracking_for_deleted_tracking' ), 10, 3 );
|
134 |
|
135 |
+
add_action( 'wp_dashboard_setup', array( $this, 'ast_add_dashboard_widgets' ) );
|
136 |
|
137 |
//filter in shipped orders
|
138 |
+
add_filter( 'is_order_shipped', array( $this, 'check_tracking_exist' ), 10, 2 );
|
139 |
+
add_filter( 'is_order_shipped', array( $this, 'check_order_status' ), 5, 2 );
|
140 |
|
141 |
+
add_action( 'wp_ajax_wc_ast_trackship_automation_form_update', array( $this, 'wc_ast_trackship_automation_form_update' ) );
|
142 |
}
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
* Load trackship styles.
|
147 |
*/
|
148 |
+
public function trackship_styles( $hook ) {
|
149 |
|
150 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
151 |
|
153 |
wp_register_script( 'trackship_script', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/trackship.js', array( 'jquery', 'wp-util' ), wc_advanced_shipment_tracking()->version, true );
|
154 |
wp_localize_script( 'trackship_script', 'trackship_script', array(
|
155 |
'i18n' => array(
|
156 |
+
'data_saved' => __( 'Data saved successfully.', 'woo-advanced-shipment-tracking' ),
|
157 |
),
|
158 |
) );
|
159 |
|
160 |
+
if ( !isset( $_GET['page'] ) ) {
|
161 |
return;
|
162 |
+
}
|
163 |
|
164 |
+
if ( 'woocommerce-advanced-shipment-tracking' != $_GET['page'] && 'trackship-for-woocommerce' != $_GET['page'] ) {
|
165 |
return;
|
166 |
+
}
|
167 |
|
168 |
wp_enqueue_style( 'trackship_styles' );
|
169 |
wp_enqueue_script( 'trackship_script' );
|
170 |
}
|
171 |
|
172 |
+
/**
|
173 |
+
* TrackShip Menu Array.
|
174 |
+
*/
|
175 |
+
public function ast_menu_trackship_options() {
|
176 |
$trackship_tab = array(
|
177 |
+
'ts_dashboard' => array(
|
178 |
+
'title' => __( 'Dashboard', 'woo-advanced-shipment-tracking' ),
|
179 |
+
'show' => true,
|
180 |
+
'class' => 'tab_label first_label',
|
181 |
+
'data-tab' => 'ts_dashboard',
|
182 |
+
'data-label' => __( 'Dashboard', 'woo-advanced-shipment-tracking' ),
|
183 |
+
'name' => 'tabs',
|
184 |
+
),
|
185 |
+
'ts_notifications' => array(
|
186 |
+
'title' => __( 'Notifications', 'woo-advanced-shipment-tracking' ),
|
187 |
'show' => true,
|
188 |
'class' => 'tab_label',
|
189 |
+
'data-tab' => 'ts_notifications',
|
190 |
+
'data-label' => __( 'Notifications', 'woo-advanced-shipment-tracking' ),
|
191 |
'name' => 'tabs',
|
192 |
+
),
|
193 |
);
|
194 |
+
return apply_filters( 'trackship_menu_tab_options', $trackship_tab );
|
195 |
+
}
|
|
|
|
|
196 |
|
197 |
+
/**
|
198 |
+
* TrackShip Shipment status notification data.
|
199 |
+
*/
|
200 |
+
public function trackship_shipment_status_notifications_data() {
|
201 |
+
|
202 |
+
$intransit_customizer = new wcast_intransit_customizer_email();
|
203 |
+
|
204 |
+
$notifications_data = array(
|
205 |
+
'in_transit' => array(
|
206 |
+
'title' => __( 'In Transit', 'woo-advanced-shipment-tracking' ),
|
207 |
+
'slug' => 'in-transit',
|
208 |
+
'option_name' => 'wcast_intransit_email_settings',
|
209 |
+
'enable_status_name' => 'wcast_enable_intransit_email',
|
210 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'in_transit', 'ts_dashboard' ),
|
211 |
+
),
|
212 |
+
'on_hold' => array(
|
213 |
+
'title' => __( 'On Hold', 'woo-advanced-shipment-tracking' ),
|
214 |
+
'slug' => 'on-hold',
|
215 |
+
'option_name' => 'wcast_onhold_email_settings',
|
216 |
+
'enable_status_name' => 'wcast_enable_onhold_email',
|
217 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'on_hold', 'ts_dashboard' ),
|
218 |
+
),
|
219 |
+
'return_to_sender' => array(
|
220 |
+
'title' => __( 'Return To Sender', 'woo-advanced-shipment-tracking' ),
|
221 |
+
'slug' => 'return-to-sender',
|
222 |
+
'option_name' => 'wcast_returntosender_email_settings',
|
223 |
+
'enable_status_name' => 'wcast_enable_returntosender_email',
|
224 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'return_to_sender', 'ts_dashboard' ),
|
225 |
+
),
|
226 |
+
'available_for_pickup' => array(
|
227 |
+
'title' => __( 'Available For Pickup', 'woo-advanced-shipment-tracking' ),
|
228 |
+
'slug' => 'available-for-pickup',
|
229 |
+
'option_name' => 'wcast_availableforpickup_email_settings',
|
230 |
+
'enable_status_name' => 'wcast_enable_availableforpickup_email',
|
231 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'available_for_pickup', 'ts_dashboard' ),
|
232 |
+
),
|
233 |
+
'out_for_delivery' => array(
|
234 |
+
'title' => __( 'Out For Delivery', 'woo-advanced-shipment-tracking' ),
|
235 |
+
'slug' => 'out-for-delivery',
|
236 |
+
'option_name' => 'wcast_outfordelivery_email_settings',
|
237 |
+
'enable_status_name' => 'wcast_enable_outfordelivery_email',
|
238 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'out_for_delivery', 'ts_dashboard' ),
|
239 |
+
),
|
240 |
+
'delivered' => array(
|
241 |
+
'title' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
|
242 |
+
'slug' => 'delivered-status',
|
243 |
+
'option_name' => 'wcast_delivered_email_settings',
|
244 |
+
'enable_status_name' => 'wcast_enable_delivered_status_email',
|
245 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'delivered', 'ts_dashboard' ),
|
246 |
+
),
|
247 |
+
'failure' => array(
|
248 |
+
'title' => __( 'Failed Attempt', 'woo-advanced-shipment-tracking' ),
|
249 |
+
'slug' => 'failed-attempt',
|
250 |
+
'option_name' => 'wcast_failure_email_settings',
|
251 |
+
'enable_status_name' => 'wcast_enable_failure_email',
|
252 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'failure', 'ts_dashboard' ),
|
253 |
+
),
|
254 |
+
'exception' => array(
|
255 |
+
'title' => __( 'Exception', 'woo-advanced-shipment-tracking' ),
|
256 |
+
'slug' => 'exception',
|
257 |
+
'option_name' => 'wcast_exception_email_settings',
|
258 |
+
'enable_status_name' => 'wcast_enable_exception_email',
|
259 |
+
'customizer_url' => $intransit_customizer->get_customizer_url( 'trackship_shipment_status_email', 'exception', 'ts_dashboard' ),
|
260 |
+
),
|
261 |
+
);
|
262 |
+
return $notifications_data;
|
263 |
}
|
264 |
|
265 |
/*
|
267 |
* WC sub menu
|
268 |
*/
|
269 |
public function register_woocommerce_trackship_menu() {
|
270 |
+
add_submenu_page( 'woocommerce', 'TrackShip', 'TrackShip', 'manage_woocommerce', 'trackship-for-woocommerce', array( $this, 'trackship_page_callback' ) );
|
|
|
|
|
|
|
271 |
}
|
272 |
|
273 |
/*
|
274 |
* callback for Shipment Tracking page
|
275 |
*/
|
276 |
+
public function trackship_page_callback() {
|
277 |
+
$wc_ast_api_key = get_option('wc_ast_api_key');
|
278 |
+
?>
|
279 |
<div class="zorem-layout">
|
280 |
<div class="zorem-layout__header">
|
281 |
+
<h1 class="zorem-layout__header-breadcrumbs">
|
282 |
+
<span><a href="<?php echo esc_url( admin_url( '/admin.php?page=wc-admin' ) ); ?>"><?php esc_html_e('WooCommerce', 'woocommerce'); ?></a></span>
|
283 |
+
<span class="header-breadcrumbs-last">TrackShip</span>
|
284 |
+
</h1>
|
|
|
285 |
</div>
|
286 |
+
<?php
|
287 |
+
if ( $wc_ast_api_key ) {
|
288 |
+
$ast_admin = new WC_Advanced_Shipment_Tracking_Admin();
|
289 |
+
|
290 |
+
do_action( 'ast_settings_admin_notice' );
|
291 |
|
292 |
+
$trackship = WC_Advanced_Shipment_Tracking_Trackship::get_instance();
|
293 |
+
$completed_order_with_tracking = $trackship->completed_order_with_tracking();
|
294 |
+
$completed_order_with_zero_balance = $trackship->completed_order_with_zero_balance();
|
295 |
+
$completed_order_with_do_connection = $trackship->completed_order_with_do_connection();
|
296 |
+
|
297 |
+
$url = 'https://my.trackship.info/wp-json/tracking/get_user_plan';
|
298 |
+
$args['body'] = array(
|
299 |
+
'user_key' => $wc_ast_api_key,
|
300 |
+
);
|
301 |
+
$response = wp_remote_post( $url, $args );
|
302 |
+
if ( !is_wp_error( $response ) ) {
|
303 |
+
$plan_data = json_decode($response['body']);
|
304 |
+
}
|
305 |
+
?>
|
306 |
+
<div class="woocommerce zorem_admin_layout">
|
307 |
+
<div class="ast_admin_content" >
|
308 |
+
<div class="ts_nav_div">
|
309 |
+
<?php
|
310 |
+
$this->get_html_menu_tab( $this->ast_menu_trackship_options() );
|
311 |
+
require_once( 'views/admin_trackship_dashboard.php' );
|
312 |
+
require_once( 'views/admin_status_notifications.php' );
|
313 |
+
?>
|
314 |
+
</div>
|
315 |
+
</div>
|
316 |
+
</div>
|
317 |
+
<div id="trackship_settings_snackbar" class="ast_snackbar"><?php esc_html_e( 'Data saved successfully.', 'woo-advanced-shipment-tracking' ); ?></div>
|
318 |
+
</div>
|
319 |
+
<?php
|
320 |
+
} else {
|
321 |
+
include 'views/admin_options_trackship_integration.php';
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
/*
|
326 |
+
* function for create tab menu html
|
327 |
+
*/
|
328 |
+
public function get_html_menu_tab( $arrays ) {
|
329 |
+
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'ts_dashboard' ;
|
330 |
+
foreach( (array)$arrays as $id => $array ) {
|
331 |
+
$checked = ( $tab == $array['data-tab'] ) ? 'checked' : '' ;
|
332 |
+
?>
|
333 |
+
<input class="tab_input" id="<?php esc_html_e( $id ); ?>" name="<?php esc_html_e( $array['name'] ); ?>" type="radio" data-tab="<?php esc_html_e( $array['data-tab'] ); ?>" data-label="<?php esc_html_e( $array['data-label'] ); ?>" <?php esc_html_e( $checked ); ?> />
|
334 |
+
<label class="<?php esc_html_e( $array['class'] ); ?>" for="<?php esc_html_e( $id ); ?>"><?php esc_html_e( $array['title'] ); ?></label>
|
335 |
+
<?php
|
336 |
+
}
|
337 |
+
}
|
338 |
|
339 |
/*
|
340 |
* include file on plugin load
|
343 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-tracking-page-customizer.php';
|
344 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-intransit-email-customizer.php';
|
345 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-failure-email-customizer.php';
|
346 |
+
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-exception-email-customizer.php';
|
347 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-outfordelivery-email-customizer.php';
|
348 |
+
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-delivered-email-customizer.php';
|
349 |
+
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-returntosender-email-customizer.php';
|
350 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-availableforpickup-email-customizer.php';
|
351 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-onhold-email-customizer.php';
|
352 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/class-wc-late-shipments-email-customizer.php';
|
|
|
353 |
require_once wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/trackship-email-manager.php';
|
354 |
}
|
355 |
|
356 |
/*
|
357 |
* settings form save
|
358 |
*/
|
359 |
+
public function wc_ast_trackship_form_update_callback() {
|
360 |
|
361 |
if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_trackship_form', 'wc_ast_trackship_form_nonce' ) ) {
|
362 |
|
363 |
$data2 = $this->get_trackship_general_data();
|
364 |
|
365 |
+
foreach ( $data2 as $key2 => $val2 ) {
|
366 |
update_option( $key2, sanitize_text_field( $_POST[ $key2 ] ) );
|
367 |
}
|
368 |
update_option( 'wc_ast_trackship_other_page', sanitize_text_field( $_POST[ 'wc_ast_trackship_other_page' ] ) );
|
369 |
+
echo json_encode( array( 'success' => 'true' ) );
|
370 |
+
die();
|
371 |
}
|
372 |
}
|
373 |
|
374 |
/*
|
375 |
* tracking page form save
|
376 |
*/
|
377 |
+
public function trackship_tracking_page_form_update_callback() {
|
378 |
+
|
379 |
if ( ! empty( $_POST ) && check_admin_referer( 'trackship_tracking_page_form', 'trackship_tracking_page_form_nonce' ) ) {
|
380 |
|
381 |
+
$data1 = $this->get_tracking_page_data();
|
382 |
|
383 |
+
foreach ( $data1 as $key1 => $val1 ) {
|
384 |
update_option( $key1, sanitize_text_field( $_POST[ $key1 ] ) );
|
385 |
}
|
386 |
|
387 |
+
echo json_encode( array('success' => 'true') );
|
388 |
+
die();
|
389 |
}
|
390 |
}
|
391 |
|
392 |
/*
|
393 |
* late shipmenta form save
|
394 |
*/
|
395 |
+
public function ts_late_shipments_email_form_update_callback() {
|
396 |
+
|
397 |
if ( ! empty( $_POST ) && check_admin_referer( 'ts_late_shipments_email_form', 'ts_late_shipments_email_form_nonce' ) ) {
|
398 |
|
399 |
+
$wcast_late_shipments_days = isset( $_POST['wcast_late_shipments_days'] ) ? wc_clean( $_POST['wcast_late_shipments_days'] ) : '';
|
400 |
+
$wcast_late_shipments_email_to = isset( $_POST['wcast_late_shipments_email_to'] ) ? wc_clean( $_POST['wcast_late_shipments_email_to'] ) : '';
|
401 |
+
$wcast_late_shipments_email_subject = isset( $_POST['wcast_late_shipments_email_subject'] ) ? wc_clean( $_POST['wcast_late_shipments_email_subject'] ) : '';
|
402 |
+
$wcast_late_shipments_email_content = isset( $_POST['wcast_late_shipments_email_content'] ) ? wc_clean( $_POST['wcast_late_shipments_email_content'] ) : '';
|
403 |
+
$wcast_late_shipments_trigger_alert = isset( $_POST['wcast_late_shipments_trigger_alert'] ) ? wc_clean( $_POST['wcast_late_shipments_trigger_alert'] ) : '';
|
404 |
+
$wcast_late_shipments_daily_digest_time = isset( $_POST['wcast_late_shipments_daily_digest_time'] ) ? wc_clean( $_POST['wcast_late_shipments_daily_digest_time'] ) : '';
|
405 |
+
$wcast_enable_late_shipments_admin_email = isset( $_POST['wcast_enable_late_shipments_admin_email'] ) ? wc_clean( $_POST['wcast_enable_late_shipments_admin_email'] ) : '';
|
406 |
|
407 |
$late_shipments_email_settings = array(
|
408 |
'wcast_enable_late_shipments_admin_email' => $wcast_enable_late_shipments_admin_email,
|
420 |
$Late_Shipments->remove_cron();
|
421 |
$Late_Shipments->setup_cron();
|
422 |
}
|
423 |
+
}
|
424 |
+
|
425 |
/*
|
426 |
* get settings tab array data
|
427 |
* return array
|
428 |
*/
|
429 |
+
public function get_trackship_general_data(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
|
431 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
432 |
+
$show_trackship_field = ( $wc_ast_api_key ) ? true : false;
|
433 |
+
|
434 |
+
$form_data = array(
|
435 |
+
'wc_ast_show_shipment_status_filter' => array(
|
436 |
+
'type' => 'tgl_checkbox',
|
437 |
+
'tgl_color' => 'green',
|
438 |
+
'title' => __( 'Display shipment status filter on orders admin', 'woo-advanced-shipment-tracking' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
'show' => $show_trackship_field,
|
440 |
+
'class' => '',
|
441 |
),
|
442 |
);
|
443 |
return $form_data;
|
444 |
+
}
|
445 |
+
|
446 |
/*
|
447 |
* get settings tab array data
|
448 |
* return array
|
449 |
*/
|
450 |
+
public function get_tracking_page_data(){
|
451 |
+
|
452 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
453 |
+
$show_trackship_field = ( $wc_ast_api_key ) ? true : false;
|
|
|
|
|
|
|
|
|
454 |
|
455 |
$slug = '';
|
456 |
$page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' );
|
457 |
+
$wc_ast_trackship_page_id = get_option( 'wc_ast_trackship_page_id' );
|
458 |
+
$post = get_post( $wc_ast_trackship_page_id );
|
|
|
459 |
|
460 |
+
if ( $post ) {
|
461 |
+
$slug = $post->post_name;
|
462 |
+
}
|
463 |
+
|
464 |
+
$page_desc = ( 'ts-shipment-tracking' != $slug ) ? __( 'You must add the shortcode [wcast-track-order] to the selected page in order for the tracking page to work.', 'woo-advanced-shipment-tracking' ) : '';
|
465 |
+
|
466 |
+
$ts_tracking_page_customizer = new ts_tracking_page_customizer();
|
467 |
$form_data = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
'wc_ast_use_tracking_page' => array(
|
469 |
'type' => 'tgl_checkbox',
|
470 |
'tgl_color' => 'green',
|
471 |
'title' => __( 'Enable a tracking page', 'woo-advanced-shipment-tracking' ),
|
472 |
+
'show' => $show_trackship_field,
|
473 |
+
'class' => '',
|
|
|
474 |
),
|
475 |
'wc_ast_trackship_page_id' => array(
|
476 |
'type' => 'dropdown_tpage',
|
477 |
'title' => __( 'Select tracking page', 'woo-advanced-shipment-tracking' ),
|
478 |
'options' => $page_list,
|
479 |
+
'show' => $show_trackship_field,
|
480 |
+
'desc' => $page_desc,
|
481 |
+
'class' => '',
|
482 |
+
),
|
483 |
+
'wc_ast_trackship_other_page' => array(
|
484 |
+
'type' => 'text',
|
485 |
+
'title' => __( 'Other', '' ),
|
486 |
+
'show' => $show_trackship_field,
|
487 |
'class' => '',
|
488 |
),
|
489 |
+
'wc_ast_tracking_page_customize_btn' => array(
|
490 |
+
'type' => 'button',
|
491 |
+
'title' => __( 'Tracking Widget Customizer', 'woo-advanced-shipment-tracking' ),
|
492 |
+
'show' => $show_trackship_field,
|
493 |
+
'class' => '',
|
494 |
+
'customize_link' => $ts_tracking_page_customizer->get_customizer_url( 'ast_tracking_page_section', 'ts_dashboard' ),
|
495 |
+
),
|
496 |
);
|
497 |
return $form_data;
|
498 |
}
|
501 |
* get settings tab array data
|
502 |
* return array
|
503 |
*/
|
504 |
+
public function get_delivered_data() {
|
505 |
$form_data = array(
|
506 |
'wc_ast_status_delivered' => array(
|
507 |
'type' => 'checkbox',
|
528 |
),
|
529 |
);
|
530 |
return $form_data;
|
|
|
531 |
}
|
532 |
+
|
533 |
/*
|
534 |
* Trackship Automation form save
|
535 |
*/
|
536 |
+
public function wc_ast_trackship_automation_form_update() {
|
|
|
|
|
537 |
$data = $this->get_delivered_data();
|
538 |
+
foreach ( $data as $key => $val ) {
|
539 |
+
if ( isset( $_POST[ $key ] ) ) {
|
540 |
+
update_option( $key, wc_clean( $_POST[ $key ] ) );
|
|
|
541 |
}
|
542 |
}
|
543 |
+
}
|
544 |
|
545 |
/**
|
546 |
* Adds 'shipment_status' column header to 'Orders' page immediately after 'woocommerce-advanced-shipment-tracking' column.
|
548 |
* @param string[] $columns
|
549 |
* @return string[] $new_columns
|
550 |
*/
|
551 |
+
public function wc_add_order_shipment_status_column_header( $columns ) {
|
552 |
wp_enqueue_style( 'trackship_styles' );
|
553 |
$new_columns = array();
|
554 |
|
568 |
*
|
569 |
* @param string[] $column name of column being displayed
|
570 |
*/
|
571 |
+
public function wc_add_order_shipment_status_column_content( $column ) {
|
572 |
+
|
573 |
global $post;
|
574 |
+
|
575 |
if ( 'shipment_status_old' === $column ) {
|
576 |
|
577 |
+
$shipment_status = get_post_meta( $post->ID, 'shipment_status', true );
|
578 |
|
579 |
+
if ( is_array( $shipment_status ) ) {
|
580 |
+
foreach ( $shipment_status as $data ) {
|
581 |
$status = $data["status"];
|
582 |
$est_delivery_date = $data["est_delivery_date"];
|
583 |
+
echo "<div class='ast-shipment-status shipment-" . sanitize_title($status) . "' >" . apply_filters( 'trackship_status_filter', $status ) . apply_filters( 'trackship_status_icon_filter', "", $status ) . "</div>";
|
584 |
|
585 |
$date = $data["status_date"];
|
586 |
+
if ( $date ) {
|
587 |
+
$date = date( "Y-m-d", strtotime( $date ) );
|
588 |
echo "<span class=description>on {$date}</span>";
|
589 |
}
|
590 |
+
if ( $est_delivery_date ) {
|
591 |
echo "<div>EST Delivery: {$est_delivery_date}</div>";
|
592 |
}
|
593 |
}
|
598 |
|
599 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
600 |
$tracking_items = $ast->get_tracking_items( $post->ID );
|
601 |
+
$shipment_status = get_post_meta( $post->ID, 'shipment_status', true );
|
602 |
$wp_date_format = get_option( 'date_format' );
|
603 |
+
$date_format = ( $wp_date_format == 'd/m/Y' ) ? 'd/m' : 'm/d' ;
|
604 |
+
|
605 |
+
if ( count( $tracking_items ) > 0 ) {
|
|
|
|
|
|
|
606 |
?>
|
607 |
+
<ul class="wcast-shipment-status-list">
|
608 |
+
<?php
|
609 |
+
foreach ( $tracking_items as $key => $tracking_item ) {
|
610 |
+
|
611 |
+
if ( !isset( $shipment_status[$key] ) ) {
|
612 |
+
echo '<li class="tracking-item-' . $tracking_item['tracking_id'] . '"></li>';continue;
|
613 |
+
}
|
614 |
+
|
615 |
+
$status = isset( $shipment_status[$key]['pending_status'] ) ? $shipment_status[$key]['pending_status'] : $shipment_status[$key]['status'];
|
616 |
+
$status_date = $shipment_status[$key]['status_date'];
|
617 |
+
$est_delivery_date = isset( $shipment_status[$key]['est_delivery_date'] ) ? $shipment_status[$key]['est_delivery_date'] : '';
|
618 |
+
$has_est_delivery = ( 'delivered' != $status && 'return_to_sender' != $status && !empty( $est_delivery_date ) ) ? true : false ;
|
619 |
+
?>
|
620 |
+
<li id="shipment-item-<?php esc_html_e( $tracking_item['tracking_id'] ); ?>" class="tracking-item-<?php esc_html_e( $tracking_item['tracking_id'] ); ?> open_tracking_details" data-orderid="<?php esc_html_e( $post->ID ); ?>" data-tracking_id="<?php esc_html_e( $tracking_item['tracking_id'] ); ?>">
|
621 |
+
<div class="ast-shipment-status shipment-<?php esc_html_e( $status ); ?> has_est_delivery_<?php echo ( $has_est_delivery ? 1 : 0 ) ?>">
|
622 |
+
<?php echo apply_filters( 'trackship_status_icon_filter', "", $status ); ?>
|
623 |
+
<span class="ast-shipment-tracking-status"><?php echo apply_filters( 'trackship_status_filter', $status ); ?></span>
|
624 |
+
<?php if ( '' != $status_date ) { ?>
|
625 |
+
<span class="showif_has_est_delivery_0 ft11">on <?php esc_html_e( date( $date_format, strtotime( $status_date ) ) ); ?></span>
|
626 |
+
<?php } ?>
|
627 |
+
<?php if ( $has_est_delivery ) { ?>
|
628 |
+
<span class="wcast-shipment-est-delivery ft11">Est. Delivery(<?php esc_html_e( date( $date_format, strtotime( $est_delivery_date ) ) ); ?>)</span>
|
629 |
+
<?php } ?>
|
630 |
+
</div>
|
631 |
+
</li>
|
632 |
+
<?php } ?>
|
633 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
634 |
<?php
|
635 |
} else {
|
636 |
echo '–';
|
642 |
* add bulk action
|
643 |
* Change order status to delivered
|
644 |
*/
|
645 |
+
public function add_bulk_actions_get_shipment_status( $bulk_actions ) {
|
646 |
$bulk_actions['get_shipment_status'] = 'Get Shipment Status';
|
647 |
return $bulk_actions;
|
648 |
}
|
650 |
/*
|
651 |
* order bulk action for get shipment status
|
652 |
*/
|
653 |
+
public function get_shipment_status_handle_bulk_action_edit_shop_order( $redirect_to, $action, $post_ids ) {
|
654 |
|
655 |
+
if ( 'get_shipment_status' !== $action ) {
|
656 |
return $redirect_to;
|
657 |
+
}
|
658 |
|
659 |
$processed_ids = array();
|
660 |
|
661 |
$order_count = count($post_ids);
|
662 |
|
|
|
|
|
|
|
|
|
663 |
foreach ( $post_ids as $post_id ) {
|
|
|
664 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $post_id ) );
|
665 |
+
$processed_ids[] = $post_id;
|
|
|
666 |
}
|
667 |
|
668 |
return $redirect_to = add_query_arg( array(
|
675 |
/*
|
676 |
* bulk shipment status action for completed order with tracking details and without shipment status
|
677 |
*/
|
678 |
+
public static function bulk_shipment_status_from_settings_fun() {
|
679 |
+
|
680 |
$args = array(
|
681 |
'status' => 'wc-completed',
|
682 |
'limit' => 100,
|
683 |
'date_created' => '>' . ( time() - 2592000 ),
|
684 |
);
|
685 |
+
|
686 |
$orders = wc_get_orders( $args );
|
687 |
+
|
688 |
+
foreach ( $orders as $order ) {
|
689 |
+
|
690 |
$order_id = $order->get_id();
|
691 |
|
692 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
693 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
694 |
+
|
695 |
+
if ( $tracking_items ) {
|
696 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
697 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
698 |
+
|
699 |
+
if ( !isset( $shipment_status[ $key ] ) ) {
|
700 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $order_id ) );
|
701 |
}
|
702 |
+
|
703 |
+
if ( isset( $shipment_status[ $key ][ 'pending_status' ] ) && 'TrackShip balance is 0' == $shipment_status[ $key ][ 'pending_status' ] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $order_id ) );
|
705 |
}
|
706 |
+
|
707 |
+
if( isset( $shipment_status[ $key ][ 'pending_status' ] ) && 'TrackShip connection issue' == $shipment_status[$key]['pending_status'] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
wp_schedule_single_event( time() + 1, 'wcast_retry_trackship_apicall', array( $order_id ) );
|
709 |
}
|
710 |
}
|
711 |
}
|
712 |
}
|
713 |
+
$url = admin_url( '/edit.php?post_type=shop_order' );
|
714 |
+
echo $url;
|
715 |
+
die();
|
716 |
+
}
|
717 |
|
718 |
/*
|
719 |
* The results notice from bulk action on orders
|
720 |
*/
|
721 |
+
public function shipment_status_bulk_action_admin_notice() {
|
722 |
+
|
723 |
+
if ( empty( $_REQUEST['get_shipment_status'] ) ) {
|
724 |
+
return; // Exit
|
725 |
+
}
|
726 |
|
727 |
$count = intval( $_REQUEST['processed_count'] );
|
728 |
|
742 |
* @return array
|
743 |
*/
|
744 |
public function add_order_meta_box_get_shipment_status_actions( $actions ) {
|
|
|
745 |
// add download to CSV action
|
746 |
$actions['get_shipment_status_edit_order'] = __( 'Get Shipment Status', 'woo-advanced-shipment-tracking' );
|
747 |
return $actions;
|
750 |
/*
|
751 |
* order details meta box action
|
752 |
*/
|
753 |
+
public function process_order_meta_box_actions_get_shipment_status( $order ) {
|
754 |
$this->trigger_woocommerce_order_status_completed( $order->get_id() );
|
755 |
}
|
756 |
|
759 |
*
|
760 |
* @since 2.4
|
761 |
*/
|
762 |
+
public function filter_orders_by_shipment_status() {
|
763 |
global $typenow;
|
764 |
|
765 |
if ( 'shop_order' === $typenow ) {
|
799 |
* @param array $vars query vars without filtering
|
800 |
* @return array $vars query vars with (maybe) filtering
|
801 |
*/
|
802 |
+
public function filter_orders_by_shipment_status_query( $vars ) {
|
803 |
global $typenow;
|
804 |
+
if ( 'shop_order' === $typenow && isset( $_GET['_shop_order_shipment_status'] ) && $_GET['_shop_order_shipment_status'] != '' ) {
|
805 |
$vars['meta_query'][] = array(
|
806 |
'key' => 'ts_shipment_status',
|
807 |
'value' => $_GET['_shop_order_shipment_status'],
|
808 |
'compare' => 'LIKE'
|
809 |
);
|
810 |
}
|
|
|
811 |
return $vars;
|
812 |
}
|
813 |
|
815 |
* trigger when order status changed to shipped or completed or update tracking
|
816 |
* param $order_id
|
817 |
*/
|
818 |
+
public function trigger_woocommerce_order_status_completed( $order_id ) {
|
819 |
+
|
|
|
820 |
$order = wc_get_order( $order_id );
|
821 |
$order_shipped = apply_filters( 'is_order_shipped', true, $order );
|
822 |
+
|
823 |
+
if( $order_shipped ) {
|
|
|
824 |
$api = new WC_Advanced_Shipment_Tracking_Api_Call;
|
825 |
$array = $api->get_trackship_apicall( $order_id );
|
826 |
}
|
829 |
/*
|
830 |
* filter for shipment status
|
831 |
*/
|
832 |
+
public function trackship_status_filter_func( $status ) {
|
833 |
+
switch ( $status ) {
|
834 |
case "in_transit":
|
835 |
$status = __( 'In Transit', 'woo-advanced-shipment-tracking' );
|
836 |
break;
|
878 |
break;
|
879 |
case "deleted":
|
880 |
$status = __( 'Deleted', 'woocommerce' );
|
881 |
+
break;
|
|
|
882 |
}
|
883 |
return $status;
|
884 |
}
|
886 |
/*
|
887 |
* filter for shipment status icon
|
888 |
*/
|
889 |
+
public function trackship_status_icon_filter_func( $html, $status ) {
|
890 |
+
switch ( $status ) {
|
891 |
case "in_transit":
|
892 |
$html = '<span class="shipment-icon icon-'.$status.'">';
|
893 |
break;
|
936 |
default:
|
937 |
$html = '<span class="shipment-icon icon-default">';
|
938 |
break;
|
|
|
939 |
}
|
940 |
return $html;
|
941 |
}
|
943 |
/*
|
944 |
* retry trackship api call
|
945 |
*/
|
946 |
+
public function wcast_retry_trackship_apicall_func( $order_id ) {
|
947 |
$logger = wc_get_logger();
|
948 |
$context = array( 'source' => 'retry_trackship_apicall' );
|
949 |
+
$logger->info( "Retry trackship api call for Order id : " . $order_id, $context );
|
950 |
$this->trigger_woocommerce_order_status_completed( $order_id );
|
951 |
}
|
952 |
|
953 |
/*
|
954 |
* update all shipment status email status
|
955 |
*/
|
956 |
+
public function update_shipment_status_email_status_fun() {
|
957 |
+
$status_settings = get_option( $_POST['settings_data'] );
|
958 |
+
$status_settings[ $_POST['id'] ] = wc_clean( $_POST[ 'wcast_enable_status_email' ] );
|
959 |
update_option( $_POST['settings_data'], $status_settings );
|
960 |
exit;
|
961 |
}
|
962 |
|
963 |
+
/*
|
964 |
+
* update late shipment email status
|
965 |
+
*/
|
966 |
+
public function update_enable_late_shipments_email_fun() {
|
967 |
+
$status_settings[ $_POST['id'] ] = wc_clean( $_POST[ 'wcast_enable_late_shipments_email' ] );
|
968 |
update_option( $_POST['settings_data'], $status_settings );
|
969 |
exit;
|
970 |
}
|
973 |
* get trackship bulk actions tab array data
|
974 |
* return array
|
975 |
*/
|
976 |
+
public function get_trackship_bulk_actions_data() {
|
977 |
|
978 |
$completed_order_with_tracking = $this->completed_order_with_tracking();
|
979 |
$completed_order_with_zero_balance = $this->completed_order_with_zero_balance();
|
980 |
$completed_order_with_do_connection = $this->completed_order_with_do_connection();
|
981 |
|
982 |
+
$disable_bulk_sync = ( $completed_order_with_tracking > 0 ) ? false : true;
|
983 |
+
$disable_bulk_sync_zero_balance = ( $completed_order_with_zero_balance > 0 ) ? false : true;
|
984 |
+
$disable_bulk_sync_do_connection = ( $completed_order_with_do_connection > 0 ) ? false : true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
985 |
|
986 |
$wc_ast_status_shipped = get_option('wc_ast_status_shipped');
|
987 |
|
988 |
+
if ( 1 == $wc_ast_status_shipped ) {
|
989 |
$completed_order_label = '<span class="shipped_label">shipped</span>';
|
990 |
} else{
|
991 |
$completed_order_label = '<span class="shipped_label">completed</span>';
|
993 |
|
994 |
$form_data = array(
|
995 |
'wc_ast_bulk_shipment_status' => array(
|
996 |
+
'type' => 'button',
|
997 |
+
'title' => sprintf( __( 'You got %s %s orders with tracking info that were not sent to track on TrackShip', 'woo-advanced-shipment-tracking' ), $completed_order_with_tracking , $completed_order_label ),
|
998 |
+
'label' => __( 'Get Shipment Status', 'woo-advanced-shipment-tracking' ),
|
999 |
+
'show' => true,
|
1000 |
+
'disable' => $disable_bulk_sync,
|
1001 |
+
'button_class' => 'bulk_shipment_status_button',
|
1002 |
+
'class' => '',
|
1003 |
),
|
1004 |
'wc_ast_bulk_shipment_status_for_zero_tracker_balace' => array(
|
1005 |
+
'type' => 'button',
|
1006 |
+
'title' => sprintf( __( 'You got %s %s orders with shipment status “TrackShip balance is 0”', 'woo-advanced-shipment-tracking' ), $completed_order_with_zero_balance , $completed_order_label ),
|
1007 |
+
'label' => __( 'Get Shipment Status', 'woo-advanced-shipment-tracking' ),
|
1008 |
+
'show' => true,
|
1009 |
+
'disable' => $disable_bulk_sync_zero_balance,
|
1010 |
+
'button_class' => 'bulk_shipment_status_button_for_empty_balance',
|
1011 |
+
'class' => '',
|
1012 |
),
|
1013 |
'wc_ast_bulk_shipment_status_for_trackship_connection_issue' => array(
|
1014 |
+
'type' => 'button',
|
1015 |
+
'title' => sprintf( __( 'You got %s %s orders with shipment status “TrackShip connection issue”', 'woo-advanced-shipment-tracking' ), $completed_order_with_do_connection , $completed_order_label ),
|
1016 |
+
'label' => __( 'Get Shipment Status', 'woo-advanced-shipment-tracking' ),
|
1017 |
'show' => true,
|
1018 |
+
'disable' => $disable_bulk_sync_do_connection,
|
1019 |
+
'button_class' => 'bulk_shipment_status_button_for_connection_issue',
|
1020 |
+
'class' => '',
|
1021 |
),
|
1022 |
);
|
1023 |
return $form_data;
|
1027 |
* get completed order with tracking that not sent to TrackShip
|
1028 |
* return number
|
1029 |
*/
|
1030 |
+
public function completed_order_with_tracking() {
|
1031 |
+
|
1032 |
// Get orders completed.
|
1033 |
$args = array(
|
1034 |
'status' => 'wc-completed',
|
1040 |
|
1041 |
$completed_order_with_tracking = 0;
|
1042 |
|
1043 |
+
foreach ( $orders as $order ) {
|
1044 |
$order_id = $order->get_id();
|
1045 |
|
1046 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1047 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1048 |
+
|
1049 |
+
if ( $tracking_items ) {
|
1050 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
1051 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
1052 |
+
if( !isset( $shipment_status[ $key ] ) ) {
|
1053 |
$completed_order_with_tracking++;
|
1054 |
}
|
1055 |
}
|
1062 |
* get completed order with Trackship Balance 0 status
|
1063 |
* return number
|
1064 |
*/
|
1065 |
+
public function completed_order_with_zero_balance() {
|
1066 |
|
1067 |
// Get orders completed.
|
1068 |
$args = array(
|
1075 |
|
1076 |
$completed_order_with_zero_balance = 0;
|
1077 |
|
1078 |
+
foreach ( $orders as $order ) {
|
1079 |
$order_id = $order->get_id();
|
1080 |
|
1081 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1082 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1083 |
|
1084 |
+
if ( $tracking_items ) {
|
1085 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
1086 |
+
foreach ( $tracking_items as $key => $tracking_item ) {
|
1087 |
+
if ( isset( $shipment_status[ $key ][ 'pending_status' ] ) && 'TrackShip balance is 0' == $shipment_status[ $key ][ 'pending_status' ] ) {
|
1088 |
+
$completed_order_with_zero_balance++;
|
1089 |
}
|
1090 |
}
|
1091 |
}
|
1097 |
* get completed order with Trackship connection issue status
|
1098 |
* return number
|
1099 |
*/
|
1100 |
+
public function completed_order_with_do_connection() {
|
1101 |
|
1102 |
// Get orders completed.
|
1103 |
$args = array(
|
1110 |
|
1111 |
$completed_order_with_do_connection = 0;
|
1112 |
|
1113 |
+
foreach ( $orders as $order ) {
|
1114 |
$order_id = $order->get_id();
|
1115 |
|
1116 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1117 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
1118 |
+
|
1119 |
+
if ( $tracking_items ) {
|
1120 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
1121 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
1122 |
+
if ( isset( $shipment_status[ $key ][ 'pending_status' ] ) && 'TrackShip connection issue' == $shipment_status[ $key ][ 'pending_status' ] ) {
|
1123 |
$completed_order_with_do_connection++;
|
1124 |
}
|
1125 |
}
|
1131 |
/**
|
1132 |
* Shipment tracking info html in orders details page
|
1133 |
*/
|
1134 |
+
public function display_shipment_tracking_info( $order_id, $item ) {
|
1135 |
+
|
1136 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true );
|
1137 |
+
$ts_shipment_status = get_post_meta( $order_id, 'ts_shipment_status', true );
|
|
|
|
|
1138 |
|
1139 |
$tracking_id = $item['tracking_id'];
|
1140 |
|
1142 |
$tracking_items = $ast->get_tracking_items( $order_id );
|
1143 |
|
1144 |
$wp_date_format = get_option( 'date_format' );
|
1145 |
+
$date_format = ( 'd/m/Y' == $wp_date_format ) ? 'd/m' : 'm/d' ;
|
|
|
|
|
|
|
|
|
|
|
1146 |
|
1147 |
if ( count( $tracking_items ) > 0 ) {
|
1148 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
1149 |
+
if( $tracking_id == $tracking_item['tracking_id'] ) {
|
1150 |
+
if ( isset( $shipment_status[$key] ) ) {
|
1151 |
+
$has_est_delivery = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1152 |
|
1153 |
+
$status = isset( $shipment_status[$key]['pending_status'] ) ? $shipment_status[$key]['pending_status'] : $shipment_status[$key]['status'];
|
1154 |
+
$status_date = $shipment_status[$key]['status_date'];
|
1155 |
+
$est_delivery_date = isset( $shipment_status[$key]['est_delivery_date'] ) ? $shipment_status[$key]['est_delivery_date'] : '';
|
1156 |
|
1157 |
+
if ( $status != 'delivered' && $status != 'return_to_sender' && !empty( $est_delivery_date ) ) {
|
1158 |
+
$has_est_delivery = true;
|
1159 |
+
}
|
1160 |
?>
|
1161 |
<div class="ast-shipment-status-div">
|
1162 |
+
<span class="open_tracking_details ast-shipment-status shipment-<?php echo sanitize_title( $status ); ?>" data-orderid="<?php echo $order_id; ?>" data-tracking_id="<?php echo $tracking_id; ?>">
|
1163 |
+
<?php echo apply_filters( 'trackship_status_icon_filter', "", $status ); ?> <strong><?php echo apply_filters( 'trackship_status_filter', $status ); ?></strong>
|
1164 |
+
</span>
|
1165 |
+
<?php if ( '' != $status_date ) { ?>
|
1166 |
+
<span class="">on <?php echo date( $date_format, strtotime( $status_date ) ); ?></span>
|
1167 |
+
<?php } ?>
|
1168 |
+
<br>
|
1169 |
+
<?php if ( $has_est_delivery ) { ?>
|
1170 |
+
<span class="wcast-shipment-est-delivery ft11">Est. Delivery(<?php echo date( $date_format, strtotime( $est_delivery_date ) ); ?>)</span>
|
1171 |
+
<?php } ?>
|
1172 |
</div>
|
1173 |
<?php
|
1174 |
}
|
1180 |
/**
|
1181 |
* Delete tracking information from TrackShip when tracking deleted from AST
|
1182 |
*/
|
1183 |
+
public function delete_tracking_number_from_trackship( $tracking_items, $tracking_id, $order_id ) {
|
1184 |
|
1185 |
+
foreach ( $tracking_items as $tracking_item ) {
|
1186 |
+
if ( $tracking_item['tracking_id'] == $_POST['tracking_id'] ) {
|
1187 |
$tracking_number = $tracking_item['tracking_number'];
|
1188 |
$tracking_provider = $tracking_item['tracking_provider'];
|
1189 |
$api = new WC_Advanced_Shipment_Tracking_Api_Call;
|
1196 |
* fix shipment tracking for deleted tracking
|
1197 |
*/
|
1198 |
public function func_fix_shipment_tracking_for_deleted_tracking( $order_id, $key, $item ){
|
1199 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
1200 |
+
if ( isset( $shipment_status[ $key ] ) ) {
|
1201 |
unset($shipment_status[$key]);
|
1202 |
+
update_post_meta( $order_id, 'shipment_status', $shipment_status );
|
1203 |
}
|
1204 |
|
1205 |
+
$ts_shipment_status = get_post_meta( $order_id, 'ts_shipment_status', true );
|
1206 |
+
if( isset( $ts_shipment_status[ $key ] ) ) {
|
1207 |
+
unset( $ts_shipment_status[$key] );
|
1208 |
+
update_post_meta( $order_id, 'ts_shipment_status', $ts_shipment_status );
|
1209 |
}
|
1210 |
}
|
1211 |
|
1212 |
/**
|
1213 |
* code for check if tracking number in order is delivered or not
|
1214 |
*/
|
1215 |
+
public function check_tracking_delivered( $order_id ) {
|
1216 |
+
|
1217 |
$delivered = true;
|
1218 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true );
|
1219 |
+
$wc_ast_status_delivered = get_option( 'wc_ast_status_delivered' );
|
1220 |
|
1221 |
+
foreach( (array) $shipment_status as $shipment ) {
|
1222 |
$status = $shipment['status'];
|
1223 |
+
if( 'delivered' != $status ) {
|
1224 |
$delivered = false;
|
1225 |
}
|
1226 |
}
|
1227 |
+
|
1228 |
+
if ( count( $shipment_status ) > 0 && $delivered == true && $wc_ast_status_delivered ) {
|
1229 |
|
1230 |
+
$order = wc_get_order( $order_id );
|
1231 |
+
$order_status = $order->get_status();
|
1232 |
|
1233 |
+
$change_to_delivered = apply_filters( 'ts_change_order_to_delivered', false, $order_status );
|
1234 |
+
|
1235 |
+
if ( $order_status == 'completed' || $order_status == 'updated-tracking' || $order_status == 'shipped' ) {
|
1236 |
+
$change_to_delivered = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1237 |
}
|
1238 |
+
|
1239 |
+
if ( $change_to_delivered ) {
|
1240 |
+
$order->update_status('delivered');
|
1241 |
+
}
|
1242 |
}
|
1243 |
}
|
1244 |
|
1245 |
/**
|
1246 |
* code for trigger shipment status email
|
1247 |
*/
|
1248 |
+
public function trigger_tracking_email( $order_id, $old_status, $new_status, $tracking_item, $shipment_status ) {
|
1249 |
$order = wc_get_order( $order_id );
|
1250 |
require_once( 'email-manager.php' );
|
1251 |
|
1252 |
+
if ( $old_status != $new_status ) {
|
1253 |
+
if ( $new_status == 'delivered' ) {
|
1254 |
+
wc_trackship_email_manager()->delivered_shippment_status_email_trigger( $order_id, $order, $old_status, $new_status, $tracking_item, $shipment_status );
|
1255 |
+
} elseif( $new_status == 'exception' || $new_status == 'failure' || $new_status == 'in_transit' || $new_status == 'on_hold' || $new_status == 'out_for_delivery' || $new_status == 'available_for_pickup' || $new_status == 'return_to_sender' ) {
|
1256 |
+
wc_trackship_email_manager()->shippment_status_email_trigger( $order_id, $order, $old_status, $new_status, $tracking_item, $shipment_status );
|
1257 |
}
|
1258 |
do_action( 'ast_trigger_ts_status_change',$order_id, $old_status, $new_status, $tracking_item, $shipment_status );
|
1259 |
}
|
1264 |
*/
|
1265 |
public function ast_add_dashboard_widgets() {
|
1266 |
wp_enqueue_style( 'trackship_styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/trackship.css', array(), wc_advanced_shipment_tracking()->version );
|
1267 |
+
wp_add_dashboard_widget( 'trackship_dashboard_widget', 'TrackShip Analytics <small>(last 30 days)</small>', array( $this, 'dashboard_widget_function' ) );
|
1268 |
}
|
1269 |
|
1270 |
/**
|
1271 |
* Output the contents of the dashboard widget
|
1272 |
*/
|
1273 |
public function dashboard_widget_function( $post, $callback_args ) {
|
1274 |
+
$tracking_analytics = $this->get_tracking_analytics_overview();
|
1275 |
+
?>
|
1276 |
<div class="ts-widget-content ">
|
1277 |
<div class="ts-widget-row">
|
1278 |
<div class="ts-widget__section ts-widget-rborder ts-widget-bborder">
|
1279 |
+
<h3><?php esc_html_e( 'Total Shipments', 'woo-advanced-shipment-tracking' ); ?></h3>
|
1280 |
+
<span class="ts-widget-analytics-number"><?php esc_html_e( $tracking_analytics['total_shipments'] ); ?></span>
|
1281 |
+
<span>(<?php esc_html_e( $tracking_analytics['total_orders'] ); ?> <?php esc_html_e( 'Orders', 'woocommerce' ); ?>)</span>
|
1282 |
</div>
|
1283 |
<div class="ts-widget__section ts-widget-bborder">
|
1284 |
+
<h3><?php esc_html_e( 'Avg Shipment Length', 'woo-advanced-shipment-tracking' ); ?></h3>
|
1285 |
+
<span class="ts-widget-analytics-number"><?php esc_html_e( round( (int)$tracking_analytics['avg_shipment_length'] ) ); ?></span>
|
1286 |
+
<span><?php esc_html_e( 'days', 'woo-advanced-shipment-tracking' ); ?></span>
|
1287 |
</div>
|
1288 |
</div>
|
1289 |
<div class="ts-widget-row">
|
1290 |
<div class="ts-widget__section ts-widget-rborder ts-widget-bborder">
|
1291 |
+
<h3><?php esc_html_e( 'Active Shipments', 'woo-advanced-shipment-tracking' ); ?></h3>
|
1292 |
+
<span class="ts-widget-analytics-number"><?php esc_html_e( $tracking_analytics['active_shipments'] ); ?></span>
|
1293 |
</div>
|
1294 |
<div class="ts-widget__section ts-widget-bborder">
|
1295 |
+
<h3><?php esc_html_e( 'Delivered', 'woo-advanced-shipment-tracking' ); ?></h3>
|
1296 |
+
<span class="ts-widget-analytics-number"><?php esc_html_e( $tracking_analytics['delivered_shipments'] ); ?></span>
|
1297 |
</div>
|
1298 |
</div>
|
1299 |
<div class="ts-widget-footer">
|
1300 |
+
<a class="" href="https://trackship.info/my-account/analytics/" target="blank"><?php esc_html_e( 'View Tracking Analytics','woo-advanced-shipment-tracking' ); ?></a>
|
1301 |
<a class="ts_link" href="https://trackship.info" title="TrackShip" target="blank"><img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-logo.png"></a>
|
1302 |
</div>
|
1303 |
</div>
|
1307 |
/*
|
1308 |
* TrackShip Analytics Overview
|
1309 |
*/
|
1310 |
+
public function get_tracking_analytics_overview() {
|
1311 |
global $wpdb;
|
1312 |
+
$paid_order_statuses = array( 'completed', 'delivered', 'shipped' );
|
1313 |
|
1314 |
+
$end_date = date( 'Y-m-d', strtotime( 'today - 30 days' ) );
|
1315 |
$start_date = date('Y-m-d');
|
1316 |
|
1317 |
global $wpdb;
|
1318 |
+
$paid_order_statuses = array('completed','delivered','shipped');
|
1319 |
|
1320 |
$order_query = "
|
1321 |
SELECT
|
1338 |
|
1339 |
ORDER BY
|
1340 |
posts.ID DESC
|
1341 |
+
";
|
1342 |
+
|
1343 |
+
$shipment_status_results = $wpdb->get_results( $order_query );
|
1344 |
$shipment_status = array();
|
1345 |
$shipment_status_merge = array();
|
1346 |
$tracking_item_merge = array();
|
1347 |
|
1348 |
+
foreach ( $shipment_status_results as $order ) {
|
1349 |
$order_id = $order->ID;
|
1350 |
+
$shipment_status = unserialize( $order->shipment_status );
|
1351 |
|
1352 |
+
if ( is_array( $shipment_status ) ) {
|
1353 |
+
$shipment_status_merge = array_merge( $shipment_status_merge, $shipment_status );
|
1354 |
}
|
1355 |
}
|
1356 |
|
1361 |
$avg_shipment_days_array = array();
|
1362 |
$avg_shipment_length = '';
|
1363 |
|
1364 |
+
foreach ( $shipment_status_merge as $key => $val ) {
|
1365 |
|
1366 |
$first = ( isset($val['tracking_events']) ) ? reset($val['tracking_events']) : '';
|
1367 |
$first_date = ( isset($first->datetime) ) ? $first->datetime : '';
|
1368 |
|
1369 |
+
if ( isset( $val['tracking_destination_events'] ) && count( $val['tracking_destination_events'] ) > 0 ) {
|
1370 |
$last = end($val['tracking_destination_events']);
|
1371 |
+
} elseif ( isset( $val['tracking_events'] ) ) {
|
1372 |
$last = end($val['tracking_events']);
|
1373 |
+
} else {
|
1374 |
$last = '';
|
1375 |
+
}
|
1376 |
+
|
1377 |
$last_date = ( isset($last->datetime) ) ? $last->datetime : '';
|
1378 |
|
1379 |
$status = isset( $val['status'] ) ? $val['status'] : '';
|
1380 |
|
1381 |
+
if ( 'delivered' != $status ) {
|
1382 |
$last_date = date("Y-m-d H:i:s");
|
1383 |
}
|
1384 |
|
1389 |
|
1390 |
$avg_shipment_length = $this->get_average( $avg_shipment_days_array );
|
1391 |
|
1392 |
+
if ( 'carrier_unsupported' == $status || 'INVALID_TRACKING_NUM' == $status || 'unknown' == $status || 'wrong_shipping_provider' == $status ) {
|
1393 |
+
$tracking_issues ++;
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
if ( 'delivered' == $status ) {
|
1397 |
+
$delivered_shipments ++;
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
if ( 'delivered' != $status ) {
|
1401 |
+
$active_shipments ++;
|
1402 |
+
}
|
1403 |
}
|
1404 |
|
1405 |
$result = array();
|
1416 |
/*
|
1417 |
*
|
1418 |
*/
|
1419 |
+
public function get_num_of_days( $first_date, $last_date ) {
|
1420 |
$date1 = strtotime($first_date);
|
1421 |
$date2 = strtotime($last_date);
|
1422 |
$diff = abs($date2 - $date1);
|
1423 |
return date( "d", $diff );
|
1424 |
}
|
1425 |
|
1426 |
+
public function get_average( $array ) {
|
1427 |
+
return round( array_sum($array) / count($array), 2 );
|
1428 |
}
|
1429 |
|
1430 |
/**
|
1431 |
* Create tracking page after store is connected
|
1432 |
*/
|
1433 |
+
public function create_tracking_page() {
|
1434 |
+
|
1435 |
+
if ( version_compare( get_option( 'wc_advanced_shipment_tracking_ts_page' ), '1.0', '<' ) ) {
|
1436 |
$new_page_title = 'Shipment Tracking';
|
1437 |
$new_page_slug = 'ts-shipment-tracking';
|
1438 |
$new_page_content = '[wcast-track-order]';
|
1439 |
//don't change the code below, unless you know what you're doing
|
1440 |
+
$page_check = get_page_by_title( $new_page_title );
|
1441 |
|
1442 |
+
if ( !isset( $page_check->ID ) ) {
|
1443 |
$new_page = array(
|
1444 |
'post_type' => 'page',
|
1445 |
'post_title' => $new_page_title,
|
1448 |
'post_status' => 'publish',
|
1449 |
'post_author' => 1,
|
1450 |
);
|
1451 |
+
$new_page_id = wp_insert_post( $new_page );
|
1452 |
update_option( 'wc_ast_trackship_page_id', $new_page_id );
|
1453 |
}
|
1454 |
+
update_option( 'wc_advanced_shipment_tracking_ts_page', '1.0' );
|
1455 |
}
|
1456 |
}
|
1457 |
|
1460 |
* if number not found. return false
|
1461 |
* if number found. return true
|
1462 |
*/
|
1463 |
+
public function check_tracking_exist( $value, $order ) {
|
1464 |
|
1465 |
+
if ( true == $value ) {
|
1466 |
|
1467 |
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
1468 |
+
|
1469 |
+
if ( $tracking_items ) {
|
1470 |
return true;
|
1471 |
} else {
|
1472 |
return false;
|
1473 |
}
|
1474 |
}
|
1475 |
+
|
1476 |
return $value;
|
1477 |
}
|
1478 |
|
1479 |
/*
|
1480 |
* If order status is "Updated Tracking" or "Completed" than retrn true else return false
|
1481 |
*/
|
1482 |
+
public function check_order_status( $value, $order ) {
|
|
|
1483 |
|
1484 |
+
$order_status = $order->get_status();
|
1485 |
$all_order_status = wc_get_order_statuses();
|
1486 |
|
1487 |
$default_order_status = array(
|
1495 |
'wc-failed' => 'Failed'
|
1496 |
);
|
1497 |
|
1498 |
+
foreach ( $default_order_status as $key => $value ) {
|
1499 |
+
unset( $all_order_status[ $key ] );
|
1500 |
}
|
1501 |
|
1502 |
$custom_order_status = $all_order_status;
|
1503 |
|
1504 |
+
foreach ( $custom_order_status as $key => $value ) {
|
1505 |
+
unset( $custom_order_status[ $key ] );
|
1506 |
+
$key = str_replace( "wc-", "", $key );
|
1507 |
$custom_order_status[] = $key;
|
1508 |
}
|
1509 |
|
1510 |
+
if ( 'updated-tracking' == $order_status || 'completed' == $order_status || in_array( $order_status, $custom_order_status )){
|
1511 |
return true;
|
1512 |
} else {
|
1513 |
return false;
|
includes/class-wc-advanced-shipment-tracking.php
CHANGED
@@ -12,21 +12,22 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
12 |
private static $instance;
|
13 |
|
14 |
public function __construct() {
|
|
|
15 |
global $wpdb;
|
16 |
-
|
17 |
-
|
18 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
19 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
20 |
}
|
|
|
21 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
22 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
23 |
-
$this->table = $main_blog_prefix.
|
24 |
} else{
|
25 |
-
$this->table = $wpdb->prefix.
|
26 |
-
}
|
27 |
-
|
28 |
-
|
29 |
-
$this->table = $wpdb->prefix."woo_shippment_provider";
|
30 |
}
|
31 |
}
|
32 |
|
@@ -38,7 +39,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
38 |
public static function get_instance() {
|
39 |
|
40 |
if ( null === self::$instance ) {
|
41 |
-
self::$instance = new self;
|
42 |
}
|
43 |
|
44 |
return self::$instance;
|
@@ -47,7 +48,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
47 |
/**
|
48 |
* Get shipping providers from database
|
49 |
*/
|
50 |
-
function get_providers(){
|
51 |
|
52 |
if ( empty( $this->providers ) ) {
|
53 |
$this->providers = array();
|
@@ -56,12 +57,12 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
56 |
$wpdb->hide_errors();
|
57 |
$results = $wpdb->get_results( "SELECT * FROM {$this->table}" );
|
58 |
|
59 |
-
|
60 |
if ( ! empty( $results ) ) {
|
61 |
|
62 |
foreach ( $results as $row ) {
|
|
|
63 |
$shippment_providers[ $row->ts_slug ] = array(
|
64 |
-
'provider_name'=> $
|
65 |
'provider_url' => $row->provider_url,
|
66 |
'trackship_supported' => $row->trackship_supported,
|
67 |
);
|
@@ -77,7 +78,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
77 |
/**
|
78 |
* Get shipping providers from database for WooCommerce App
|
79 |
*/
|
80 |
-
function get_providers_for_app(){
|
81 |
|
82 |
if ( empty( $this->providers_for_app ) ) {
|
83 |
$this->providers_for_app = array();
|
@@ -91,25 +92,22 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
91 |
$results = $wpdb->get_results( "SELECT * FROM {$this->table} GROUP BY shipping_country" );
|
92 |
|
93 |
|
94 |
-
foreach($shippment_countries as $s_c){
|
95 |
|
96 |
-
|
97 |
-
$country_name = esc_attr( $WC_Countries->countries[$s_c->shipping_country] );
|
98 |
-
} else{
|
99 |
-
$country_name = 'Global';
|
100 |
-
}
|
101 |
$country = $s_c->shipping_country;
|
102 |
$shippment_providers_by_country = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$this->table} WHERE shipping_country = %s AND display_in_order = 1", $country ) );
|
103 |
|
104 |
$providers_array = array();
|
105 |
$new_provider = array();
|
|
|
106 |
foreach ( $shippment_providers_by_country as $providers ) {
|
107 |
$new_provider = array(
|
108 |
$providers->provider_name => $providers->provider_url,
|
109 |
);
|
110 |
-
$providers_array = array_merge($providers_array
|
111 |
-
|
112 |
}
|
|
|
113 |
$shippment_providers[ $country_name ] = $providers_array;
|
114 |
|
115 |
$this->providers_for_app = $shippment_providers;
|
@@ -124,8 +122,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
124 |
*/
|
125 |
public function admin_styles() {
|
126 |
$plugin_url = wc_shipment_tracking()->plugin_url;
|
127 |
-
wp_enqueue_style( 'ast_styles', $plugin_url . '/assets/css/admin.css' );
|
128 |
-
|
129 |
}
|
130 |
|
131 |
/**
|
@@ -151,7 +148,6 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
151 |
*/
|
152 |
public function render_shop_order_columns( $column ) {
|
153 |
global $post;
|
154 |
-
|
155 |
if ( 'woocommerce-advanced-shipment-tracking' === $column ) {
|
156 |
echo $this->get_shipment_tracking_column( $post->ID );
|
157 |
}
|
@@ -180,29 +176,29 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
180 |
$tracking_provider = isset( $tracking_item['tracking_provider'] ) ? $tracking_item['tracking_provider'] : $tracking_item['custom_tracking_provider'];
|
181 |
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
182 |
|
183 |
-
$results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM
|
184 |
|
185 |
$provider_name = apply_filters('get_ast_provider_name', $tracking_provider, $results);
|
186 |
|
187 |
$formatted = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
188 |
-
|
189 |
-
if($
|
190 |
printf(
|
191 |
'<li id="tracking-item-%s" class="tracking-item-%s"><div><b>%s</b></div><a href="%s" target="_blank" class=ft11>%s</a><a class="inline_tracking_delete" rel="%s" data-order="%s"><span class="dashicons dashicons-trash"></span></a></li>',
|
192 |
esc_attr( $tracking_item['tracking_id'] ),
|
193 |
esc_attr( $tracking_item['tracking_id'] ),
|
194 |
-
$provider_name,
|
195 |
-
esc_url( $
|
196 |
esc_html( $tracking_item['tracking_number'] ),
|
197 |
esc_attr( $tracking_item['tracking_id'] ),
|
198 |
esc_attr( $order_id )
|
199 |
);
|
200 |
-
} else{
|
201 |
printf(
|
202 |
'<li id="tracking-item-%s" class="tracking-item-%s"><div><b>%s</b></div>%s<a class="inline_tracking_delete" rel="%s" data-order="%s"><span class="dashicons dashicons-trash"></span></a></li>',
|
203 |
esc_attr( $tracking_item['tracking_id'] ),
|
204 |
esc_attr( $tracking_item['tracking_id'] ),
|
205 |
-
$provider_name,
|
206 |
esc_html( $tracking_item['tracking_number'] ),
|
207 |
esc_attr( $tracking_item['tracking_id'] ),
|
208 |
esc_attr( $order_id )
|
@@ -227,45 +223,45 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
227 |
* Returns a HTML node for a tracking item for the admin meta box
|
228 |
*/
|
229 |
public function display_html_tracking_item_for_meta_box( $order_id, $item ) {
|
230 |
-
|
231 |
global $wpdb;
|
232 |
-
$tracking_provider = isset( $item['tracking_provider'] ) ? $item['tracking_provider'] : $item['custom_tracking_provider'];
|
233 |
-
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
234 |
|
235 |
-
$
|
236 |
-
|
237 |
-
$
|
|
|
|
|
238 |
?>
|
239 |
<div class="tracking-item" id="tracking-item-<?php echo esc_attr( $item['tracking_id'] ); ?>">
|
240 |
<div class="tracking-content">
|
241 |
<div class="tracking-content-div">
|
242 |
<strong><?php echo esc_html( $provider_name ); ?></strong>
|
243 |
-
<?php if ( strlen( $formatted['
|
244 |
-
- <?php
|
245 |
-
|
246 |
-
|
247 |
-
<?php } else{ ?>
|
248 |
<span> - <?php echo $item['tracking_number']; ?></span>
|
249 |
<?php } ?>
|
250 |
</div>
|
251 |
-
<?php
|
252 |
-
do_action('
|
|
|
|
|
253 |
</div>
|
254 |
<p class="meta">
|
255 |
<?php /* translators: 1: shipping date */ ?>
|
256 |
<?php echo esc_html( sprintf( __( 'Shipped on %s', 'woo-advanced-shipment-tracking' ), date_i18n( get_option( 'date_format' ), $item['date_shipped'] ) ) ); ?>
|
257 |
-
<a href="#" class="delete-tracking" rel="<?php echo esc_attr( $item['tracking_id'] ); ?>"><?php
|
258 |
</p>
|
259 |
</div>
|
260 |
-
|
261 |
}
|
262 |
|
263 |
/**
|
264 |
* Show the meta box for shipment info on the order page
|
265 |
*/
|
266 |
public function meta_box() {
|
267 |
-
global $post;
|
268 |
-
global $wpdb;
|
269 |
|
270 |
$order = wc_get_order( $post->ID );
|
271 |
$order_status = $order->get_status();
|
@@ -273,87 +269,75 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
273 |
$WC_Countries = new WC_Countries();
|
274 |
$countries = $WC_Countries->get_countries();
|
275 |
|
276 |
-
$woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
|
277 |
-
|
278 |
-
if( is_multisite() ){
|
279 |
-
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
280 |
-
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
281 |
-
}
|
282 |
-
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
283 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
284 |
-
$woo_shippment_table_name = $main_blog_prefix."woo_shippment_provider";
|
285 |
-
} else{
|
286 |
-
$woo_shippment_table_name = $wpdb->prefix."woo_shippment_provider";
|
287 |
-
}
|
288 |
-
} else{
|
289 |
-
$woo_shippment_table_name = $wpdb->prefix."woo_shippment_provider";
|
290 |
-
}
|
291 |
-
|
292 |
$tracking_items = $this->get_tracking_items( $post->ID );
|
293 |
|
294 |
-
$shippment_countries = $wpdb->get_results( "SELECT shipping_country FROM $
|
295 |
|
296 |
-
$shippment_providers = $wpdb->get_results( "SELECT * FROM $
|
297 |
|
298 |
-
$default_provider = get_option(
|
299 |
-
$wc_ast_default_mark_shipped = get_option(
|
300 |
-
$wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
|
301 |
$value = 1;
|
302 |
$cbvalue = '';
|
303 |
-
|
304 |
-
|
|
|
305 |
$cbvalue = 'change_order_to_shipped';
|
306 |
-
} else
|
|
|
307 |
$cbvalue = 1;
|
308 |
}
|
309 |
}
|
310 |
|
311 |
-
$wc_ast_status_shipped = get_option('wc_ast_status_shipped');
|
312 |
-
|
|
|
313 |
$change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
|
314 |
$shipped_label = 'Shipped';
|
315 |
-
} else{
|
316 |
$change_order_status_label = __( 'Mark as Completed?', 'woo-advanced-shipment-tracking' );
|
317 |
$shipped_label = 'Completed';
|
318 |
}
|
319 |
|
320 |
echo '<div id="tracking-items">';
|
321 |
-
|
322 |
-
|
323 |
-
|
|
|
324 |
}
|
325 |
-
}
|
326 |
echo '</div>';
|
327 |
|
328 |
-
|
329 |
|
330 |
-
echo '<div id="advanced-shipment-tracking-form">';
|
331 |
-
|
332 |
-
<
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
338 |
echo '<option value="">'.__( 'Select Provider', 'woo-advanced-shipment-tracking' ).'</option>';
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
echo '<optgroup label="' . $country_name . '">';
|
346 |
-
$country = $s_c->shipping_country;
|
347 |
-
$shippment_providers_by_country = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE shipping_country = '$country' AND display_in_order = 1" );
|
348 |
-
foreach ( $shippment_providers_by_country as $providers ) {
|
349 |
-
//echo '<pre>';print_r($providers);echo '</pre>';
|
350 |
-
$selected = ( $default_provider == esc_attr( $providers->ts_slug ) ) ? 'selected' : '';
|
351 |
-
echo '<option value="' . esc_attr( $providers->ts_slug ) . '" '.$selected. '>' . esc_html( $providers->provider_name ) . '</option>';
|
352 |
}
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
woocommerce_wp_hidden_input( array(
|
359 |
'id' => 'wc_shipment_tracking_get_nonce',
|
@@ -387,38 +371,21 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
387 |
'value' => date_i18n( __( 'Y-m-d', 'woo-advanced-shipment-tracking' ), current_time( 'timestamp' ) ),
|
388 |
) );
|
389 |
|
390 |
-
do_action(
|
391 |
-
do_action(
|
392 |
-
|
393 |
-
if(
|
394 |
-
|
395 |
-
?>
|
396 |
-
<fieldset class="form-field change_order_to_shipped_field" style="margin-bottom: 10px;">
|
397 |
-
<span><?php _e( 'Mark order as:', 'woo-advanced-shipment-tracking'); ?></span>
|
398 |
-
<ul class="wc-radios">
|
399 |
-
<li><label><input name="change_order_to_shipped" value="change_order_to_shipped" type="checkbox" class="select short mark_shipped_checkbox" <?php if($wc_ast_default_mark_shipped == 1){ echo 'checked'; }?>><?php _e( $shipped_label, 'woo-advanced-shipment-tracking'); ?></label></li>
|
400 |
-
<li><label><input name="change_order_to_shipped" value="change_order_to_partial_shipped" type="checkbox" class="select short mark_shipped_checkbox"><?php _e( 'Partial Shipped', 'woo-advanced-shipment-tracking'); ?></label></li>
|
401 |
-
</ul>
|
402 |
-
</fieldset>
|
403 |
-
<?php
|
404 |
-
} else{
|
405 |
-
woocommerce_wp_checkbox( array(
|
406 |
-
'id' => 'change_order_to_shipped',
|
407 |
-
'label' => __( $change_order_status_label, 'woo-advanced-shipment-tracking' ),
|
408 |
-
'description' => '',
|
409 |
-
'cbvalue' => $cbvalue,
|
410 |
-
'value' => $value,
|
411 |
-
) );
|
412 |
-
}
|
413 |
}
|
414 |
|
415 |
-
if(
|
416 |
-
echo '<button class="button button-primary
|
417 |
}
|
418 |
|
419 |
echo '<p class="preview_tracking_link">' . __( 'Preview:', 'woo-advanced-shipment-tracking' ) . ' <a href="" target="_blank">' . __( 'Track Shipment', 'woo-advanced-shipment-tracking' ) . '</a></p>';
|
420 |
|
421 |
echo '</div>';
|
|
|
422 |
$provider_array = array();
|
423 |
|
424 |
foreach ( $shippment_providers as $provider ) {
|
@@ -476,17 +443,75 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
476 |
wp_enqueue_script( 'woocommerce-advanced-shipment-tracking-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/admin.js' );
|
477 |
?>
|
478 |
<script>
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
</script>
|
488 |
<?php
|
489 |
-
do_action(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
}
|
491 |
|
492 |
/**
|
@@ -495,6 +520,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
495 |
* Function for getting all tracking items associated with the order
|
496 |
*/
|
497 |
public function get_meta_box_items_ajax() {
|
|
|
498 |
check_ajax_referer( 'get-tracking-item', 'security', true );
|
499 |
|
500 |
$order_id = wc_clean( $_POST['order_id'] );
|
@@ -503,30 +529,27 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
503 |
foreach ( $tracking_items as $tracking_item ) {
|
504 |
$this->display_html_tracking_item_for_meta_box( $order_id, $tracking_item );
|
505 |
}
|
506 |
-
|
507 |
die();
|
508 |
}
|
509 |
|
510 |
/**
|
511 |
* Get shipping provider custom name or name
|
512 |
*/
|
513 |
-
public function get_ast_provider_name_callback( $
|
514 |
-
|
515 |
-
if(!empty($results)){
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
}
|
521 |
-
}
|
522 |
-
return $provider_name;
|
523 |
}
|
524 |
|
525 |
/**
|
526 |
* Get shipping provider image src
|
527 |
*/
|
528 |
-
public function get_shipping_provdider_src_callback($results){
|
529 |
-
|
|
|
530 |
|
531 |
$upload_dir = wp_upload_dir();
|
532 |
$ast_directory = $upload_dir['baseurl'] . '/ast-shipping-providers/';
|
@@ -534,18 +557,18 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
534 |
|
535 |
$custom_thumb_id = $results->custom_thumb_id;
|
536 |
|
537 |
-
if($custom_thumb_id == 0 && $results->shipping_default
|
538 |
-
$src = $ast_directory.''.sanitize_title($results->provider_name).'.png?v='.wc_advanced_shipment_tracking()->version;
|
539 |
-
} else{
|
540 |
$image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
|
541 |
-
if($image_attributes[0]){
|
542 |
$src = $image_attributes[0];
|
543 |
-
} else{
|
544 |
-
$src = wc_advanced_shipment_tracking()->plugin_dir_url().
|
545 |
-
}
|
546 |
-
}
|
547 |
-
} else{
|
548 |
-
$src = wc_advanced_shipment_tracking()->plugin_dir_url().
|
549 |
}
|
550 |
return $src;
|
551 |
}
|
@@ -556,38 +579,26 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
556 |
* Function for saving tracking items
|
557 |
*/
|
558 |
public function save_meta_box( $post_id, $post ) {
|
559 |
-
if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider']
|
560 |
|
561 |
-
$tracking_product_code = isset($_POST['tracking_product_code']) ? $_POST['tracking_product_code'] :
|
562 |
$order = new WC_Order($post_id);
|
563 |
|
564 |
$args = array(
|
565 |
-
'tracking_provider' => wc_clean($_POST['tracking_provider']),
|
566 |
'tracking_number' => wc_clean( $_POST['tracking_number'] ),
|
567 |
-
'tracking_product_code' => wc_clean($tracking_product_code),
|
568 |
'date_shipped' => wc_clean( $_POST['date_shipped'] ),
|
569 |
);
|
570 |
|
571 |
$args = apply_filters( 'tracking_info_args', $args, $_POST, $post_id );
|
572 |
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
} else{
|
580 |
-
$order->update_status('completed');
|
581 |
-
}
|
582 |
-
} elseif($_POST['change_order_to_shipped'] == 'change_order_to_partial_shipped'){
|
583 |
-
$previous_order_status = $order->get_status();
|
584 |
-
|
585 |
-
if('partial-shipped' == $previous_order_status){
|
586 |
-
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $post_id, $order );
|
587 |
-
}
|
588 |
-
$order->update_status('partial-shipped');
|
589 |
-
do_action("send_order_to_trackship", $post_id);
|
590 |
-
}
|
591 |
}
|
592 |
}
|
593 |
|
@@ -601,41 +612,32 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
601 |
|
602 |
$tracking_number = str_replace(' ', '', $_POST['tracking_number']);
|
603 |
|
604 |
-
if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider']
|
605 |
|
606 |
$order_id = wc_clean( $_POST['order_id'] );
|
607 |
-
$order = new WC_Order($order_id);
|
608 |
-
$tracking_product_code = isset($_POST['tracking_product_code']) ? $_POST['tracking_product_code'] :
|
609 |
|
610 |
$args = array(
|
611 |
-
'tracking_provider' => wc_clean($_POST['tracking_provider']),
|
612 |
'tracking_number' => wc_clean( $_POST['tracking_number'] ),
|
613 |
-
'tracking_product_code' => wc_clean($tracking_product_code),
|
614 |
'date_shipped' => wc_clean( $_POST['date_shipped'] ),
|
615 |
);
|
616 |
|
617 |
$args = apply_filters( 'tracking_info_args', $args, $_POST, $order_id );
|
618 |
|
619 |
-
|
|
|
|
|
|
|
|
|
620 |
|
621 |
-
|
622 |
-
if('completed' == $order->get_status()){
|
623 |
-
WC()->mailer()->emails['WC_Email_Customer_Completed_Order']->trigger( $order_id, $order );
|
624 |
-
do_action("send_order_to_trackship", $order_id);
|
625 |
-
} else{
|
626 |
-
$order->update_status('completed');
|
627 |
-
}
|
628 |
-
} elseif($_POST['change_order_to_shipped'] == 'change_order_to_partial_shipped'){
|
629 |
-
$previous_order_status = $order->get_status();
|
630 |
-
|
631 |
-
if('partial-shipped' == $previous_order_status){
|
632 |
-
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
|
633 |
-
}
|
634 |
-
$order->update_status('partial-shipped');
|
635 |
-
do_action("send_order_to_trackship", $order_id);
|
636 |
-
}
|
637 |
|
638 |
-
|
|
|
|
|
639 |
echo 'reload';
|
640 |
die();
|
641 |
}
|
@@ -668,26 +670,16 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
668 |
|
669 |
$args = apply_filters( 'tracking_info_args', $args, $_POST, $order_id );
|
670 |
|
671 |
-
$
|
672 |
-
$order = new WC_Order($order_id);
|
673 |
|
674 |
-
|
|
|
|
|
|
|
|
|
675 |
|
676 |
-
|
677 |
-
|
678 |
-
WC()->mailer()->emails['WC_Email_Customer_Completed_Order']->trigger( $order_id, $order );
|
679 |
-
do_action("send_order_to_trackship", $order_id);
|
680 |
-
} else{
|
681 |
-
$order->update_status('completed');
|
682 |
-
}
|
683 |
-
} elseif($change_order_to_shipped == 'change_order_to_partial_shipped'){
|
684 |
-
$previous_order_status = $order->get_status();
|
685 |
-
if('partial-shipped' == $previous_order_status){
|
686 |
-
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
|
687 |
-
}
|
688 |
-
$order->update_status('partial-shipped');
|
689 |
-
do_action("send_order_to_trackship", $order_id);
|
690 |
-
}
|
691 |
}
|
692 |
}
|
693 |
|
@@ -702,22 +694,22 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
702 |
$tracking_id = wc_clean( $_POST['tracking_id'] );
|
703 |
$tracking_items = $this->get_tracking_items( $order_id, true );
|
704 |
|
705 |
-
do_action('delete_tracking_number_from_trackship', $tracking_items, $tracking_id, $order_id );
|
706 |
|
707 |
-
foreach($tracking_items as $tracking_item){
|
708 |
-
if($tracking_item['tracking_id'] == $_POST['tracking_id']){
|
709 |
$formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
710 |
-
|
711 |
$tracking_number = $tracking_item['tracking_number'];
|
712 |
$tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
|
713 |
$order = wc_get_order( $order_id );
|
714 |
// The text for the note
|
715 |
-
$note = sprintf(__(
|
716 |
|
717 |
// Add the note
|
718 |
$order->add_order_note( $note );
|
719 |
}
|
720 |
}
|
|
|
721 |
$this->delete_tracking_item( $order_id, $tracking_id );
|
722 |
}
|
723 |
|
@@ -732,9 +724,11 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
732 |
|
733 |
$local_template = get_stylesheet_directory().'/woocommerce/myaccount/tracking-info.php';
|
734 |
|
735 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
736 |
wc_get_template( 'myaccount/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id' => $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
737 |
-
}
|
|
|
|
|
738 |
wc_get_template( 'myaccount/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id' => $order_id ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
739 |
}
|
740 |
}
|
@@ -745,7 +739,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
745 |
* @param string[] $columns the columns in the orders table
|
746 |
* @return string[] updated columns
|
747 |
*/
|
748 |
-
public function add_column_my_account_orders( $columns ){
|
749 |
|
750 |
$new_columns = array();
|
751 |
foreach ( $columns as $key => $name ) {
|
@@ -770,14 +764,20 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
770 |
|
771 |
$order_id = $order->get_id();
|
772 |
$tracking_items = $this->get_tracking_items( $order_id, true );
|
773 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
774 |
-
$use_tracking_page = get_option('wc_ast_use_tracking_page');
|
775 |
-
$display_track_in_my_account = get_option('display_track_in_my_account',0);
|
776 |
-
$open_track_in_new_tab = get_option('open_track_in_new_tab',0);
|
777 |
-
|
778 |
-
if(
|
779 |
-
|
780 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
781 |
$actions['ast_multi_track'] = array(
|
782 |
// adjust URL as needed
|
783 |
'url' => $order->get_view_order_url(),
|
@@ -786,20 +786,21 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
786 |
return $actions;
|
787 |
}
|
788 |
|
789 |
-
if(
|
|
|
790 |
<script>
|
791 |
jQuery( document ).ready(function() {
|
792 |
jQuery('.ast_track').attr("target","_blank");
|
793 |
});
|
794 |
</script>
|
795 |
-
<?php
|
|
|
796 |
|
797 |
$actions['ast_track'] = array(
|
798 |
// adjust URL as needed
|
799 |
-
'url' => $tracking_items[0]['
|
800 |
'name' => __( 'Track', 'woo-advanced-shipment-tracking' ),
|
801 |
-
);
|
802 |
-
|
803 |
return $actions;
|
804 |
}
|
805 |
|
@@ -815,61 +816,68 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
815 |
*/
|
816 |
public function email_display( $order, $sent_to_admin, $plain_text = null, $email = null ) {
|
817 |
|
|
|
818 |
|
819 |
-
$
|
820 |
-
|
821 |
-
$order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;
|
822 |
|
823 |
-
|
824 |
-
$preview = true;
|
825 |
-
} else{
|
826 |
-
$preview = false;
|
827 |
-
}
|
828 |
|
829 |
-
$local_template = get_stylesheet_directory().'/woocommerce/emails/tracking-info.php';
|
830 |
|
831 |
$order = wc_get_order( $order_id );
|
832 |
|
833 |
-
if( $preview && $order_id
|
834 |
|
835 |
$tracking_items[] = array(
|
836 |
-
'tracking_provider'
|
837 |
-
'custom_tracking_provider'
|
838 |
-
'formatted_tracking_provider'
|
839 |
-
'formatted_tracking_link'
|
840 |
-
'
|
841 |
-
'
|
|
|
842 |
);
|
843 |
|
844 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
845 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $tracking_items, 'order_id'=> 1 ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
846 |
-
} else{
|
847 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $tracking_items, 'order_id'=> 1 ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
848 |
}
|
849 |
|
850 |
-
} else if($order){
|
851 |
$order_status = $order->get_status();
|
852 |
|
853 |
-
if ( is_a( $email, 'WC_Email_Customer_Invoice' ) && isset($wc_ast_unclude_tracking_info['show_in_customer_invoice']) && $wc_ast_unclude_tracking_info['show_in_customer_invoice']
|
|
|
|
|
854 |
|
855 |
-
if ( is_a( $email, 'WC_Email_Customer_Note' ) && isset($wc_ast_unclude_tracking_info['show_in_customer_note']) && $wc_ast_unclude_tracking_info['show_in_customer_note']
|
|
|
|
|
856 |
|
857 |
-
if(isset($wc_ast_unclude_tracking_info[$order_status]) && $wc_ast_unclude_tracking_info[$order_status]
|
|
|
|
|
858 |
|
859 |
-
if ( is_a( $email, 'WC_Email_Customer_Refunded_Order' ) && isset($wc_ast_unclude_tracking_info['refunded']) && $wc_ast_unclude_tracking_info['refunded']
|
|
|
|
|
860 |
|
861 |
$tracking_items = $this->get_tracking_items( $order_id, true );
|
862 |
|
863 |
if ( true === $plain_text ) {
|
864 |
-
|
|
|
865 |
wc_get_template( 'emails/plain/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
866 |
-
} else{
|
867 |
wc_get_template( 'emails/plain/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
868 |
}
|
869 |
} else {
|
870 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
871 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
872 |
-
}
|
|
|
|
|
873 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
874 |
}
|
875 |
}
|
@@ -890,24 +898,18 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
890 |
*/
|
891 |
public function get_formatted_tracking_item( $order_id, $tracking_item ) {
|
892 |
$formatted = array();
|
893 |
-
$tracking_items
|
894 |
$trackship_supported = '';
|
895 |
|
896 |
-
foreach($tracking_items as $key
|
897 |
-
if($item['tracking_id'] == $tracking_item['tracking_id']){
|
898 |
$shipmet_key = $key;
|
899 |
}
|
900 |
}
|
901 |
|
902 |
-
$shipment_status = get_post_meta( $order_id,
|
903 |
|
904 |
-
$status = '';
|
905 |
-
|
906 |
-
if(isset($shipment_status[$shipmet_key])){
|
907 |
-
if(isset($shipment_status[$shipmet_key]['status'])){
|
908 |
-
$status = $shipment_status[$shipmet_key]['status'];
|
909 |
-
}
|
910 |
-
}
|
911 |
|
912 |
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
913 |
$postcode = get_post_meta( $order_id, '_shipping_postcode', true );
|
@@ -924,118 +926,129 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
924 |
}
|
925 |
|
926 |
$tracking_provider = isset( $tracking_item['tracking_provider'] ) ? $tracking_item['tracking_provider'] : $tracking_item['custom_tracking_provider'];
|
927 |
-
$tracking_provider = apply_filters('convert_provider_name_to_slug'
|
928 |
$tracking_item['tracking_provider'] = $tracking_provider;
|
929 |
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
|
940 |
-
|
941 |
-
|
942 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
943 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
944 |
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
$order_key = $order->get_order_key();
|
953 |
-
if($tracking_page == 'other'){
|
954 |
-
$trackship_other_page = get_option('wc_ast_trackship_other_page');
|
955 |
-
$formatted['formatted_tracking_link'] = add_query_arg( array(
|
956 |
-
'order_id' => $order_id,
|
957 |
-
'order_key' => $order_key,
|
958 |
-
), $trackship_other_page );
|
959 |
-
|
960 |
-
} else{
|
961 |
-
$formatted['formatted_tracking_link'] = add_query_arg( array(
|
962 |
-
'order_id' => $order_id,
|
963 |
-
'order_key' => $order_key,
|
964 |
-
), get_permalink( $tracking_page ) );
|
965 |
}
|
966 |
|
967 |
-
|
968 |
-
|
969 |
-
$searchVal = array("%number%", str_replace(' ', '', "%2 $ s") );
|
970 |
-
$tracking_number = str_replace(' ', '', $tracking_item['tracking_number']);
|
971 |
-
$replaceVal = array( $tracking_number, urlencode( $postcode ) );
|
972 |
-
$link_format = str_replace($searchVal, $replaceVal, $link_format);
|
973 |
-
|
974 |
-
if(isset($tracking_item['tracking_product_code'])){
|
975 |
-
$searchnumber2 = array("%number2%", str_replace(' ', '', "%2 $ s") );
|
976 |
-
$tracking_product_code = str_replace(' ', '', $tracking_item['tracking_product_code']);
|
977 |
-
$link_format = str_replace($searchnumber2, $tracking_product_code, $link_format);
|
978 |
-
}
|
979 |
-
|
980 |
-
if($order->get_shipping_country() != null){
|
981 |
-
$shipping_country = $order->get_shipping_country();
|
982 |
-
} else{
|
983 |
-
$shipping_country = $order->get_billing_country();
|
984 |
-
}
|
985 |
-
|
986 |
-
if($shipping_country){
|
987 |
-
|
988 |
-
if($tracking_item['tracking_provider'] == 'jp-post' && $shipping_country != 'JP'){
|
989 |
-
$local_en = '&locale=en';
|
990 |
-
$link_format = $link_format.$local_en;
|
991 |
-
}
|
992 |
-
|
993 |
-
if($tracking_item['tracking_provider'] == 'dhl-ecommerce'){
|
994 |
-
$link_format = str_replace('us-en', strtolower($shipping_country).'-en', $link_format);
|
995 |
-
}
|
996 |
-
|
997 |
-
if($tracking_item['tracking_provider'] == 'dhl-freight'){
|
998 |
-
$link_format = str_replace('global-en', strtolower($shipping_country).'-en', $link_format);
|
999 |
-
}
|
1000 |
-
}
|
1001 |
-
|
1002 |
-
if($order->get_shipping_postcode() != null){
|
1003 |
-
$shipping_postal_code = $order->get_shipping_postcode();
|
1004 |
-
} else{
|
1005 |
-
$shipping_postal_code = $order->get_billing_postcode();
|
1006 |
-
}
|
1007 |
-
|
1008 |
-
$shipping_country = str_replace(' ', '', $shipping_country);
|
1009 |
-
$link_format = str_replace("%country_code%", $shipping_country, $link_format);
|
1010 |
-
|
1011 |
-
if($tracking_item['tracking_provider'] == 'apc-overnight'){
|
1012 |
-
$shipping_postal_code = str_replace(' ', '+', $shipping_postal_code);
|
1013 |
-
} else{
|
1014 |
-
$shipping_postal_code = str_replace(' ', '', $shipping_postal_code);
|
1015 |
-
}
|
1016 |
-
$link_format = str_replace("%postal_code%", $shipping_postal_code, $link_format);
|
1017 |
-
|
1018 |
-
$formatted['formatted_tracking_link'] = $link_format;
|
1019 |
-
} else{
|
1020 |
-
if(isset($tracking_item['custom_tracking_link']))$formatted['formatted_tracking_link'] = $tracking_item['custom_tracking_link'];
|
1021 |
}
|
1022 |
-
}
|
1023 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1024 |
return $formatted;
|
1025 |
}
|
1026 |
|
1027 |
-
public function check_ts_tracking_page_for_tracking_item( $order_id, $tracking_item, $status ){
|
1028 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
1029 |
-
$use_tracking_page = get_option('wc_ast_use_tracking_page');
|
|
|
1030 |
|
1031 |
foreach ( $this->get_providers() as $provider => $format ) {
|
1032 |
-
if ( $provider === $tracking_item['tracking_provider'] ) {
|
1033 |
-
$trackship_supported = $format['trackship_supported'];
|
1034 |
break;
|
1035 |
}
|
1036 |
}
|
1037 |
|
1038 |
-
if( $wc_ast_api_key && $use_tracking_page &&
|
|
|
|
|
1039 |
return false;
|
1040 |
}
|
1041 |
|
@@ -1057,13 +1070,19 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1057 |
if ( $item['tracking_id'] == $tracking_id ) {
|
1058 |
unset( $tracking_items[ $key ] );
|
1059 |
$is_deleted = true;
|
1060 |
-
do_action(
|
1061 |
break;
|
1062 |
}
|
1063 |
}
|
1064 |
$this->save_tracking_items( $order_id, $tracking_items );
|
1065 |
}
|
1066 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1067 |
return $is_deleted;
|
1068 |
}
|
1069 |
|
@@ -1078,50 +1097,29 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1078 |
public function add_tracking_item( $order_id, $args ) {
|
1079 |
$tracking_item = array();
|
1080 |
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
|
|
|
|
1084 |
|
1085 |
-
if(isset($args['
|
1086 |
-
$tracking_item['custom_tracking_provider'] = wc_clean( $args['tracking_provider'] );
|
1087 |
-
}
|
1088 |
-
if(isset($args['custom_tracking_link'])){
|
1089 |
-
$tracking_item['custom_tracking_link'] = wc_clean( $args['custom_tracking_link'] );
|
1090 |
-
}
|
1091 |
-
|
1092 |
-
if(isset($args['tracking_number'])){
|
1093 |
-
$tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
|
1094 |
-
}
|
1095 |
-
|
1096 |
-
if(isset($args['tracking_product_code'])){
|
1097 |
-
$tracking_item['tracking_product_code'] = wc_clean( $args['tracking_product_code'] );
|
1098 |
-
}
|
1099 |
-
|
1100 |
-
if(isset($args['date_shipped'])){
|
1101 |
$date = str_replace("/","-",$args['date_shipped']);
|
1102 |
$date = date_create($date);
|
1103 |
|
1104 |
-
if( isset($args['source']) && $args['source']
|
1105 |
-
$wc_ast_api_date_format = get_option('wc_ast_api_date_format','d-m-Y');
|
1106 |
$date = date_format( $date, $wc_ast_api_date_format );
|
1107 |
-
} else{
|
1108 |
$date = date_format($date,"d-m-Y");
|
1109 |
}
|
1110 |
|
1111 |
$tracking_item['date_shipped'] = wc_clean( strtotime( $date ) );
|
1112 |
}
|
1113 |
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
if(isset($args['status_shipped'])){
|
1119 |
-
$tracking_item['status_shipped'] = wc_clean( $args['status_shipped'] );
|
1120 |
-
}
|
1121 |
-
|
1122 |
-
if ( !isset($tracking_item['date_shipped']) ) {
|
1123 |
-
$tracking_item['date_shipped'] = time();
|
1124 |
-
}
|
1125 |
|
1126 |
if ( 0 == (int) $tracking_item['date_shipped'] ) {
|
1127 |
$tracking_item['date_shipped'] = time();
|
@@ -1139,55 +1137,19 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1139 |
|
1140 |
$tracking_items[] = $tracking_item;
|
1141 |
|
1142 |
-
$status_shipped = (isset($tracking_item[
|
1143 |
|
1144 |
$this->save_tracking_items( $order_id, $tracking_items );
|
1145 |
|
1146 |
$order = new WC_Order( $order_id );
|
1147 |
|
1148 |
-
|
1149 |
-
if('completed' == $order->get_status()){
|
1150 |
-
do_action("send_order_to_trackship", $order_id);
|
1151 |
-
} else{
|
1152 |
-
$order->update_status('completed');
|
1153 |
-
}
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
if( $status_shipped == 2){
|
1157 |
-
$wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
|
1158 |
-
if($wc_ast_status_partial_shipped){
|
1159 |
-
|
1160 |
-
$previous_order_status = $order->get_status();
|
1161 |
-
|
1162 |
-
if('partial-shipped' == $previous_order_status){
|
1163 |
-
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
$order->update_status('partial-shipped');
|
1167 |
-
do_action("send_order_to_trackship", $order_id);
|
1168 |
-
}
|
1169 |
-
}
|
1170 |
-
|
1171 |
-
if( $status_shipped == 3){
|
1172 |
-
$wc_ast_status_updated_tracking = get_option('wc_ast_status_updated_tracking');
|
1173 |
-
if($wc_ast_status_updated_tracking){
|
1174 |
-
|
1175 |
-
$previous_order_status = $order->get_status();
|
1176 |
-
|
1177 |
-
if('updated-tracking' == $previous_order_status){
|
1178 |
-
WC()->mailer()->emails['WC_Email_Customer_Updated_Tracking_Order']->trigger( $order_id, $order );
|
1179 |
-
}
|
1180 |
-
|
1181 |
-
$order->update_status('updated-tracking');
|
1182 |
-
do_action("send_order_to_trackship", $order_id);
|
1183 |
-
}
|
1184 |
-
}
|
1185 |
|
1186 |
$formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
1187 |
$tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
|
1188 |
|
1189 |
// The text for the note
|
1190 |
-
$note = sprintf(__("Order was shipped with %s and tracking number is: %s", 'woo-advanced-shipment-tracking'), $tracking_provider, $tracking_item['tracking_number'] );
|
1191 |
|
1192 |
// Add the note
|
1193 |
$order->add_order_note( $note );
|
@@ -1195,9 +1157,9 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1195 |
return $tracking_item;
|
1196 |
}
|
1197 |
|
1198 |
-
public function seach_tracking_number_in_items($tracking_number, $tracking_items){
|
1199 |
-
foreach ($tracking_items as $key => $val) {
|
1200 |
-
if ($val['tracking_number'] === $tracking_number) {
|
1201 |
return $key;
|
1202 |
}
|
1203 |
}
|
@@ -1219,25 +1181,26 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1219 |
$ast_admin = WC_Advanced_Shipment_Tracking_Admin::get_instance();
|
1220 |
$shippment_provider = $ast_admin->get_provider_slug_from_name( $tracking_provider );
|
1221 |
|
1222 |
-
if( $args['tracking_provider'] && !empty($shippment_provider)){
|
1223 |
$tracking_item['tracking_provider'] = wc_clean ( $shippment_provider );
|
1224 |
-
} else if($args['tracking_provider']){
|
1225 |
$tracking_item['tracking_provider'] = $args['tracking_provider'];
|
1226 |
}
|
1227 |
|
1228 |
-
if($args['tracking_number']){
|
1229 |
$tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
|
1230 |
}
|
1231 |
-
|
|
|
1232 |
$date = str_replace("/","-",$args['date_shipped']);
|
1233 |
$date = date_create($date);
|
1234 |
$date = date_format($date,"d-m-Y");
|
1235 |
|
1236 |
-
$tracking_item['date_shipped']
|
1237 |
}
|
1238 |
|
1239 |
-
if($args['status_shipped']){
|
1240 |
-
$tracking_item['status_shipped']
|
1241 |
}
|
1242 |
|
1243 |
if ( 0 == (int) $tracking_item['date_shipped'] ) {
|
@@ -1249,31 +1212,20 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1249 |
$tracking_items = $this->get_tracking_items( $order_id );
|
1250 |
$tracking_items[] = $tracking_item;
|
1251 |
|
1252 |
-
if($tracking_item['tracking_provider']){
|
1253 |
$this->save_tracking_items( $order_id, $tracking_items );
|
1254 |
|
1255 |
-
$status_shipped = (isset($tracking_item[
|
1256 |
|
1257 |
$order = new WC_Order( $order_id );
|
1258 |
|
1259 |
-
|
1260 |
-
if('completed' == $order->get_status()){
|
1261 |
-
do_action("send_order_to_trackship", $order_id);
|
1262 |
-
} else{
|
1263 |
-
$order->update_status('completed');
|
1264 |
-
}
|
1265 |
-
}
|
1266 |
-
|
1267 |
-
if( $status_shipped == 2){
|
1268 |
-
$order->update_status('partial-shipped');
|
1269 |
-
do_action("send_order_to_trackship", $order_id);
|
1270 |
-
}
|
1271 |
|
1272 |
$formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
1273 |
-
$tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
|
1274 |
|
1275 |
// The text for the note
|
1276 |
-
$note = sprintf(__(
|
1277 |
|
1278 |
// Add the note
|
1279 |
$order->add_order_note( $note );
|
@@ -1321,7 +1273,6 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1321 |
}
|
1322 |
}
|
1323 |
}
|
1324 |
-
|
1325 |
return null;
|
1326 |
}
|
1327 |
|
@@ -1339,10 +1290,10 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1339 |
|
1340 |
global $wpdb;
|
1341 |
$order = wc_get_order( $order_id );
|
1342 |
-
if($order){
|
1343 |
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
1344 |
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
|
1345 |
-
} else {
|
1346 |
$order = new WC_Order( $order_id );
|
1347 |
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
1348 |
}
|
@@ -1377,7 +1328,8 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1377 |
/**
|
1378 |
* validation code add tracking info form
|
1379 |
*/
|
1380 |
-
public function custom_validation_js(){
|
|
|
1381 |
<script>
|
1382 |
jQuery(document).on("click",".button-save-form",function(e){
|
1383 |
var error;
|
@@ -1413,13 +1365,14 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1413 |
/*
|
1414 |
* Get formated order id
|
1415 |
*/
|
1416 |
-
public function get_formated_order_id($order_id){
|
|
|
1417 |
if ( is_plugin_active( 'custom-order-numbers-for-woocommerce/custom-order-numbers-for-woocommerce.php' ) ) {
|
1418 |
-
$alg_wc_custom_order_numbers_enabled = get_option('alg_wc_custom_order_numbers_enabled');
|
1419 |
-
$alg_wc_custom_order_numbers_prefix
|
1420 |
-
$new_order_id = str_replace($alg_wc_custom_order_numbers_prefix,''
|
1421 |
|
1422 |
-
if(
|
1423 |
$args = array(
|
1424 |
'post_type' => 'shop_order',
|
1425 |
'posts_per_page' => '1',
|
@@ -1435,10 +1388,10 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1435 |
$posts = get_posts( $args );
|
1436 |
$my_query = new WP_Query( $args );
|
1437 |
|
1438 |
-
if( $my_query->have_posts() ) {
|
1439 |
-
while( $my_query->have_posts()) {
|
1440 |
$my_query->the_post();
|
1441 |
-
if(get_the_ID()){
|
1442 |
$order_id = get_the_ID();
|
1443 |
}
|
1444 |
} // end while
|
@@ -1446,42 +1399,12 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1446 |
$order_id;
|
1447 |
wp_reset_postdata();
|
1448 |
}
|
1449 |
-
}
|
1450 |
-
if ( is_plugin_active( 'custom-order-numbers-for-woocommerce-pro-master/custom-order-numbers-for-woocommerce-pro.php' ) ) {
|
1451 |
-
$offset = 0;
|
1452 |
-
$block_size = 512;
|
1453 |
-
while( true ) {
|
1454 |
-
$args = array(
|
1455 |
-
'post_type' => 'shop_order',
|
1456 |
-
'post_status' => 'any',
|
1457 |
-
'posts_per_page' => $block_size,
|
1458 |
-
'orderby' => 'date',
|
1459 |
-
'order' => 'DESC',
|
1460 |
-
'offset' => $offset,
|
1461 |
-
'fields' => 'ids',
|
1462 |
-
);
|
1463 |
-
$loop = new WP_Query( $args );
|
1464 |
-
if ( ! $loop->have_posts() ) {
|
1465 |
-
break;
|
1466 |
-
}
|
1467 |
-
foreach ( $loop->posts as $new_order_id ) {
|
1468 |
-
$_order = wc_get_order( $new_order_id );
|
1469 |
-
$Alg_WC = new Alg_WC_Custom_Order_Numbers_Core;
|
1470 |
-
$_order_number = $Alg_WC->display_order_number( $new_order_id, $_order );
|
1471 |
-
if ( $_order_number === $order_id ) {
|
1472 |
-
$order_id = $new_order_id;
|
1473 |
-
//echo $order_id;exit;
|
1474 |
-
break;
|
1475 |
-
}
|
1476 |
-
}
|
1477 |
-
$offset += $block_size;
|
1478 |
-
}
|
1479 |
-
}
|
1480 |
|
1481 |
if ( is_plugin_active( 'woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php' ) ) {
|
1482 |
|
1483 |
$s_order_id = wc_sequential_order_numbers()->find_order_by_order_number( $order_id );
|
1484 |
-
if($s_order_id){
|
1485 |
$order_id = $s_order_id;
|
1486 |
}
|
1487 |
}
|
@@ -1499,14 +1422,14 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1499 |
);
|
1500 |
|
1501 |
$posts = get_posts( $query_args );
|
1502 |
-
if(!
|
1503 |
list( $order_id ) = $posts;
|
1504 |
}
|
1505 |
}
|
1506 |
|
1507 |
if ( is_plugin_active( 'woocommerce-jetpack/woocommerce-jetpack.php' ) ) {
|
1508 |
|
1509 |
-
$wcj_order_numbers_enabled = get_option('wcj_order_numbers_enabled');
|
1510 |
// Get prefix and suffix options
|
1511 |
$prefix = do_shortcode( get_option( 'wcj_order_number_prefix', '' ) );
|
1512 |
$prefix .= date_i18n( get_option( 'wcj_order_number_date_prefix', '' ) );
|
@@ -1518,7 +1441,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1518 |
$search_no_suffix_and_prefix = preg_replace( "/{$suffix}\z/i", '', $search_no_suffix );
|
1519 |
$final_search = empty( $search_no_suffix_and_prefix ) ? $search : $search_no_suffix_and_prefix;
|
1520 |
|
1521 |
-
if(
|
1522 |
$query_args = array(
|
1523 |
'numberposts' => 1,
|
1524 |
'meta_key' => '_wcj_order_number',
|
@@ -1529,7 +1452,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1529 |
);
|
1530 |
|
1531 |
$posts = get_posts( $query_args );
|
1532 |
-
if(!
|
1533 |
list( $order_id ) = $posts;
|
1534 |
}
|
1535 |
}
|
@@ -1537,7 +1460,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1537 |
|
1538 |
if ( is_plugin_active( 'wp-lister-amazon/wp-lister-amazon.php' ) ) {
|
1539 |
$wpla_use_amazon_order_number = get_option( 'wpla_use_amazon_order_number' );
|
1540 |
-
if($wpla_use_amazon_order_number
|
1541 |
$query_args = array(
|
1542 |
'numberposts' => 1,
|
1543 |
'meta_key' => '_wpla_amazon_order_id',
|
@@ -1548,13 +1471,13 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1548 |
);
|
1549 |
|
1550 |
$posts = get_posts( $query_args );
|
1551 |
-
if(!
|
1552 |
list( $order_id ) = $posts;
|
1553 |
}
|
1554 |
}
|
1555 |
}
|
1556 |
|
1557 |
-
if ( is_plugin_active( 'wp-lister/wp-lister.php' ) || is_plugin_active( 'wp-lister-for-ebay/wp-lister.php' )) {
|
1558 |
$args = array(
|
1559 |
'post_type' => 'shop_order',
|
1560 |
'posts_per_page' => '1',
|
@@ -1571,13 +1494,14 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1571 |
),
|
1572 |
'post_status' => 'any',
|
1573 |
);
|
|
|
1574 |
$posts = get_posts( $args );
|
1575 |
$my_query = new WP_Query( $args );
|
1576 |
|
1577 |
-
if( $my_query->have_posts() ) {
|
1578 |
-
while( $my_query->have_posts()) {
|
1579 |
$my_query->the_post();
|
1580 |
-
if(get_the_ID()){
|
1581 |
$order_id = get_the_ID();
|
1582 |
}
|
1583 |
} // end while
|
@@ -1596,7 +1520,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1596 |
);
|
1597 |
|
1598 |
$posts = get_posts( $query_args );
|
1599 |
-
if(!
|
1600 |
list( $order_id ) = $posts;
|
1601 |
}
|
1602 |
}
|
@@ -1612,138 +1536,113 @@ class WC_Advanced_Shipment_Tracking_Actions {
|
|
1612 |
);
|
1613 |
|
1614 |
$posts = get_posts( $query_args );
|
1615 |
-
if(!
|
1616 |
list( $order_id ) = $posts;
|
1617 |
}
|
1618 |
}
|
1619 |
|
1620 |
-
return $order_id;
|
1621 |
-
}
|
1622 |
-
|
1623 |
-
/*
|
1624 |
-
* Get custom order number
|
1625 |
-
*/
|
1626 |
-
public function get_custom_order_number($order_id){
|
1627 |
-
if ( is_plugin_active( 'custom-order-numbers-for-woocommerce-pro-master/custom-order-numbers-for-woocommerce-pro.php' ) ) {
|
1628 |
-
$is_wc_version_below_3 = version_compare( get_option( 'woocommerce_version', null ), '3.0.0', '<' );
|
1629 |
-
|
1630 |
-
$order = wc_get_order( $order_id );
|
1631 |
-
|
1632 |
-
$order_number_meta = get_post_meta( $order_id, '_alg_wc_custom_order_number', true );
|
1633 |
-
|
1634 |
-
if ( '' == $order_number_meta || 'order_id' === get_option( 'alg_wc_custom_order_numbers_counter_type', 'sequential' ) ) {
|
1635 |
-
$order_number_meta = $order_id;
|
1636 |
-
}
|
1637 |
-
|
1638 |
-
$order_timestamp = strtotime( ( $is_wc_version_below_3 ? $order->order_date : $order->get_date_created() ) );
|
1639 |
-
|
1640 |
-
$custom_order_number = apply_filters( 'alg_wc_custom_order_numbers', sprintf( '%s%s', do_shortcode( get_option( 'alg_wc_custom_order_numbers_prefix', '' ) ), $order_number_meta ), 'value', array( 'order_timestamp' => $order_timestamp, 'order_number_meta' => $order_number_meta ) );
|
1641 |
-
|
1642 |
-
if(!empty($custom_order_number)){
|
1643 |
-
return $custom_order_number;
|
1644 |
-
}
|
1645 |
-
}
|
1646 |
-
|
1647 |
-
if ( is_plugin_active( 'custom-order-numbers-for-woocommerce/custom-order-numbers-for-woocommerce.php' ) ) {
|
1648 |
-
$custom_order_number = get_post_meta( $order_id, '_alg_wc_custom_order_number', true );
|
1649 |
-
if(!empty($custom_order_number)){
|
1650 |
-
return $custom_order_number;
|
1651 |
-
}
|
1652 |
-
}
|
1653 |
-
|
1654 |
-
if ( is_plugin_active( 'woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php' ) ) {
|
1655 |
-
$custom_order_number = get_post_meta( $order_id, '_order_number_formatted', true );
|
1656 |
-
if(!empty($custom_order_number)){
|
1657 |
-
return $custom_order_number;
|
1658 |
-
}
|
1659 |
-
}
|
1660 |
-
|
1661 |
-
if ( is_plugin_active( 'woocommerce-sequential-order-numbers-pro/woocommerce-sequential-order-numbers-pro.php' ) ) {
|
1662 |
-
$custom_order_number = get_post_meta( $order_id, '_order_number_formatted', true );
|
1663 |
-
if(!empty($custom_order_number)){
|
1664 |
-
return $custom_order_number;
|
1665 |
-
}
|
1666 |
-
}
|
1667 |
-
|
1668 |
-
if ( is_plugin_active( 'woocommerce-jetpack/woocommerce-jetpack.php' ) ) {
|
1669 |
-
$custom_order_number = get_post_meta( $order_id, '_wcj_order_number', true );
|
1670 |
-
$order = wc_get_order( $order_id );
|
1671 |
-
if(class_exists('WCJ_Order_Numbers')){
|
1672 |
-
$WCJ_Order_Numbers = new WCJ_Order_Numbers();
|
1673 |
-
$custom_order_number = $WCJ_Order_Numbers->display_order_number( $order_id, $order );
|
1674 |
-
if(!empty($custom_order_number)){
|
1675 |
-
return $custom_order_number;
|
1676 |
-
}
|
1677 |
-
}
|
1678 |
-
}
|
1679 |
-
|
1680 |
-
if ( is_plugin_active( 'wp-lister-amazon/wp-lister-amazon.php' ) ) {
|
1681 |
-
$custom_order_number = get_post_meta( $order_id, '_wpla_amazon_order_id', true );
|
1682 |
-
if(!empty($custom_order_number)){
|
1683 |
-
return $custom_order_number;
|
1684 |
-
}
|
1685 |
-
}
|
1686 |
-
|
1687 |
-
if ( is_plugin_active( 'wp-lister/wp-lister.php' ) || is_plugin_active( 'wp-lister-for-ebay/wp-lister.php' )) {
|
1688 |
-
$custom_order_number = get_post_meta( $order_id, '_ebay_extended_order_id', true );
|
1689 |
-
if(empty($custom_order_number)){
|
1690 |
-
$custom_order_number = get_post_meta( $order_id, '_ebay_order_id', true );
|
1691 |
-
}
|
1692 |
-
if(!empty($custom_order_number)){
|
1693 |
-
return $custom_order_number;
|
1694 |
-
}
|
1695 |
-
}
|
1696 |
-
|
1697 |
-
if ( is_plugin_active( 'yith-woocommerce-sequential-order-number-premium/init.php' ) ) {
|
1698 |
-
$custom_order_number = get_post_meta( $order_id, '_ywson_custom_number_order_complete', true );
|
1699 |
-
if(!empty($custom_order_number)){
|
1700 |
-
return $custom_order_number;
|
1701 |
-
}
|
1702 |
-
}
|
1703 |
-
|
1704 |
-
if ( is_plugin_active( 'wt-woocommerce-sequential-order-numbers/wt-advanced-order-number.php' ) ) {
|
1705 |
-
$custom_order_number = get_post_meta($order_id, '_order_number', TRUE);
|
1706 |
-
if(!empty($custom_order_number)){
|
1707 |
-
return $custom_order_number;
|
1708 |
-
}
|
1709 |
-
}
|
1710 |
-
|
1711 |
-
return $order_id;
|
1712 |
}
|
1713 |
|
1714 |
/*
|
1715 |
* Return option value for customizer
|
1716 |
*/
|
1717 |
-
public function get_option_value_from_array($array
|
1718 |
-
|
|
|
1719 |
$value = '';
|
1720 |
|
1721 |
-
if(isset($array_data[$key])){
|
1722 |
-
$value = $array_data[$key];
|
1723 |
-
if( $value
|
1724 |
return $value;
|
1725 |
-
}
|
1726 |
}
|
1727 |
-
|
|
|
1728 |
$value = $default_value;
|
1729 |
-
}
|
|
|
1730 |
return $value;
|
1731 |
}
|
1732 |
|
1733 |
/*
|
1734 |
* Return checkbox option value for customizer
|
1735 |
*/
|
1736 |
-
public function get_checkbox_option_value_from_array($array
|
1737 |
-
|
|
|
1738 |
$value = '';
|
1739 |
|
1740 |
-
if(isset($array_data[$key])){
|
1741 |
-
$value = $array_data[$key];
|
1742 |
return $value;
|
1743 |
}
|
1744 |
-
|
|
|
1745 |
$value = $default_value;
|
1746 |
-
}
|
|
|
1747 |
return $value;
|
1748 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1749 |
}
|
12 |
private static $instance;
|
13 |
|
14 |
public function __construct() {
|
15 |
+
|
16 |
global $wpdb;
|
17 |
+
if ( is_multisite() ) {
|
18 |
+
|
19 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
20 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
21 |
}
|
22 |
+
|
23 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
24 |
+
$main_blog_prefix = $wpdb->get_blog_prefix( BLOG_ID_CURRENT_SITE );
|
25 |
+
$this->table = $main_blog_prefix . 'woo_shippment_provider';
|
26 |
} else{
|
27 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
28 |
+
}
|
29 |
+
} else {
|
30 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
|
|
31 |
}
|
32 |
}
|
33 |
|
39 |
public static function get_instance() {
|
40 |
|
41 |
if ( null === self::$instance ) {
|
42 |
+
self::$instance = new self();
|
43 |
}
|
44 |
|
45 |
return self::$instance;
|
48 |
/**
|
49 |
* Get shipping providers from database
|
50 |
*/
|
51 |
+
public function get_providers() {
|
52 |
|
53 |
if ( empty( $this->providers ) ) {
|
54 |
$this->providers = array();
|
57 |
$wpdb->hide_errors();
|
58 |
$results = $wpdb->get_results( "SELECT * FROM {$this->table}" );
|
59 |
|
|
|
60 |
if ( ! empty( $results ) ) {
|
61 |
|
62 |
foreach ( $results as $row ) {
|
63 |
+
$provider_name = !empty( $row->custom_provider_name ) ? $row->custom_provider_name : $row->provider_name;
|
64 |
$shippment_providers[ $row->ts_slug ] = array(
|
65 |
+
'provider_name'=> $provider_name,
|
66 |
'provider_url' => $row->provider_url,
|
67 |
'trackship_supported' => $row->trackship_supported,
|
68 |
);
|
78 |
/**
|
79 |
* Get shipping providers from database for WooCommerce App
|
80 |
*/
|
81 |
+
public function get_providers_for_app() {
|
82 |
|
83 |
if ( empty( $this->providers_for_app ) ) {
|
84 |
$this->providers_for_app = array();
|
92 |
$results = $wpdb->get_results( "SELECT * FROM {$this->table} GROUP BY shipping_country" );
|
93 |
|
94 |
|
95 |
+
foreach ( $shippment_countries as $s_c ) {
|
96 |
|
97 |
+
$country_name = ( 'Global' != $s_c->shipping_country ) ? esc_attr( $WC_Countries->countries[ $s_c->shipping_country ] ) : 'Global';
|
|
|
|
|
|
|
|
|
98 |
$country = $s_c->shipping_country;
|
99 |
$shippment_providers_by_country = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$this->table} WHERE shipping_country = %s AND display_in_order = 1", $country ) );
|
100 |
|
101 |
$providers_array = array();
|
102 |
$new_provider = array();
|
103 |
+
|
104 |
foreach ( $shippment_providers_by_country as $providers ) {
|
105 |
$new_provider = array(
|
106 |
$providers->provider_name => $providers->provider_url,
|
107 |
);
|
108 |
+
$providers_array = array_merge( $providers_array, $new_provider );
|
|
|
109 |
}
|
110 |
+
|
111 |
$shippment_providers[ $country_name ] = $providers_array;
|
112 |
|
113 |
$this->providers_for_app = $shippment_providers;
|
122 |
*/
|
123 |
public function admin_styles() {
|
124 |
$plugin_url = wc_shipment_tracking()->plugin_url;
|
125 |
+
wp_enqueue_style( 'ast_styles', $plugin_url . '/assets/css/admin.css' );
|
|
|
126 |
}
|
127 |
|
128 |
/**
|
148 |
*/
|
149 |
public function render_shop_order_columns( $column ) {
|
150 |
global $post;
|
|
|
151 |
if ( 'woocommerce-advanced-shipment-tracking' === $column ) {
|
152 |
echo $this->get_shipment_tracking_column( $post->ID );
|
153 |
}
|
176 |
$tracking_provider = isset( $tracking_item['tracking_provider'] ) ? $tracking_item['tracking_provider'] : $tracking_item['custom_tracking_provider'];
|
177 |
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
178 |
|
179 |
+
$results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table WHERE ts_slug = %s", $tracking_provider ) );
|
180 |
|
181 |
$provider_name = apply_filters('get_ast_provider_name', $tracking_provider, $results);
|
182 |
|
183 |
$formatted = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
184 |
+
|
185 |
+
if( $formatted['ast_tracking_link'] ) {
|
186 |
printf(
|
187 |
'<li id="tracking-item-%s" class="tracking-item-%s"><div><b>%s</b></div><a href="%s" target="_blank" class=ft11>%s</a><a class="inline_tracking_delete" rel="%s" data-order="%s"><span class="dashicons dashicons-trash"></span></a></li>',
|
188 |
esc_attr( $tracking_item['tracking_id'] ),
|
189 |
esc_attr( $tracking_item['tracking_id'] ),
|
190 |
+
esc_html( $provider_name ),
|
191 |
+
esc_url( $formatted['ast_tracking_link'] ),
|
192 |
esc_html( $tracking_item['tracking_number'] ),
|
193 |
esc_attr( $tracking_item['tracking_id'] ),
|
194 |
esc_attr( $order_id )
|
195 |
);
|
196 |
+
} else {
|
197 |
printf(
|
198 |
'<li id="tracking-item-%s" class="tracking-item-%s"><div><b>%s</b></div>%s<a class="inline_tracking_delete" rel="%s" data-order="%s"><span class="dashicons dashicons-trash"></span></a></li>',
|
199 |
esc_attr( $tracking_item['tracking_id'] ),
|
200 |
esc_attr( $tracking_item['tracking_id'] ),
|
201 |
+
esc_html( $provider_name ),
|
202 |
esc_html( $tracking_item['tracking_number'] ),
|
203 |
esc_attr( $tracking_item['tracking_id'] ),
|
204 |
esc_attr( $order_id )
|
223 |
* Returns a HTML node for a tracking item for the admin meta box
|
224 |
*/
|
225 |
public function display_html_tracking_item_for_meta_box( $order_id, $item ) {
|
226 |
+
|
227 |
global $wpdb;
|
|
|
|
|
228 |
|
229 |
+
$formatted = $this->get_formatted_tracking_item( $order_id, $item );
|
230 |
+
$tracking_provider = isset( $item['tracking_provider'] ) ? $item['tracking_provider'] : $item['custom_tracking_provider'];
|
231 |
+
$tracking_provider = apply_filters( 'convert_provider_name_to_slug', $tracking_provider );
|
232 |
+
$results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table WHERE ts_slug = %s", $tracking_provider ) );
|
233 |
+
$provider_name = apply_filters( 'get_ast_provider_name', $tracking_provider, $results );
|
234 |
?>
|
235 |
<div class="tracking-item" id="tracking-item-<?php echo esc_attr( $item['tracking_id'] ); ?>">
|
236 |
<div class="tracking-content">
|
237 |
<div class="tracking-content-div">
|
238 |
<strong><?php echo esc_html( $provider_name ); ?></strong>
|
239 |
+
<?php if ( strlen( $formatted['ast_tracking_link'] ) > 0 ) { ?>
|
240 |
+
- <?php
|
241 |
+
echo sprintf( '<a href="%s" target="_blank" title="' . esc_attr( __( 'Track Shipment', 'woo-advanced-shipment-tracking' ) ) . '">' . __( $item['tracking_number'] ) . '</a>', esc_url( $formatted['ast_tracking_link'] ) ); ?>
|
242 |
+
<?php } else { ?>
|
|
|
243 |
<span> - <?php echo $item['tracking_number']; ?></span>
|
244 |
<?php } ?>
|
245 |
</div>
|
246 |
+
<?php
|
247 |
+
do_action( 'ast_after_tracking_number', $order_id, $item['tracking_id'] );
|
248 |
+
do_action( 'ast_shipment_tracking_end', $order_id, $item );
|
249 |
+
?>
|
250 |
</div>
|
251 |
<p class="meta">
|
252 |
<?php /* translators: 1: shipping date */ ?>
|
253 |
<?php echo esc_html( sprintf( __( 'Shipped on %s', 'woo-advanced-shipment-tracking' ), date_i18n( get_option( 'date_format' ), $item['date_shipped'] ) ) ); ?>
|
254 |
+
<a href="#" class="delete-tracking" rel="<?php echo esc_attr( $item['tracking_id'] ); ?>"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a>
|
255 |
</p>
|
256 |
</div>
|
257 |
+
<?php
|
258 |
}
|
259 |
|
260 |
/**
|
261 |
* Show the meta box for shipment info on the order page
|
262 |
*/
|
263 |
public function meta_box() {
|
264 |
+
global $post,$wpdb;
|
|
|
265 |
|
266 |
$order = wc_get_order( $post->ID );
|
267 |
$order_status = $order->get_status();
|
269 |
$WC_Countries = new WC_Countries();
|
270 |
$countries = $WC_Countries->get_countries();
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
$tracking_items = $this->get_tracking_items( $post->ID );
|
273 |
|
274 |
+
$shippment_countries = $wpdb->get_results( "SELECT shipping_country FROM $this->table WHERE display_in_order = 1 GROUP BY shipping_country" );
|
275 |
|
276 |
+
$shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table" );
|
277 |
|
278 |
+
$default_provider = get_option( 'wc_ast_default_provider' );
|
279 |
+
$wc_ast_default_mark_shipped = get_option( 'wc_ast_default_mark_shipped' );
|
280 |
+
$wc_ast_status_partial_shipped = get_option( 'wc_ast_status_partial_shipped' );
|
281 |
$value = 1;
|
282 |
$cbvalue = '';
|
283 |
+
|
284 |
+
if ( 1 == $wc_ast_default_mark_shipped ) {
|
285 |
+
if ( $wc_ast_status_partial_shipped ) {
|
286 |
$cbvalue = 'change_order_to_shipped';
|
287 |
+
} else
|
288 |
+
{
|
289 |
$cbvalue = 1;
|
290 |
}
|
291 |
}
|
292 |
|
293 |
+
$wc_ast_status_shipped = get_option( 'wc_ast_status_shipped' );
|
294 |
+
|
295 |
+
if ( 1 == $wc_ast_status_shipped ) {
|
296 |
$change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
|
297 |
$shipped_label = 'Shipped';
|
298 |
+
} else {
|
299 |
$change_order_status_label = __( 'Mark as Completed?', 'woo-advanced-shipment-tracking' );
|
300 |
$shipped_label = 'Completed';
|
301 |
}
|
302 |
|
303 |
echo '<div id="tracking-items">';
|
304 |
+
if ( count( $tracking_items ) > 0 ) {
|
305 |
+
foreach ( $tracking_items as $tracking_item ) {
|
306 |
+
$this->display_html_tracking_item_for_meta_box( $post->ID, $tracking_item );
|
307 |
+
}
|
308 |
}
|
|
|
309 |
echo '</div>';
|
310 |
|
311 |
+
do_action( 'ast_add_tracking_btn' );
|
312 |
|
313 |
+
echo '<div id="advanced-shipment-tracking-form">';
|
314 |
+
?>
|
315 |
+
<p class="form-field tracking_number_field ">
|
316 |
+
<label for="tracking_number"><?php _e( 'Tracking number:', 'woo-advanced-shipment-tracking'); ?></label>
|
317 |
+
<input type="text" class="short" style="" name="tracking_number" id="tracking_number" value="" autocomplete="off">
|
318 |
+
</p>
|
319 |
+
<?php
|
320 |
+
echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __( 'Shipping Provider:', 'woo-advanced-shipment-tracking' ) . '</label><br/><select id="tracking_provider" name="tracking_provider" class="chosen_select" style="width:100%;">';
|
321 |
+
|
322 |
echo '<option value="">'.__( 'Select Provider', 'woo-advanced-shipment-tracking' ).'</option>';
|
323 |
+
|
324 |
+
foreach($shippment_countries as $s_c){
|
325 |
+
if($s_c->shipping_country != 'Global'){
|
326 |
+
$country_name = esc_attr( $WC_Countries->countries[$s_c->shipping_country] );
|
327 |
+
} else{
|
328 |
+
$country_name = 'Global';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
}
|
330 |
+
echo '<optgroup label="' . $country_name . '">';
|
331 |
+
$country = $s_c->shipping_country;
|
332 |
+
$shippment_providers_by_country = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_country = '$country' AND display_in_order = 1" );
|
333 |
+
foreach ( $shippment_providers_by_country as $providers ) {
|
334 |
+
$selected = ( $default_provider == esc_attr( $providers->ts_slug ) ) ? 'selected' : '';
|
335 |
+
echo '<option value="' . esc_attr( $providers->ts_slug ) . '" '.$selected. '>' . esc_html( $providers->provider_name ) . '</option>';
|
336 |
+
}
|
337 |
+
echo '</optgroup>';
|
338 |
+
}
|
339 |
+
|
340 |
+
echo '</select> ';
|
341 |
|
342 |
woocommerce_wp_hidden_input( array(
|
343 |
'id' => 'wc_shipment_tracking_get_nonce',
|
371 |
'value' => date_i18n( __( 'Y-m-d', 'woo-advanced-shipment-tracking' ), current_time( 'timestamp' ) ),
|
372 |
) );
|
373 |
|
374 |
+
do_action( 'ast_after_tracking_field', $post->ID);
|
375 |
+
do_action( 'ast_tracking_form_between_form', $post->ID, 'single_order' );
|
376 |
+
|
377 |
+
if ( 'auto-draft' != $order_status ) {
|
378 |
+
wc_advanced_shipment_tracking()->actions->mark_order_as_fields_html();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
}
|
380 |
|
381 |
+
if ( 'auto-draft' != $order_status ) {
|
382 |
+
echo '<button class="button button-primary btn_ast2 button-save-form">' . __( 'Save Tracking', 'woo-advanced-shipment-tracking' ) . '</button>';
|
383 |
}
|
384 |
|
385 |
echo '<p class="preview_tracking_link">' . __( 'Preview:', 'woo-advanced-shipment-tracking' ) . ' <a href="" target="_blank">' . __( 'Track Shipment', 'woo-advanced-shipment-tracking' ) . '</a></p>';
|
386 |
|
387 |
echo '</div>';
|
388 |
+
|
389 |
$provider_array = array();
|
390 |
|
391 |
foreach ( $shippment_providers as $provider ) {
|
443 |
wp_enqueue_script( 'woocommerce-advanced-shipment-tracking-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/admin.js' );
|
444 |
?>
|
445 |
<script>
|
446 |
+
jQuery(document).on("change", "#tracking_provider", function(){
|
447 |
+
var selected_provider = jQuery(this).val();
|
448 |
+
if(selected_provider == 'nz-couriers' || selected_provider == 'post-haste' || selected_provider == 'castle-parcels' || selected_provider == 'dx-mail' || selected_provider == 'now-couriers'){
|
449 |
+
jQuery('.tracking_product_code_field').show();
|
450 |
+
} else{
|
451 |
+
jQuery('.tracking_product_code_field').hide();
|
452 |
+
}
|
453 |
+
});
|
454 |
</script>
|
455 |
<?php
|
456 |
+
do_action( 'ast_tracking_form_end_meta_box' );
|
457 |
+
}
|
458 |
+
|
459 |
+
/*
|
460 |
+
* Function for mark order as html
|
461 |
+
*/
|
462 |
+
public function mark_order_as_fields_html() {
|
463 |
+
|
464 |
+
$wc_ast_status_shipped = get_option( 'wc_ast_status_shipped', 0 );
|
465 |
+
$shipped_label = ( 1 == $wc_ast_status_shipped ) ? __( 'Shipped', 'woo-advanced-shipment-tracking' ) : __( 'Completed', 'woo-advanced-shipment-tracking' );
|
466 |
+
|
467 |
+
$wc_ast_default_mark_shipped = get_option( 'wc_ast_default_mark_shipped' );
|
468 |
+
$wc_ast_status_partial_shipped = get_option( 'wc_ast_status_partial_shipped' );
|
469 |
+
|
470 |
+
$order_status_array = apply_filters( 'mark_order_as_fields_data' , array(
|
471 |
+
'change_order_to_shipped' => array(
|
472 |
+
'name' => 'change_order_to_shipped',
|
473 |
+
'class' => 'mark_shipped_checkbox',
|
474 |
+
'label' => $shipped_label,
|
475 |
+
'checked' => ( 1 == $wc_ast_default_mark_shipped ) ? true : false,
|
476 |
+
'show' => true,
|
477 |
+
),
|
478 |
+
'change_order_to_partial_shipped' => array(
|
479 |
+
'name' => 'change_order_to_shipped',
|
480 |
+
'class' => 'mark_shipped_checkbox',
|
481 |
+
'label' => __( 'Partial Shipped', 'woo-advanced-shipment-tracking'),
|
482 |
+
'checked' => false,
|
483 |
+
'show' => ( 1 == $wc_ast_status_partial_shipped ) ? true : false
|
484 |
+
),
|
485 |
+
)
|
486 |
+
);
|
487 |
+
?>
|
488 |
+
|
489 |
+
<fieldset class="form-field change_order_to_shipped_field">
|
490 |
+
<span><?php esc_html_e( 'Mark order as:', 'woo-advanced-shipment-tracking'); ?></span>
|
491 |
+
<ul class="wc-radios">
|
492 |
+
<?php
|
493 |
+
foreach ( $order_status_array as $value => $data ) {
|
494 |
+
if ( isset( $data['show'] ) && $data['show'] == true ) {
|
495 |
+
?>
|
496 |
+
<li>
|
497 |
+
<label>
|
498 |
+
<input name="<?php esc_html_e( $data['name'] ); ?>" value="<?php esc_html_e( $value ); ?>" type="checkbox" class="select short mark_shipped_checkbox" <?php if ( $data['checked'] ) { echo 'checked'; } ?>><?php esc_html_e( $data['label'] ); ?>
|
499 |
+
</label>
|
500 |
+
</li>
|
501 |
+
<?php
|
502 |
+
}
|
503 |
+
}
|
504 |
+
?>
|
505 |
+
</ul>
|
506 |
+
</fieldset>
|
507 |
+
<?php
|
508 |
+
}
|
509 |
+
|
510 |
+
/*
|
511 |
+
* Function for add tracking button in order details page
|
512 |
+
*/
|
513 |
+
public function ast_add_tracking_btn() {
|
514 |
+
echo '<button class="button button-primary btn_ast2 btn_full button-show-tracking-form" type="button">' . __( 'Add Tracking Info', 'woo-advanced-shipment-tracking' ) . '</button>';
|
515 |
}
|
516 |
|
517 |
/**
|
520 |
* Function for getting all tracking items associated with the order
|
521 |
*/
|
522 |
public function get_meta_box_items_ajax() {
|
523 |
+
|
524 |
check_ajax_referer( 'get-tracking-item', 'security', true );
|
525 |
|
526 |
$order_id = wc_clean( $_POST['order_id'] );
|
529 |
foreach ( $tracking_items as $tracking_item ) {
|
530 |
$this->display_html_tracking_item_for_meta_box( $order_id, $tracking_item );
|
531 |
}
|
|
|
532 |
die();
|
533 |
}
|
534 |
|
535 |
/**
|
536 |
* Get shipping provider custom name or name
|
537 |
*/
|
538 |
+
public function get_ast_provider_name_callback( $provider_name, $results ) {
|
539 |
+
|
540 |
+
if ( !empty( $results ) ) {
|
541 |
+
$provider_name = ( null != $results->custom_provider_name ) ? $results->custom_provider_name : $results->provider_name;
|
542 |
+
}
|
543 |
+
|
544 |
+
return $provider_name;
|
|
|
|
|
|
|
545 |
}
|
546 |
|
547 |
/**
|
548 |
* Get shipping provider image src
|
549 |
*/
|
550 |
+
public function get_shipping_provdider_src_callback( $results ) {
|
551 |
+
|
552 |
+
if ( !empty( $results ) ) {
|
553 |
|
554 |
$upload_dir = wp_upload_dir();
|
555 |
$ast_directory = $upload_dir['baseurl'] . '/ast-shipping-providers/';
|
557 |
|
558 |
$custom_thumb_id = $results->custom_thumb_id;
|
559 |
|
560 |
+
if ( $custom_thumb_id == 0 && 1 == $results->shipping_default ) {
|
561 |
+
$src = $ast_directory . '' . sanitize_title( $results->provider_name ) . '.png?v=' . wc_advanced_shipment_tracking()->version;
|
562 |
+
} else {
|
563 |
$image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
|
564 |
+
if ( $image_attributes[0] ) {
|
565 |
$src = $image_attributes[0];
|
566 |
+
} else {
|
567 |
+
$src = wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/images/icon-default.png';
|
568 |
+
}
|
569 |
+
}
|
570 |
+
} else {
|
571 |
+
$src = wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/images/icon-default.png';
|
572 |
}
|
573 |
return $src;
|
574 |
}
|
579 |
* Function for saving tracking items
|
580 |
*/
|
581 |
public function save_meta_box( $post_id, $post ) {
|
582 |
+
if ( isset( $_POST['tracking_number'] ) && '' != $_POST['tracking_provider'] && isset( $_POST['tracking_provider'] ) && strlen( $_POST['tracking_number'] ) > 0 ) {
|
583 |
|
584 |
+
$tracking_product_code = isset( $_POST['tracking_product_code'] ) ? $_POST['tracking_product_code'] : '';
|
585 |
$order = new WC_Order($post_id);
|
586 |
|
587 |
$args = array(
|
588 |
+
'tracking_provider' => wc_clean( $_POST['tracking_provider'] ),
|
589 |
'tracking_number' => wc_clean( $_POST['tracking_number'] ),
|
590 |
+
'tracking_product_code' => wc_clean( $tracking_product_code ),
|
591 |
'date_shipped' => wc_clean( $_POST['date_shipped'] ),
|
592 |
);
|
593 |
|
594 |
$args = apply_filters( 'tracking_info_args', $args, $_POST, $post_id );
|
595 |
|
596 |
+
if ( 'change_order_to_shipped' == $_POST['change_order_to_shipped'] ) {
|
597 |
+
$args['status_shipped'] = 1;
|
598 |
+
} elseif ( 'change_order_to_partial_shipped' == $_POST['change_order_to_shipped'] ) {
|
599 |
+
$args['status_shipped'] = 2;
|
600 |
+
}
|
601 |
+
$this->add_tracking_item( $post_id, $args );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
}
|
603 |
}
|
604 |
|
612 |
|
613 |
$tracking_number = str_replace(' ', '', $_POST['tracking_number']);
|
614 |
|
615 |
+
if ( isset( $_POST['tracking_number'] ) && '' != $_POST['tracking_provider'] && isset( $_POST['tracking_provider'] ) && strlen( $_POST['tracking_number'] ) > 0 ) {
|
616 |
|
617 |
$order_id = wc_clean( $_POST['order_id'] );
|
618 |
+
$order = new WC_Order( $order_id );
|
619 |
+
$tracking_product_code = isset( $_POST['tracking_product_code'] ) ? $_POST['tracking_product_code'] : '';
|
620 |
|
621 |
$args = array(
|
622 |
+
'tracking_provider' => wc_clean( $_POST['tracking_provider'] ),
|
623 |
'tracking_number' => wc_clean( $_POST['tracking_number'] ),
|
624 |
+
'tracking_product_code' => wc_clean( $tracking_product_code ),
|
625 |
'date_shipped' => wc_clean( $_POST['date_shipped'] ),
|
626 |
);
|
627 |
|
628 |
$args = apply_filters( 'tracking_info_args', $args, $_POST, $order_id );
|
629 |
|
630 |
+
if ( 'change_order_to_shipped' == $_POST['change_order_to_shipped'] ) {
|
631 |
+
$args['status_shipped'] = 1;
|
632 |
+
} elseif ( 'change_order_to_partial_shipped' == $_POST['change_order_to_shipped'] ) {
|
633 |
+
$args['status_shipped'] = 2;
|
634 |
+
}
|
635 |
|
636 |
+
$tracking_item = $this->add_tracking_item( $order_id, $args );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
|
638 |
+
do_action( 'ast_save_tracking_details_end', $order_id, $_POST );
|
639 |
+
|
640 |
+
if( isset( $_POST['productlist'] ) && !empty( $_POST['productlist'] ) && $_POST['productlist'] != '[]' ) {
|
641 |
echo 'reload';
|
642 |
die();
|
643 |
}
|
670 |
|
671 |
$args = apply_filters( 'tracking_info_args', $args, $_POST, $order_id );
|
672 |
|
673 |
+
$change_order_to_shipped = isset( $_POST[ 'change_order_to_shipped' ] ) ? $_POST[ 'change_order_to_shipped' ] : '';
|
|
|
674 |
|
675 |
+
if ( 'change_order_to_shipped' == $change_order_to_shipped || 'yes' == $change_order_to_shipped ) {
|
676 |
+
$args['status_shipped'] = 1;
|
677 |
+
} elseif ( 'change_order_to_partial_shipped' == $change_order_to_shipped ) {
|
678 |
+
$args['status_shipped'] = 2;
|
679 |
+
}
|
680 |
|
681 |
+
$tracking_item = $this->add_tracking_item( $order_id, $args );
|
682 |
+
do_action( 'ast_save_tracking_details_end', $order_id, $_POST );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
}
|
684 |
}
|
685 |
|
694 |
$tracking_id = wc_clean( $_POST['tracking_id'] );
|
695 |
$tracking_items = $this->get_tracking_items( $order_id, true );
|
696 |
|
697 |
+
do_action( 'delete_tracking_number_from_trackship', $tracking_items, $tracking_id, $order_id );
|
698 |
|
699 |
+
foreach ( $tracking_items as $tracking_item ) {
|
700 |
+
if ( $tracking_item['tracking_id'] == $_POST['tracking_id'] ) {
|
701 |
$formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
|
|
702 |
$tracking_number = $tracking_item['tracking_number'];
|
703 |
$tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
|
704 |
$order = wc_get_order( $order_id );
|
705 |
// The text for the note
|
706 |
+
$note = sprintf( __( 'Tracking info was deleted for tracking provider %s with tracking number %s', 'woo-advanced-shipment-tracking' ), $tracking_provider, $tracking_number );
|
707 |
|
708 |
// Add the note
|
709 |
$order->add_order_note( $note );
|
710 |
}
|
711 |
}
|
712 |
+
|
713 |
$this->delete_tracking_item( $order_id, $tracking_id );
|
714 |
}
|
715 |
|
724 |
|
725 |
$local_template = get_stylesheet_directory().'/woocommerce/myaccount/tracking-info.php';
|
726 |
|
727 |
+
if ( file_exists( $local_template ) && is_writable( $local_template ) ) {
|
728 |
wc_get_template( 'myaccount/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id' => $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
729 |
+
} elseif ( class_exists('ast_pro') ) {
|
730 |
+
wc_get_template( 'myaccount/fluid-tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', ast_pro()->get_plugin_path() . '/templates/' );
|
731 |
+
} else {
|
732 |
wc_get_template( 'myaccount/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id' => $order_id ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
733 |
}
|
734 |
}
|
739 |
* @param string[] $columns the columns in the orders table
|
740 |
* @return string[] updated columns
|
741 |
*/
|
742 |
+
public function add_column_my_account_orders( $columns ) {
|
743 |
|
744 |
$new_columns = array();
|
745 |
foreach ( $columns as $key => $name ) {
|
764 |
|
765 |
$order_id = $order->get_id();
|
766 |
$tracking_items = $this->get_tracking_items( $order_id, true );
|
767 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
768 |
+
$use_tracking_page = get_option( 'wc_ast_use_tracking_page' );
|
769 |
+
$display_track_in_my_account = get_option( 'display_track_in_my_account', 0 );
|
770 |
+
$open_track_in_new_tab = get_option( 'open_track_in_new_tab', 0 );
|
771 |
+
|
772 |
+
if ( 1 != $display_track_in_my_account ) {
|
773 |
+
return $actions;
|
774 |
+
}
|
775 |
+
|
776 |
+
if ( 0 == count( $tracking_items ) ) {
|
777 |
+
return $actions;
|
778 |
+
}
|
779 |
+
|
780 |
+
if ( count( $tracking_items ) > 1 && ( !$wc_ast_api_key || !$use_tracking_page ) ) {
|
781 |
$actions['ast_multi_track'] = array(
|
782 |
// adjust URL as needed
|
783 |
'url' => $order->get_view_order_url(),
|
786 |
return $actions;
|
787 |
}
|
788 |
|
789 |
+
if ( 1 == $open_track_in_new_tab ) {
|
790 |
+
?>
|
791 |
<script>
|
792 |
jQuery( document ).ready(function() {
|
793 |
jQuery('.ast_track').attr("target","_blank");
|
794 |
});
|
795 |
</script>
|
796 |
+
<?php
|
797 |
+
}
|
798 |
|
799 |
$actions['ast_track'] = array(
|
800 |
// adjust URL as needed
|
801 |
+
'url' => $tracking_items[0][ 'ast_tracking_link' ],
|
802 |
'name' => __( 'Track', 'woo-advanced-shipment-tracking' ),
|
803 |
+
);
|
|
|
804 |
return $actions;
|
805 |
}
|
806 |
|
816 |
*/
|
817 |
public function email_display( $order, $sent_to_admin, $plain_text = null, $email = null ) {
|
818 |
|
819 |
+
$wc_ast_unclude_tracking_info = get_option( 'wc_ast_unclude_tracking_info' );
|
820 |
|
821 |
+
$order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;
|
|
|
|
|
822 |
|
823 |
+
$preview = ( isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview'] ) ? true : false;
|
|
|
|
|
|
|
|
|
824 |
|
825 |
+
$local_template = get_stylesheet_directory() . '/woocommerce/emails/tracking-info.php';
|
826 |
|
827 |
$order = wc_get_order( $order_id );
|
828 |
|
829 |
+
if ( $preview && 1 == $order_id ) {
|
830 |
|
831 |
$tracking_items[] = array(
|
832 |
+
'tracking_provider' => 'usps',
|
833 |
+
'custom_tracking_provider' => '',
|
834 |
+
'formatted_tracking_provider' => 'USPS',
|
835 |
+
'formatted_tracking_link' => 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=112123113',
|
836 |
+
'ast_tracking_link' => 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=112123113',
|
837 |
+
'tracking_number' => '112123113',
|
838 |
+
'date_shipped' => '2020-10-13',
|
839 |
);
|
840 |
|
841 |
+
if ( file_exists( $local_template ) && is_writable( $local_template ) ) {
|
842 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $tracking_items, 'order_id'=> 1 ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
843 |
+
} else {
|
844 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $tracking_items, 'order_id'=> 1 ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
845 |
}
|
846 |
|
847 |
+
} else if ( $order ) {
|
848 |
$order_status = $order->get_status();
|
849 |
|
850 |
+
if ( is_a( $email, 'WC_Email_Customer_Invoice' ) && isset( $wc_ast_unclude_tracking_info['show_in_customer_invoice'] ) && 0 == $wc_ast_unclude_tracking_info['show_in_customer_invoice'] ) {
|
851 |
+
return;
|
852 |
+
}
|
853 |
|
854 |
+
if ( is_a( $email, 'WC_Email_Customer_Note' ) && isset( $wc_ast_unclude_tracking_info['show_in_customer_note'] ) && 0 == $wc_ast_unclude_tracking_info['show_in_customer_note'] ) {
|
855 |
+
return;
|
856 |
+
}
|
857 |
|
858 |
+
if ( isset( $wc_ast_unclude_tracking_info[ $order_status ] ) && 0 == $wc_ast_unclude_tracking_info[ $order_status ] && !is_a( $email, 'WC_Email_Customer_Invoice' ) && !is_a( $email, 'WC_Email_Customer_Note' ) ) {
|
859 |
+
return;
|
860 |
+
}
|
861 |
|
862 |
+
if ( is_a( $email, 'WC_Email_Customer_Refunded_Order' ) && isset( $wc_ast_unclude_tracking_info[ 'refunded' ] ) && 0 == $wc_ast_unclude_tracking_info[ 'refunded' ] ) {
|
863 |
+
return;
|
864 |
+
}
|
865 |
|
866 |
$tracking_items = $this->get_tracking_items( $order_id, true );
|
867 |
|
868 |
if ( true === $plain_text ) {
|
869 |
+
|
870 |
+
if ( file_exists( $local_template ) && is_writable( $local_template ) ) {
|
871 |
wc_get_template( 'emails/plain/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
872 |
+
} else {
|
873 |
wc_get_template( 'emails/plain/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
874 |
}
|
875 |
} else {
|
876 |
+
if ( file_exists( $local_template ) && is_writable( $local_template ) ) {
|
877 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
878 |
+
} elseif ( class_exists('ast_pro') ) {
|
879 |
+
wc_get_template( 'emails/fluid-tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', ast_pro()->get_plugin_path() . '/templates/' );
|
880 |
+
} else {
|
881 |
wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ), 'order_id'=> $order_id ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
882 |
}
|
883 |
}
|
898 |
*/
|
899 |
public function get_formatted_tracking_item( $order_id, $tracking_item ) {
|
900 |
$formatted = array();
|
901 |
+
$tracking_items = $this->get_tracking_items( $order_id );
|
902 |
$trackship_supported = '';
|
903 |
|
904 |
+
foreach ( $tracking_items as $key => $item ) {
|
905 |
+
if ( $item['tracking_id'] == $tracking_item['tracking_id'] ) {
|
906 |
$shipmet_key = $key;
|
907 |
}
|
908 |
}
|
909 |
|
910 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true );
|
911 |
|
912 |
+
$status = isset( $shipment_status[ $shipmet_key ][ 'status' ] ) ? $shipment_status[ $shipmet_key ][ 'status' ] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
913 |
|
914 |
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
915 |
$postcode = get_post_meta( $order_id, '_shipping_postcode', true );
|
926 |
}
|
927 |
|
928 |
$tracking_provider = isset( $tracking_item['tracking_provider'] ) ? $tracking_item['tracking_provider'] : $tracking_item['custom_tracking_provider'];
|
929 |
+
$tracking_provider = apply_filters( 'convert_provider_name_to_slug', $tracking_provider );
|
930 |
$tracking_item['tracking_provider'] = $tracking_provider;
|
931 |
|
932 |
+
$link_format = '';
|
933 |
+
|
934 |
+
foreach ( $this->get_providers() as $provider => $format ) {
|
935 |
+
if ( $provider === $tracking_item['tracking_provider'] ) {
|
936 |
+
$link_format = $format['provider_url'];
|
937 |
+
$trackship_supported = $format['trackship_supported'];
|
938 |
+
$formatted['formatted_tracking_provider'] = $format['provider_name'];
|
939 |
+
break;
|
940 |
+
}
|
941 |
|
942 |
+
if ( $link_format ) {
|
943 |
+
break;
|
944 |
+
}
|
945 |
+
}
|
946 |
+
|
947 |
+
if ( $link_format ) {
|
948 |
+
$searchVal = array( "%number%", str_replace( ' ', '', "%2 $ s" ) );
|
949 |
+
$tracking_number = str_replace( ' ', '', $tracking_item['tracking_number'] );
|
950 |
+
$replaceVal = array( $tracking_number, urlencode( $postcode ) );
|
951 |
+
$link_format = str_replace( $searchVal, $replaceVal, $link_format );
|
952 |
+
|
953 |
+
if ( isset( $tracking_item[ 'tracking_product_code' ] ) ) {
|
954 |
+
$searchnumber2 = array("%number2%", str_replace(' ', '', "%2 $ s") );
|
955 |
+
$tracking_product_code = str_replace(' ', '', $tracking_item['tracking_product_code']);
|
956 |
+
$link_format = str_replace( $searchnumber2, $tracking_product_code, $link_format );
|
957 |
}
|
958 |
+
|
959 |
+
if ( null != $order->get_shipping_country() ) {
|
960 |
+
$shipping_country = $order->get_shipping_country();
|
961 |
+
} else {
|
962 |
+
$shipping_country = $order->get_billing_country();
|
963 |
+
}
|
964 |
+
|
965 |
+
if ( $shipping_country ) {
|
966 |
|
967 |
+
if ( 'jp-post' == $tracking_item['tracking_provider'] && 'JP' != $shipping_country ) {
|
968 |
+
$local_en = '&locale=en';
|
969 |
+
$link_format = $link_format . $local_en;
|
970 |
+
}
|
971 |
+
|
972 |
+
if ( 'dhl-ecommerce' == $tracking_item['tracking_provider'] ) {
|
973 |
+
$link_format = str_replace('us-en', strtolower($shipping_country) . '-en', $link_format);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
974 |
}
|
975 |
|
976 |
+
if ( 'dhl-freight' == $tracking_item['tracking_provider'] ) {
|
977 |
+
$link_format = str_replace('global-en', strtolower($shipping_country) . '-en', $link_format);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
978 |
}
|
979 |
+
}
|
980 |
+
|
981 |
+
if ( null != $order->get_shipping_postcode() ) {
|
982 |
+
$shipping_postal_code = $order->get_shipping_postcode();
|
983 |
+
} else {
|
984 |
+
$shipping_postal_code = $order->get_billing_postcode();
|
985 |
+
}
|
986 |
+
|
987 |
+
$shipping_country = str_replace( ' ', '', $shipping_country );
|
988 |
+
$link_format = str_replace( '%country_code%', $shipping_country, $link_format );
|
989 |
+
|
990 |
+
if ( 'apc-overnight' == $tracking_item['tracking_provider'] ) {
|
991 |
+
$shipping_postal_code = str_replace( ' ', '+', $shipping_postal_code );
|
992 |
+
} else {
|
993 |
+
$shipping_postal_code = str_replace( ' ', '', $shipping_postal_code );
|
994 |
+
}
|
995 |
+
|
996 |
+
$link_format = str_replace( '%postal_code%', $shipping_postal_code, $link_format );
|
997 |
+
|
998 |
+
$formatted_tracking_link = $link_format;
|
999 |
+
$formatted['formatted_tracking_link'] = $link_format;
|
1000 |
+
} else {
|
1001 |
+
$formatted_tracking_link = isset( $tracking_item['custom_tracking_link'] ) ? $tracking_item['custom_tracking_link'] : '' ;
|
1002 |
+
$formatted['formatted_tracking_link'] = $formatted_tracking_link;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
$ts_tracking_page = $this->check_ts_tracking_page_for_tracking_item( $order_id, $tracking_item, $status );
|
1006 |
+
|
1007 |
+
if ( $ts_tracking_page ) {
|
1008 |
+
|
1009 |
+
$tracking_page = get_option( 'wc_ast_trackship_page_id' );
|
1010 |
+
$order_key = $order->get_order_key();
|
1011 |
+
|
1012 |
+
if ( 'other' == $tracking_page ) {
|
1013 |
+
$trackship_other_page = get_option( 'wc_ast_trackship_other_page' );
|
1014 |
+
$ts_tracking_link = add_query_arg( array(
|
1015 |
+
'order_id' => $order_id,
|
1016 |
+
'order_key' => $order_key,
|
1017 |
+
), $trackship_other_page );
|
1018 |
+
} else {
|
1019 |
+
$ts_tracking_link = add_query_arg( array(
|
1020 |
+
'order_id' => $order_id,
|
1021 |
+
'order_key' => $order_key,
|
1022 |
+
), get_permalink( $tracking_page ) );
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
$formatted['ast_tracking_link'] = $ts_tracking_link;
|
1026 |
+
} else {
|
1027 |
+
$formatted['ast_tracking_link'] = $formatted_tracking_link;
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
global $wpdb;
|
1031 |
+
$results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$this->table} WHERE ts_slug = %s", $tracking_item['tracking_provider'] ) );
|
1032 |
+
$formatted[ 'tracking_provider_image' ] = apply_filters( 'get_shipping_provdider_src', $results );
|
1033 |
+
|
1034 |
return $formatted;
|
1035 |
}
|
1036 |
|
1037 |
+
public function check_ts_tracking_page_for_tracking_item( $order_id, $tracking_item, $status ) {
|
1038 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
1039 |
+
$use_tracking_page = get_option( 'wc_ast_use_tracking_page' );
|
1040 |
+
$trackship_supported = 0;
|
1041 |
|
1042 |
foreach ( $this->get_providers() as $provider => $format ) {
|
1043 |
+
if ( $provider === $tracking_item['tracking_provider'] ) {
|
1044 |
+
$trackship_supported = isset( $format['trackship_supported'] ) ? $format['trackship_supported'] : 0;
|
1045 |
break;
|
1046 |
}
|
1047 |
}
|
1048 |
|
1049 |
+
if ( $wc_ast_api_key && $use_tracking_page && 1 == $trackship_supported && 'carrier_unsupported' != $status ) {
|
1050 |
+
return true;
|
1051 |
+
}
|
1052 |
return false;
|
1053 |
}
|
1054 |
|
1070 |
if ( $item['tracking_id'] == $tracking_id ) {
|
1071 |
unset( $tracking_items[ $key ] );
|
1072 |
$is_deleted = true;
|
1073 |
+
do_action( 'fix_shipment_tracking_for_deleted_tracking', $order_id, $key, $item );
|
1074 |
break;
|
1075 |
}
|
1076 |
}
|
1077 |
$this->save_tracking_items( $order_id, $tracking_items );
|
1078 |
}
|
1079 |
+
|
1080 |
+
$tracking_items = $this->get_tracking_items( $order_id );
|
1081 |
+
|
1082 |
+
if ( !$tracking_items ) {
|
1083 |
+
delete_post_meta( $order_id, '_wc_shipment_tracking_items' );
|
1084 |
+
}
|
1085 |
+
|
1086 |
return $is_deleted;
|
1087 |
}
|
1088 |
|
1097 |
public function add_tracking_item( $order_id, $args ) {
|
1098 |
$tracking_item = array();
|
1099 |
|
1100 |
+
$tracking_item['tracking_provider'] = isset( $args['tracking_provider'] ) ? wc_clean( $args['tracking_provider'] ) : '';
|
1101 |
+
$tracking_item['custom_tracking_provider'] = isset( $args['custom_tracking_provider'] ) ? wc_clean( $args['custom_tracking_provider'] ) : '';
|
1102 |
+
$tracking_item['custom_tracking_link'] = isset( $args['custom_tracking_link'] ) ? wc_clean( $args['custom_tracking_link'] ) : '';
|
1103 |
+
$tracking_item['tracking_number'] = isset( $args['tracking_number'] ) ? wc_clean( $args['tracking_number'] ) : '';
|
1104 |
+
$tracking_item['tracking_product_code'] = isset( $args['tracking_product_code'] ) ? wc_clean( $args['tracking_product_code'] ) : '';
|
1105 |
|
1106 |
+
if ( isset( $args['date_shipped'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1107 |
$date = str_replace("/","-",$args['date_shipped']);
|
1108 |
$date = date_create($date);
|
1109 |
|
1110 |
+
if ( isset($args['source']) && 'REST_API' == $args['source'] ) {
|
1111 |
+
$wc_ast_api_date_format = get_option( 'wc_ast_api_date_format','d-m-Y' );
|
1112 |
$date = date_format( $date, $wc_ast_api_date_format );
|
1113 |
+
} else {
|
1114 |
$date = date_format($date,"d-m-Y");
|
1115 |
}
|
1116 |
|
1117 |
$tracking_item['date_shipped'] = wc_clean( strtotime( $date ) );
|
1118 |
}
|
1119 |
|
1120 |
+
$tracking_item['products_list'] = isset( $args['products_list'] ) ? wc_clean( $args['products_list'] ) : '';
|
1121 |
+
$tracking_item['status_shipped'] = isset( $args['status_shipped'] ) ? wc_clean( $args['status_shipped'] ) : '';
|
1122 |
+
$tracking_item['date_shipped'] = !isset( $args['date_shipped'] ) ? time() : $tracking_item['date_shipped'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1123 |
|
1124 |
if ( 0 == (int) $tracking_item['date_shipped'] ) {
|
1125 |
$tracking_item['date_shipped'] = time();
|
1137 |
|
1138 |
$tracking_items[] = $tracking_item;
|
1139 |
|
1140 |
+
$status_shipped = ( isset( $tracking_item[ 'status_shipped' ] ) ? $tracking_item[ 'status_shipped' ] : '' );
|
1141 |
|
1142 |
$this->save_tracking_items( $order_id, $tracking_items );
|
1143 |
|
1144 |
$order = new WC_Order( $order_id );
|
1145 |
|
1146 |
+
do_action( 'update_order_status_after_adding_tracking', $status_shipped, $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1147 |
|
1148 |
$formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
1149 |
$tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
|
1150 |
|
1151 |
// The text for the note
|
1152 |
+
$note = sprintf( __( "Order was shipped with %s and tracking number is: %s", 'woo-advanced-shipment-tracking' ), $tracking_provider, $tracking_item['tracking_number'] );
|
1153 |
|
1154 |
// Add the note
|
1155 |
$order->add_order_note( $note );
|
1157 |
return $tracking_item;
|
1158 |
}
|
1159 |
|
1160 |
+
public function seach_tracking_number_in_items( $tracking_number, $tracking_items ) {
|
1161 |
+
foreach ( $tracking_items as $key => $val ) {
|
1162 |
+
if ( $val['tracking_number'] === $tracking_number ) {
|
1163 |
return $key;
|
1164 |
}
|
1165 |
}
|
1181 |
$ast_admin = WC_Advanced_Shipment_Tracking_Admin::get_instance();
|
1182 |
$shippment_provider = $ast_admin->get_provider_slug_from_name( $tracking_provider );
|
1183 |
|
1184 |
+
if ( $args['tracking_provider'] && !empty( $shippment_provider ) ) {
|
1185 |
$tracking_item['tracking_provider'] = wc_clean ( $shippment_provider );
|
1186 |
+
} else if ( $args['tracking_provider'] ) {
|
1187 |
$tracking_item['tracking_provider'] = $args['tracking_provider'];
|
1188 |
}
|
1189 |
|
1190 |
+
if ( $args['tracking_number'] ) {
|
1191 |
$tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
|
1192 |
}
|
1193 |
+
|
1194 |
+
if ( $args['date_shipped'] ) {
|
1195 |
$date = str_replace("/","-",$args['date_shipped']);
|
1196 |
$date = date_create($date);
|
1197 |
$date = date_format($date,"d-m-Y");
|
1198 |
|
1199 |
+
$tracking_item['date_shipped'] = wc_clean( strtotime( $date ) );
|
1200 |
}
|
1201 |
|
1202 |
+
if ( $args['status_shipped'] ) {
|
1203 |
+
$tracking_item['status_shipped'] = wc_clean( $args['status_shipped'] );
|
1204 |
}
|
1205 |
|
1206 |
if ( 0 == (int) $tracking_item['date_shipped'] ) {
|
1212 |
$tracking_items = $this->get_tracking_items( $order_id );
|
1213 |
$tracking_items[] = $tracking_item;
|
1214 |
|
1215 |
+
if ( $tracking_item['tracking_provider'] ) {
|
1216 |
$this->save_tracking_items( $order_id, $tracking_items );
|
1217 |
|
1218 |
+
$status_shipped = ( isset( $tracking_item['status_shipped'] ) ? $tracking_item['status_shipped'] : "" );
|
1219 |
|
1220 |
$order = new WC_Order( $order_id );
|
1221 |
|
1222 |
+
do_action( 'update_order_status_after_adding_tracking', $status_shipped, $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1223 |
|
1224 |
$formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
|
1225 |
+
$tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
|
1226 |
|
1227 |
// The text for the note
|
1228 |
+
$note = sprintf( __( 'Order was shipped with %s and tracking number is: %s', 'woo-advanced-shipment-tracking' ), $tracking_provider, $tracking_item['tracking_number'] );
|
1229 |
|
1230 |
// Add the note
|
1231 |
$order->add_order_note( $note );
|
1273 |
}
|
1274 |
}
|
1275 |
}
|
|
|
1276 |
return null;
|
1277 |
}
|
1278 |
|
1290 |
|
1291 |
global $wpdb;
|
1292 |
$order = wc_get_order( $order_id );
|
1293 |
+
if ( $order ) {
|
1294 |
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
1295 |
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
|
1296 |
+
} else {
|
1297 |
$order = new WC_Order( $order_id );
|
1298 |
$tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
|
1299 |
}
|
1328 |
/**
|
1329 |
* validation code add tracking info form
|
1330 |
*/
|
1331 |
+
public function custom_validation_js(){
|
1332 |
+
?>
|
1333 |
<script>
|
1334 |
jQuery(document).on("click",".button-save-form",function(e){
|
1335 |
var error;
|
1365 |
/*
|
1366 |
* Get formated order id
|
1367 |
*/
|
1368 |
+
public function get_formated_order_id( $order_id ) {
|
1369 |
+
|
1370 |
if ( is_plugin_active( 'custom-order-numbers-for-woocommerce/custom-order-numbers-for-woocommerce.php' ) ) {
|
1371 |
+
$alg_wc_custom_order_numbers_enabled = get_option( 'alg_wc_custom_order_numbers_enabled' );
|
1372 |
+
$alg_wc_custom_order_numbers_prefix = get_option( 'alg_wc_custom_order_numbers_prefix' );
|
1373 |
+
$new_order_id = str_replace( $alg_wc_custom_order_numbers_prefix, '', $order_id );
|
1374 |
|
1375 |
+
if ( 'yes' == $alg_wc_custom_order_numbers_enabled ) {
|
1376 |
$args = array(
|
1377 |
'post_type' => 'shop_order',
|
1378 |
'posts_per_page' => '1',
|
1388 |
$posts = get_posts( $args );
|
1389 |
$my_query = new WP_Query( $args );
|
1390 |
|
1391 |
+
if ( $my_query->have_posts() ) {
|
1392 |
+
while ( $my_query->have_posts()) {
|
1393 |
$my_query->the_post();
|
1394 |
+
if ( get_the_ID() ) {
|
1395 |
$order_id = get_the_ID();
|
1396 |
}
|
1397 |
} // end while
|
1399 |
$order_id;
|
1400 |
wp_reset_postdata();
|
1401 |
}
|
1402 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1403 |
|
1404 |
if ( is_plugin_active( 'woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php' ) ) {
|
1405 |
|
1406 |
$s_order_id = wc_sequential_order_numbers()->find_order_by_order_number( $order_id );
|
1407 |
+
if ( $s_order_id ) {
|
1408 |
$order_id = $s_order_id;
|
1409 |
}
|
1410 |
}
|
1422 |
);
|
1423 |
|
1424 |
$posts = get_posts( $query_args );
|
1425 |
+
if( !empty( $posts ) ) {
|
1426 |
list( $order_id ) = $posts;
|
1427 |
}
|
1428 |
}
|
1429 |
|
1430 |
if ( is_plugin_active( 'woocommerce-jetpack/woocommerce-jetpack.php' ) ) {
|
1431 |
|
1432 |
+
$wcj_order_numbers_enabled = get_option( 'wcj_order_numbers_enabled' );
|
1433 |
// Get prefix and suffix options
|
1434 |
$prefix = do_shortcode( get_option( 'wcj_order_number_prefix', '' ) );
|
1435 |
$prefix .= date_i18n( get_option( 'wcj_order_number_date_prefix', '' ) );
|
1441 |
$search_no_suffix_and_prefix = preg_replace( "/{$suffix}\z/i", '', $search_no_suffix );
|
1442 |
$final_search = empty( $search_no_suffix_and_prefix ) ? $search : $search_no_suffix_and_prefix;
|
1443 |
|
1444 |
+
if ( 'yes' == $wcj_order_numbers_enabled ) {
|
1445 |
$query_args = array(
|
1446 |
'numberposts' => 1,
|
1447 |
'meta_key' => '_wcj_order_number',
|
1452 |
);
|
1453 |
|
1454 |
$posts = get_posts( $query_args );
|
1455 |
+
if ( !empty( $posts ) ) {
|
1456 |
list( $order_id ) = $posts;
|
1457 |
}
|
1458 |
}
|
1460 |
|
1461 |
if ( is_plugin_active( 'wp-lister-amazon/wp-lister-amazon.php' ) ) {
|
1462 |
$wpla_use_amazon_order_number = get_option( 'wpla_use_amazon_order_number' );
|
1463 |
+
if ( 1 == $wpla_use_amazon_order_number ) {
|
1464 |
$query_args = array(
|
1465 |
'numberposts' => 1,
|
1466 |
'meta_key' => '_wpla_amazon_order_id',
|
1471 |
);
|
1472 |
|
1473 |
$posts = get_posts( $query_args );
|
1474 |
+
if ( !empty( $posts ) ) {
|
1475 |
list( $order_id ) = $posts;
|
1476 |
}
|
1477 |
}
|
1478 |
}
|
1479 |
|
1480 |
+
if ( is_plugin_active( 'wp-lister/wp-lister.php' ) || is_plugin_active( 'wp-lister-for-ebay/wp-lister.php' ) ) {
|
1481 |
$args = array(
|
1482 |
'post_type' => 'shop_order',
|
1483 |
'posts_per_page' => '1',
|
1494 |
),
|
1495 |
'post_status' => 'any',
|
1496 |
);
|
1497 |
+
|
1498 |
$posts = get_posts( $args );
|
1499 |
$my_query = new WP_Query( $args );
|
1500 |
|
1501 |
+
if ( $my_query->have_posts() ) {
|
1502 |
+
while ( $my_query->have_posts() ) {
|
1503 |
$my_query->the_post();
|
1504 |
+
if ( get_the_ID() ) {
|
1505 |
$order_id = get_the_ID();
|
1506 |
}
|
1507 |
} // end while
|
1520 |
);
|
1521 |
|
1522 |
$posts = get_posts( $query_args );
|
1523 |
+
if ( !empty( $posts ) ) {
|
1524 |
list( $order_id ) = $posts;
|
1525 |
}
|
1526 |
}
|
1536 |
);
|
1537 |
|
1538 |
$posts = get_posts( $query_args );
|
1539 |
+
if( !empty( $posts ) ) {
|
1540 |
list( $order_id ) = $posts;
|
1541 |
}
|
1542 |
}
|
1543 |
|
1544 |
+
return apply_filters( 'ast_formated_order_id', $order_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1545 |
}
|
1546 |
|
1547 |
/*
|
1548 |
* Return option value for customizer
|
1549 |
*/
|
1550 |
+
public function get_option_value_from_array( $array, $key, $default_value ){
|
1551 |
+
|
1552 |
+
$array_data = get_option( $array );
|
1553 |
$value = '';
|
1554 |
|
1555 |
+
if ( isset( $array_data[ $key ] ) ) {
|
1556 |
+
$value = $array_data[ $key ];
|
1557 |
+
if ( '' != $value ) {
|
1558 |
return $value;
|
1559 |
+
}
|
1560 |
}
|
1561 |
+
|
1562 |
+
if ( '' == $value ) {
|
1563 |
$value = $default_value;
|
1564 |
+
}
|
1565 |
+
|
1566 |
return $value;
|
1567 |
}
|
1568 |
|
1569 |
/*
|
1570 |
* Return checkbox option value for customizer
|
1571 |
*/
|
1572 |
+
public function get_checkbox_option_value_from_array( $array, $key, $default_value ) {
|
1573 |
+
|
1574 |
+
$array_data = get_option( $array );
|
1575 |
$value = '';
|
1576 |
|
1577 |
+
if ( isset( $array_data[ $key ] ) ) {
|
1578 |
+
$value = $array_data[ $key ];
|
1579 |
return $value;
|
1580 |
}
|
1581 |
+
|
1582 |
+
if ( '' == $value ) {
|
1583 |
$value = $default_value;
|
1584 |
+
}
|
1585 |
+
|
1586 |
return $value;
|
1587 |
+
}
|
1588 |
+
|
1589 |
+
/*
|
1590 |
+
* Return Tracking information template
|
1591 |
+
*/
|
1592 |
+
public function tracking_info_template( $order_id, $tracking_items, $shipment_status = '' ) {
|
1593 |
+
|
1594 |
+
$local_template = get_stylesheet_directory().'/woocommerce/emails/tracking-info.php';
|
1595 |
+
|
1596 |
+
if ( file_exists( $local_template ) && is_writable( $local_template ) ) {
|
1597 |
+
return wc_get_template_html( 'emails/tracking-info.php', array(
|
1598 |
+
'tracking_items' => $tracking_items,
|
1599 |
+
'order_id' => $order_id,
|
1600 |
+
'show_shipment_status' => true,
|
1601 |
+
'new_status' => $shipment_status,
|
1602 |
+
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
1603 |
+
} elseif ( class_exists('ast_pro') ) {
|
1604 |
+
return wc_get_template_html( 'emails/fluid-tracking-info.php', array(
|
1605 |
+
'tracking_items' => $tracking_items,
|
1606 |
+
'order_id'=> $order_id
|
1607 |
+
), 'woocommerce-advanced-shipment-tracking/', ast_pro()->get_plugin_path() . '/templates/' );
|
1608 |
+
} else {
|
1609 |
+
return wc_get_template_html( 'emails/tracking-info.php', array(
|
1610 |
+
'tracking_items' => $tracking_items,
|
1611 |
+
'order_id' => $order_id,
|
1612 |
+
'show_shipment_status' => true,
|
1613 |
+
'new_status' => $shipment_status,
|
1614 |
+
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
1615 |
+
}
|
1616 |
+
}
|
1617 |
+
|
1618 |
+
/*
|
1619 |
+
* Return order details template
|
1620 |
+
*/
|
1621 |
+
public function order_details_template( $order, $hide_shipping_item_price = '' ) {
|
1622 |
+
return wc_get_template_html(
|
1623 |
+
'emails/wcast-email-order-details.php', array(
|
1624 |
+
'order' => $order,
|
1625 |
+
'hide_shipping_item_price' => $hide_shipping_item_price,
|
1626 |
+
'sent_to_admin' => false,
|
1627 |
+
'plain_text' => false,
|
1628 |
+
'email' => '',
|
1629 |
+
),
|
1630 |
+
'woocommerce-advanced-shipment-tracking/',
|
1631 |
+
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
1632 |
+
);
|
1633 |
+
}
|
1634 |
+
|
1635 |
+
/*
|
1636 |
+
* Return shipping address template
|
1637 |
+
*/
|
1638 |
+
public function order_shipping_details_template( $order ) {
|
1639 |
+
return wc_get_template_html(
|
1640 |
+
'emails/wcast-shipping-email-addresses.php', array(
|
1641 |
+
'order' => $order,
|
1642 |
+
'sent_to_admin' => false,
|
1643 |
+
),
|
1644 |
+
'woocommerce-advanced-shipment-tracking/',
|
1645 |
+
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
1646 |
+
);
|
1647 |
+
}
|
1648 |
}
|
includes/customizer/class-wc-availableforpickup-email-customizer.php
CHANGED
@@ -12,18 +12,16 @@ class wcast_availableforpickup_customizer_email {
|
|
12 |
|
13 |
// Get our Customizer defaults
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
|
|
15 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
16 |
-
if(!$wc_ast_api_key)
|
17 |
-
|
18 |
-
}
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
-
if ( !
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
// Register our sections
|
28 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
29 |
|
@@ -43,32 +41,9 @@ class wcast_availableforpickup_customizer_email {
|
|
43 |
|
44 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
45 |
|
46 |
-
add_action( 'customize_preview_init', array(
|
47 |
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* add css and js for preview
|
52 |
-
*/
|
53 |
-
public function enqueue_preview_scripts() {
|
54 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
55 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
56 |
-
// Send variables to Javascript
|
57 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
58 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
59 |
-
'site_title' => $this->get_blogname(),
|
60 |
-
'order_number' => $preview_id,
|
61 |
-
));
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Get blog name formatted for emails.
|
66 |
-
*
|
67 |
-
* @return string
|
68 |
-
*/
|
69 |
-
public function get_blogname() {
|
70 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
71 |
-
}
|
72 |
|
73 |
/**
|
74 |
* Checks to see if we are opening our custom customizer preview
|
@@ -76,7 +51,7 @@ class wcast_availableforpickup_customizer_email {
|
|
76 |
* @access public
|
77 |
* @return bool
|
78 |
*/
|
79 |
-
public
|
80 |
return isset( $_REQUEST['wcast-availableforpickup-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-availableforpickup-email-customizer-preview'];
|
81 |
}
|
82 |
|
@@ -86,37 +61,10 @@ class wcast_availableforpickup_customizer_email {
|
|
86 |
* @access public
|
87 |
* @return bool
|
88 |
*/
|
89 |
-
public
|
90 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
91 |
}
|
92 |
|
93 |
-
/**
|
94 |
-
* Get Customizer URL
|
95 |
-
*
|
96 |
-
*/
|
97 |
-
public static function get_customizer_url( $email, $shipment_status, $return_tab ) {
|
98 |
-
$customizer_url = add_query_arg( array(
|
99 |
-
'wcast-customizer' => '1',
|
100 |
-
'email' => $email,
|
101 |
-
'shipment_status' => $shipment_status,
|
102 |
-
'autofocus[section]' => 'trackship_shipment_status_email',
|
103 |
-
'url' => urlencode( add_query_arg( array( 'wcast-availableforpickup-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
104 |
-
'return' => urlencode( wcast_availableforpickup_customizer_email::get_email_settings_page_url($return_tab) ),
|
105 |
-
), admin_url( 'customize.php' ) );
|
106 |
-
|
107 |
-
return $customizer_url;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Get WooCommerce email settings page URL
|
112 |
-
*
|
113 |
-
* @access public
|
114 |
-
* @return string
|
115 |
-
*/
|
116 |
-
public static function get_email_settings_page_url($return_tab) {
|
117 |
-
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
118 |
-
}
|
119 |
-
|
120 |
/**
|
121 |
* code for initialize default value for customizer
|
122 |
*/
|
@@ -134,7 +82,7 @@ class wcast_availableforpickup_customizer_email {
|
|
134 |
'wcast_availableforpickup_email_code_block' => '',
|
135 |
);
|
136 |
|
137 |
-
return apply_filters( '
|
138 |
}
|
139 |
|
140 |
/**
|
@@ -247,7 +195,7 @@ class wcast_availableforpickup_customizer_email {
|
|
247 |
'sanitize_callback' => 'wp_kses_post'
|
248 |
)
|
249 |
);
|
250 |
-
$wp_customize->add_control( new
|
251 |
array(
|
252 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
253 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
@@ -360,23 +308,13 @@ class wcast_availableforpickup_customizer_email {
|
|
360 |
}
|
361 |
|
362 |
public function active_callback(){
|
363 |
-
|
364 |
-
return true;
|
365 |
-
} else{
|
366 |
-
return false;
|
367 |
-
}
|
368 |
}
|
369 |
|
370 |
public function active_callback_only_show_order_details(){
|
371 |
-
|
372 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
373 |
-
$show_order_details = $ast->
|
374 |
-
|
375 |
-
if ( wcast_availableforpickup_customizer_email::is_own_preview_request() && $show_order_details ) {
|
376 |
-
return true;
|
377 |
-
} else{
|
378 |
-
return false;
|
379 |
-
}
|
380 |
}
|
381 |
|
382 |
/**
|
@@ -386,130 +324,60 @@ class wcast_availableforpickup_customizer_email {
|
|
386 |
* @return void
|
387 |
*/
|
388 |
public function set_up_preview() {
|
389 |
-
|
390 |
// Make sure this is own preview request.
|
391 |
-
if ( !
|
392 |
-
|
393 |
-
}
|
394 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/availableforpickup_preview.php';
|
395 |
-
exit;
|
396 |
}
|
397 |
|
398 |
/**
|
399 |
* code for preview of available for pickup email
|
400 |
*/
|
401 |
public function preview_availableforpickup_email(){
|
402 |
-
|
403 |
-
$wc_emails = WC_Emails::instance();
|
404 |
-
$emails = $wc_emails->get_emails();
|
405 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
406 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
407 |
|
408 |
-
$
|
409 |
-
|
410 |
-
$email_heading = $ast->get_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_email_heading',$this->defaults['wcast_availableforpickup_email_heading']);
|
411 |
-
$email_heading = str_replace( '{site_title}', $this->get_blogname(), $email_heading );
|
412 |
-
$email_heading = str_replace( '{order_number}', $order_id, $email_heading );
|
413 |
-
|
414 |
$email_content = $ast->get_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_email_content',$this->defaults['wcast_availableforpickup_email_content']);
|
415 |
-
|
416 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_show_order_details',$this->defaults['wcast_availableforpickup_show_order_details']);
|
417 |
-
|
418 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_hide_shipping_item_price',$this->defaults['wcast_availableforpickup_hide_shipping_item_price']);
|
419 |
-
|
420 |
-
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_show_shipping_address',$this->defaults['wcast_availableforpickup_show_shipping_address']);
|
421 |
-
|
422 |
-
$sent_to_admin = false;
|
423 |
-
$plain_text = false;
|
424 |
-
$email = '';
|
425 |
|
426 |
if($preview_id == '' || $preview_id == 'mockup') {
|
427 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
428 |
echo $content;
|
429 |
return;
|
430 |
}
|
|
|
431 |
$order = wc_get_order( $preview_id );
|
432 |
|
433 |
-
if(!$order){
|
434 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
435 |
echo $content;
|
436 |
return;
|
437 |
}
|
438 |
|
439 |
-
$mailer = WC()->mailer();
|
440 |
-
|
441 |
// get the preview email subject
|
442 |
-
$email_heading =
|
443 |
-
|
444 |
-
|
445 |
-
$message = wc_trackship_email_manager()->email_content($email_content,$preview_id,$order);
|
446 |
|
447 |
$wcast_availableforpickup_analytics_link = $ast->get_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_analytics_link','');
|
448 |
-
|
449 |
if($wcast_availableforpickup_analytics_link){
|
450 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
451 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
452 |
}
|
453 |
|
454 |
-
$
|
455 |
-
|
456 |
-
|
457 |
-
$
|
458 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
459 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
460 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
461 |
-
'order_id' => $preview_id,
|
462 |
-
'show_shipment_status' => true,
|
463 |
-
'new_status' => 'available_for_pickup',
|
464 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
465 |
-
} else{
|
466 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
467 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
468 |
-
'order_id' => $preview_id,
|
469 |
-
'show_shipment_status' => true,
|
470 |
-
'new_status' => 'available_for_pickup',
|
471 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
472 |
-
}
|
473 |
-
$message .= ob_get_clean();
|
474 |
-
|
475 |
-
if($wcast_show_order_details == 1){
|
476 |
-
|
477 |
-
ob_start();
|
478 |
-
wc_get_template(
|
479 |
-
'emails/wcast-email-order-details.php', array(
|
480 |
-
'order' => $order,
|
481 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
482 |
-
'sent_to_admin' => $sent_to_admin,
|
483 |
-
'plain_text' => $plain_text,
|
484 |
-
'email' => $email,
|
485 |
-
),
|
486 |
-
'woocommerce-advanced-shipment-tracking/',
|
487 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
488 |
-
);
|
489 |
-
$message .= ob_get_clean();
|
490 |
-
}
|
491 |
-
|
492 |
-
if($wcast_show_shipping_address == 1){
|
493 |
-
ob_start();
|
494 |
-
wc_get_template(
|
495 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
496 |
-
'order' => $order,
|
497 |
-
'sent_to_admin' => $sent_to_admin,
|
498 |
-
),
|
499 |
-
'woocommerce-advanced-shipment-tracking/',
|
500 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
501 |
-
);
|
502 |
-
$message .= ob_get_clean();
|
503 |
-
}
|
504 |
|
505 |
// create a new email
|
506 |
$email = new WC_Email();
|
507 |
-
$
|
508 |
-
|
509 |
// wrap the content with the email template and then add styles
|
510 |
-
|
511 |
-
|
512 |
-
echo $message;
|
513 |
}
|
514 |
|
515 |
/**
|
@@ -530,5 +398,4 @@ class wcast_availableforpickup_customizer_email {
|
|
530 |
/**
|
531 |
* Initialise our Customizer settings
|
532 |
*/
|
533 |
-
|
534 |
-
$wcast_customizer_settings = new wcast_availableforpickup_customizer_email();
|
12 |
|
13 |
// Get our Customizer defaults
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
+
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
18 |
+
|
|
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
24 |
+
|
|
|
|
|
25 |
// Register our sections
|
26 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
27 |
|
41 |
|
42 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
45 |
|
46 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
/**
|
49 |
* Checks to see if we are opening our custom customizer preview
|
51 |
* @access public
|
52 |
* @return bool
|
53 |
*/
|
54 |
+
public function is_own_preview_request() {
|
55 |
return isset( $_REQUEST['wcast-availableforpickup-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-availableforpickup-email-customizer-preview'];
|
56 |
}
|
57 |
|
61 |
* @access public
|
62 |
* @return bool
|
63 |
*/
|
64 |
+
public function is_own_customizer_request() {
|
65 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
/**
|
69 |
* code for initialize default value for customizer
|
70 |
*/
|
82 |
'wcast_availableforpickup_email_code_block' => '',
|
83 |
);
|
84 |
|
85 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
86 |
}
|
87 |
|
88 |
/**
|
195 |
'sanitize_callback' => 'wp_kses_post'
|
196 |
)
|
197 |
);
|
198 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_availableforpickup_email_settings[wcast_availableforpickup_email_content]',
|
199 |
array(
|
200 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
201 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
308 |
}
|
309 |
|
310 |
public function active_callback(){
|
311 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
312 |
}
|
313 |
|
314 |
public function active_callback_only_show_order_details(){
|
|
|
315 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
316 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_show_order_details',$this->defaults['wcast_availableforpickup_show_order_details']);
|
317 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
|
|
|
|
|
|
|
|
|
|
318 |
}
|
319 |
|
320 |
/**
|
324 |
* @return void
|
325 |
*/
|
326 |
public function set_up_preview() {
|
|
|
327 |
// Make sure this is own preview request.
|
328 |
+
if ( ! $this->is_own_preview_request() )return;
|
329 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/availableforpickup_preview.php';exit;
|
|
|
|
|
|
|
330 |
}
|
331 |
|
332 |
/**
|
333 |
* code for preview of available for pickup email
|
334 |
*/
|
335 |
public function preview_availableforpickup_email(){
|
336 |
+
|
|
|
|
|
337 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
338 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
339 |
|
340 |
+
$email_heading = $ast->get_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_email_heading',$this->defaults['wcast_availableforpickup_email_heading']);
|
|
|
|
|
|
|
|
|
|
|
341 |
$email_content = $ast->get_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_email_content',$this->defaults['wcast_availableforpickup_email_content']);
|
|
|
342 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_show_order_details',$this->defaults['wcast_availableforpickup_show_order_details']);
|
|
|
343 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_hide_shipping_item_price',$this->defaults['wcast_availableforpickup_hide_shipping_item_price']);
|
344 |
+
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_show_shipping_address',$this->defaults['wcast_availableforpickup_show_shipping_address']);
|
|
|
|
|
|
|
|
|
|
|
345 |
|
346 |
if($preview_id == '' || $preview_id == 'mockup') {
|
347 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
348 |
echo $content;
|
349 |
return;
|
350 |
}
|
351 |
+
|
352 |
$order = wc_get_order( $preview_id );
|
353 |
|
354 |
+
if( !$order ){
|
355 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
356 |
echo $content;
|
357 |
return;
|
358 |
}
|
359 |
|
|
|
|
|
360 |
// get the preview email subject
|
361 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
362 |
+
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
|
|
|
|
363 |
|
364 |
$wcast_availableforpickup_analytics_link = $ast->get_option_value_from_array('wcast_availableforpickup_email_settings','wcast_availableforpickup_analytics_link','');
|
|
|
365 |
if($wcast_availableforpickup_analytics_link){
|
366 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
367 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
368 |
}
|
369 |
|
370 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
371 |
+
$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'available_for_pickup' );
|
372 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
373 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
|
375 |
// create a new email
|
376 |
$email = new WC_Email();
|
377 |
+
$mailer = WC()->mailer();
|
378 |
+
|
379 |
// wrap the content with the email template and then add styles
|
380 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
|
|
|
|
381 |
}
|
382 |
|
383 |
/**
|
398 |
/**
|
399 |
* Initialise our Customizer settings
|
400 |
*/
|
401 |
+
new wcast_availableforpickup_customizer_email();
|
|
includes/customizer/class-wc-delivered-email-customizer.php
CHANGED
@@ -14,17 +14,14 @@ class wcast_delivered_customizer_email {
|
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
-
if(!$wc_ast_api_key)
|
18 |
-
return;
|
19 |
-
}
|
20 |
|
21 |
// Register our sample default controls
|
22 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
23 |
|
24 |
// Only proceed if this is own request.
|
25 |
-
if ( !
|
26 |
-
|
27 |
-
}
|
28 |
// Register our sections
|
29 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
30 |
|
@@ -44,40 +41,17 @@ class wcast_delivered_customizer_email {
|
|
44 |
|
45 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
46 |
|
47 |
-
add_action( 'customize_preview_init', array(
|
48 |
|
49 |
}
|
50 |
|
51 |
-
/**
|
52 |
-
* add css and js for preview
|
53 |
-
*/
|
54 |
-
public function enqueue_preview_scripts() {
|
55 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
56 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
57 |
-
// Send variables to Javascript
|
58 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
59 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
60 |
-
'site_title' => $this->get_blogname(),
|
61 |
-
'order_number' => $preview_id,
|
62 |
-
));
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Get blog name formatted for emails.
|
67 |
-
*
|
68 |
-
* @return string
|
69 |
-
*/
|
70 |
-
public function get_blogname() {
|
71 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
72 |
-
}
|
73 |
-
|
74 |
/**
|
75 |
* Checks to see if we are opening our custom customizer preview
|
76 |
*
|
77 |
* @access public
|
78 |
* @return bool
|
79 |
*/
|
80 |
-
public
|
81 |
return isset( $_REQUEST['wcast-delivered-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-delivered-email-customizer-preview'];
|
82 |
}
|
83 |
|
@@ -87,35 +61,9 @@ class wcast_delivered_customizer_email {
|
|
87 |
* @access public
|
88 |
* @return bool
|
89 |
*/
|
90 |
-
public
|
91 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get Customizer URL
|
96 |
-
*
|
97 |
-
*/
|
98 |
-
public static function get_customizer_url( $email, $shipment_status, $return_tab ) {
|
99 |
-
$customizer_url = add_query_arg( array(
|
100 |
-
'wcast-customizer' => '1',
|
101 |
-
'email' => $email,
|
102 |
-
'shipment_status' => $shipment_status,
|
103 |
-
'autofocus[section]' => 'trackship_shipment_status_email',
|
104 |
-
'url' => urlencode( add_query_arg( array( 'wcast-delivered-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
105 |
-
'return' => urlencode( wcast_delivered_customizer_email::get_email_settings_page_url($return_tab) ),
|
106 |
-
), admin_url( 'customize.php' ) );
|
107 |
-
return $customizer_url;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Get WooCommerce email settings page URL
|
112 |
-
*
|
113 |
-
* @access public
|
114 |
-
* @return string
|
115 |
-
*/
|
116 |
-
public static function get_email_settings_page_url($return_tab) {
|
117 |
-
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
118 |
-
}
|
119 |
|
120 |
/**
|
121 |
* code for initialize default value for customizer
|
@@ -133,7 +81,7 @@ class wcast_delivered_customizer_email {
|
|
133 |
'wcast_delivered_status_email_code_block' => '',
|
134 |
);
|
135 |
|
136 |
-
return apply_filters( '
|
137 |
}
|
138 |
|
139 |
/**
|
@@ -245,7 +193,7 @@ class wcast_delivered_customizer_email {
|
|
245 |
'sanitize_callback' => 'wp_kses_post'
|
246 |
)
|
247 |
);
|
248 |
-
$wp_customize->add_control( new
|
249 |
array(
|
250 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
251 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
@@ -377,23 +325,15 @@ class wcast_delivered_customizer_email {
|
|
377 |
}
|
378 |
|
379 |
public function active_callback(){
|
380 |
-
|
381 |
-
return true;
|
382 |
-
} else{
|
383 |
-
return false;
|
384 |
-
}
|
385 |
}
|
386 |
|
387 |
public function active_callback_only_show_order_details(){
|
388 |
|
389 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
390 |
-
$show_order_details = $ast->
|
391 |
|
392 |
-
|
393 |
-
return true;
|
394 |
-
} else{
|
395 |
-
return false;
|
396 |
-
}
|
397 |
}
|
398 |
|
399 |
/**
|
@@ -405,129 +345,60 @@ class wcast_delivered_customizer_email {
|
|
405 |
public function set_up_preview() {
|
406 |
|
407 |
// Make sure this is own preview request.
|
408 |
-
if ( !
|
409 |
-
|
410 |
-
}
|
411 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/delivered_status_preview.php';
|
412 |
-
exit;
|
413 |
}
|
414 |
|
415 |
/**
|
416 |
* code for preview of delivered email
|
417 |
*/
|
418 |
public function preview_delivered_email(){
|
419 |
-
|
420 |
-
$wc_emails = WC_Emails::instance();
|
421 |
-
$emails = $wc_emails->get_emails();
|
422 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
423 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
424 |
|
425 |
-
$order_id = $ast->get_custom_order_number( $preview_id );
|
426 |
-
|
427 |
$email_heading = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_email_heading',$this->defaults['wcast_delivered_status_email_heading']);
|
428 |
-
$email_heading = str_replace( '{site_title}', $this->get_blogname(), $email_heading );
|
429 |
-
$email_heading = str_replace( '{order_number}', $order_id, $email_heading );
|
430 |
-
|
431 |
$email_content = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_email_content',$this->defaults['wcast_delivered_status_email_content']);
|
432 |
-
|
433 |
$wcast_show_tracking_details = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_show_tracking_details',$this->defaults['wcast_delivered_status_show_tracking_details']);
|
434 |
-
|
435 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_show_order_details',$this->defaults['wcast_delivered_status_show_order_details']);
|
436 |
-
|
437 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_hide_shipping_item_price',$this->defaults['wcast_delivered_status_hide_shipping_item_price']);
|
438 |
-
|
439 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_show_shipping_address',$this->defaults['wcast_delivered_status_show_shipping_address']);
|
440 |
-
|
441 |
-
$sent_to_admin = false;
|
442 |
-
$plain_text = false;
|
443 |
-
$email = '';
|
444 |
-
|
445 |
if($preview_id == '' || $preview_id == 'mockup') {
|
446 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
447 |
echo $content;
|
448 |
return;
|
449 |
}
|
|
|
450 |
$order = wc_get_order( $preview_id );
|
451 |
|
452 |
if(!$order){
|
453 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
454 |
echo $content;
|
455 |
return;
|
456 |
-
}
|
457 |
-
|
458 |
-
$mailer = WC()->mailer();
|
459 |
|
460 |
// get the preview email subject
|
461 |
-
$email_heading =
|
462 |
-
|
463 |
-
|
464 |
-
$message = wc_trackship_email_manager()->email_content($email_content,$preview_id,$order);
|
465 |
|
466 |
$wcast_delivered_status_analytics_link = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_analytics_link','');
|
467 |
-
|
468 |
if($wcast_delivered_status_analytics_link){
|
469 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
470 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
471 |
}
|
472 |
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
478 |
-
'tracking_items' => $ast->get_tracking_items( $preview_id, true ),
|
479 |
-
'order_id' => $preview_id,
|
480 |
-
'show_shipment_status' => true,
|
481 |
-
'new_status' => 'delivered',
|
482 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
483 |
-
} else{
|
484 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
485 |
-
'tracking_items' => $ast->get_tracking_items( $preview_id, true ),
|
486 |
-
'order_id' => $preview_id,
|
487 |
-
'show_shipment_status' => true,
|
488 |
-
'new_status' => 'delivered',
|
489 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
490 |
-
}
|
491 |
-
$message .= ob_get_clean();
|
492 |
-
}
|
493 |
|
494 |
-
if($wcast_show_order_details == 1){
|
495 |
-
|
496 |
-
ob_start();
|
497 |
-
wc_get_template(
|
498 |
-
'emails/wcast-email-order-details.php', array(
|
499 |
-
'order' => $order,
|
500 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
501 |
-
'sent_to_admin' => $sent_to_admin,
|
502 |
-
'plain_text' => $plain_text,
|
503 |
-
'email' => $email,
|
504 |
-
),
|
505 |
-
'woocommerce-advanced-shipment-tracking/',
|
506 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
507 |
-
);
|
508 |
-
$message .= ob_get_clean();
|
509 |
-
}
|
510 |
-
|
511 |
-
if($wcast_show_shipping_address == 1){
|
512 |
-
ob_start();
|
513 |
-
wc_get_template(
|
514 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
515 |
-
'order' => $order,
|
516 |
-
'sent_to_admin' => $sent_to_admin,
|
517 |
-
),
|
518 |
-
'woocommerce-advanced-shipment-tracking/',
|
519 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
520 |
-
);
|
521 |
-
$message .= ob_get_clean();
|
522 |
-
}
|
523 |
-
|
524 |
// create a new email
|
525 |
$email = new WC_Email();
|
526 |
-
$
|
527 |
|
528 |
// wrap the content with the email template and then add styles
|
529 |
-
|
530 |
-
echo $message;
|
531 |
}
|
532 |
|
533 |
/**
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
|
|
|
|
18 |
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
24 |
+
|
|
|
25 |
// Register our sections
|
26 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
27 |
|
41 |
|
42 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
45 |
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* Checks to see if we are opening our custom customizer preview
|
50 |
*
|
51 |
* @access public
|
52 |
* @return bool
|
53 |
*/
|
54 |
+
public function is_own_preview_request() {
|
55 |
return isset( $_REQUEST['wcast-delivered-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-delivered-email-customizer-preview'];
|
56 |
}
|
57 |
|
61 |
* @access public
|
62 |
* @return bool
|
63 |
*/
|
64 |
+
public function is_own_customizer_request() {
|
65 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
66 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
/**
|
69 |
* code for initialize default value for customizer
|
81 |
'wcast_delivered_status_email_code_block' => '',
|
82 |
);
|
83 |
|
84 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
85 |
}
|
86 |
|
87 |
/**
|
193 |
'sanitize_callback' => 'wp_kses_post'
|
194 |
)
|
195 |
);
|
196 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_delivered_email_settings[wcast_delivered_status_email_content]',
|
197 |
array(
|
198 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
199 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
325 |
}
|
326 |
|
327 |
public function active_callback(){
|
328 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
329 |
}
|
330 |
|
331 |
public function active_callback_only_show_order_details(){
|
332 |
|
333 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
334 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_show_order_details',$this->defaults['wcast_delivered_status_show_order_details']);
|
335 |
|
336 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
|
|
|
|
|
|
|
|
337 |
}
|
338 |
|
339 |
/**
|
345 |
public function set_up_preview() {
|
346 |
|
347 |
// Make sure this is own preview request.
|
348 |
+
if ( ! $this->is_own_preview_request() )return;
|
349 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/delivered_status_preview.php';exit;
|
|
|
|
|
|
|
350 |
}
|
351 |
|
352 |
/**
|
353 |
* code for preview of delivered email
|
354 |
*/
|
355 |
public function preview_delivered_email(){
|
356 |
+
|
|
|
|
|
357 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
358 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
359 |
|
|
|
|
|
360 |
$email_heading = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_email_heading',$this->defaults['wcast_delivered_status_email_heading']);
|
|
|
|
|
|
|
361 |
$email_content = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_email_content',$this->defaults['wcast_delivered_status_email_content']);
|
|
|
362 |
$wcast_show_tracking_details = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_show_tracking_details',$this->defaults['wcast_delivered_status_show_tracking_details']);
|
|
|
363 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_show_order_details',$this->defaults['wcast_delivered_status_show_order_details']);
|
|
|
364 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_hide_shipping_item_price',$this->defaults['wcast_delivered_status_hide_shipping_item_price']);
|
|
|
365 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_show_shipping_address',$this->defaults['wcast_delivered_status_show_shipping_address']);
|
366 |
+
|
|
|
|
|
|
|
|
|
367 |
if($preview_id == '' || $preview_id == 'mockup') {
|
368 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
369 |
echo $content;
|
370 |
return;
|
371 |
}
|
372 |
+
|
373 |
$order = wc_get_order( $preview_id );
|
374 |
|
375 |
if(!$order){
|
376 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
377 |
echo $content;
|
378 |
return;
|
379 |
+
}
|
|
|
|
|
380 |
|
381 |
// get the preview email subject
|
382 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
383 |
+
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
|
|
|
|
384 |
|
385 |
$wcast_delivered_status_analytics_link = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_analytics_link','');
|
|
|
386 |
if($wcast_delivered_status_analytics_link){
|
387 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
388 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
389 |
}
|
390 |
|
391 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
392 |
+
if( $wcast_show_tracking_details )$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'delivered' );
|
393 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
394 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
// create a new email
|
397 |
$email = new WC_Email();
|
398 |
+
$mailer = WC()->mailer();
|
399 |
|
400 |
// wrap the content with the email template and then add styles
|
401 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
|
|
402 |
}
|
403 |
|
404 |
/**
|
includes/customizer/class-wc-email-customizer.php
DELETED
@@ -1,610 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Customizer Setup and Custom Controls
|
4 |
-
*
|
5 |
-
*/
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Adds the individual sections, settings, and controls to the theme customizer
|
9 |
-
*/
|
10 |
-
class wcast_initialise_customizer_email {
|
11 |
-
// Get our default values
|
12 |
-
public function __construct() {
|
13 |
-
// Get our Customizer defaults
|
14 |
-
$this->defaults = $this->wcast_generate_defaults();
|
15 |
-
|
16 |
-
// Register our sample default controls
|
17 |
-
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
18 |
-
|
19 |
-
// Only proceed if this is own request.
|
20 |
-
if ( ! wcast_initialise_customizer_email::is_own_customizer_request() && ! wcast_initialise_customizer_email::is_own_preview_request() ) {
|
21 |
-
return;
|
22 |
-
}
|
23 |
-
|
24 |
-
// Register our sections
|
25 |
-
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
26 |
-
|
27 |
-
// Remove unrelated components.
|
28 |
-
add_filter( 'customize_loaded_components', array( wcast_customizer(), 'remove_unrelated_components' ), 99, 2 );
|
29 |
-
|
30 |
-
// Remove unrelated sections.
|
31 |
-
add_filter( 'customize_section_active', array( wcast_customizer(), 'remove_unrelated_sections' ), 10, 2 );
|
32 |
-
|
33 |
-
// Unhook divi front end.
|
34 |
-
add_action( 'woomail_footer', array( wcast_customizer(), 'unhook_divi' ), 10 );
|
35 |
-
|
36 |
-
// Unhook Flatsome js
|
37 |
-
add_action( 'customize_preview_init', array( wcast_customizer(), 'unhook_flatsome' ), 50 );
|
38 |
-
|
39 |
-
add_filter( 'customize_controls_enqueue_scripts', array( wcast_customizer(), 'enqueue_customizer_scripts' ) );
|
40 |
-
|
41 |
-
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
42 |
-
|
43 |
-
add_action( 'customize_preview_init', array( $this, 'enqueue_preview_scripts' ) );
|
44 |
-
}
|
45 |
-
|
46 |
-
public function enqueue_preview_scripts() {
|
47 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
48 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
49 |
-
// Send variables to Javascript
|
50 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
51 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
52 |
-
'site_title' => $this->get_blogname(),
|
53 |
-
'order_number' => $preview_id,
|
54 |
-
));
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Get blog name formatted for emails.
|
59 |
-
*
|
60 |
-
* @return string
|
61 |
-
*/
|
62 |
-
public function get_blogname() {
|
63 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Checks to see if we are opening our custom customizer preview
|
68 |
-
*
|
69 |
-
* @access public
|
70 |
-
* @return bool
|
71 |
-
*/
|
72 |
-
public static function is_own_preview_request() {
|
73 |
-
return isset( $_REQUEST['wcast-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-email-customizer-preview'];
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Checks to see if we are opening our custom customizer controls
|
78 |
-
*
|
79 |
-
* @access public
|
80 |
-
* @return bool
|
81 |
-
*/
|
82 |
-
public static function is_own_customizer_request() {
|
83 |
-
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'custom_order_status_email';
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Get Delivered Customizer URL
|
88 |
-
*
|
89 |
-
*/
|
90 |
-
public static function get_customizer_url( $email, $order_status ) {
|
91 |
-
$customizer_url = add_query_arg( array(
|
92 |
-
'wcast-customizer' => '1',
|
93 |
-
'email' => $email,
|
94 |
-
'order_status' => $order_status,
|
95 |
-
'autofocus[section]' => 'custom_order_status_email',
|
96 |
-
'url' => urlencode( add_query_arg( array( 'wcast-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
97 |
-
'return' => urlencode( wcast_initialise_customizer_email::get_email_settings_page_url() ),
|
98 |
-
), admin_url( 'customize.php' ) );
|
99 |
-
|
100 |
-
return $customizer_url;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Get WooCommerce email settings page URL
|
105 |
-
*
|
106 |
-
* @access public
|
107 |
-
* @return string
|
108 |
-
*/
|
109 |
-
public static function get_email_settings_page_url() {
|
110 |
-
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* code for initialize default value for customizer
|
115 |
-
*/
|
116 |
-
public function wcast_generate_defaults() {
|
117 |
-
$customizer_defaults = array(
|
118 |
-
'wcast_delivered_email_subject' => __( 'Your {site_title} order is now delivered', 'woo-advanced-shipment-tracking' ),
|
119 |
-
'wcast_delivered_email_heading' => __( 'Thanks for shopping with us', 'woocommerce' ),
|
120 |
-
'wcast_delivered_email_content' => __( "Hi there. we thought you'd like to know that your recent order from {site_title} has been Delivered.", 'woo-advanced-shipment-tracking' ),
|
121 |
-
'wcast_enable_delivered_email' => 'no',
|
122 |
-
'wcast_delivered_email_to' => '{customer_email}',
|
123 |
-
'wcast_show_tracking_details' => '',
|
124 |
-
'wcast_show_order_details' => '',
|
125 |
-
'wcast_show_billing_address' => '',
|
126 |
-
'wcast_show_shipping_address' => '',
|
127 |
-
'wcast_email_code_block' => '',
|
128 |
-
);
|
129 |
-
|
130 |
-
return apply_filters( 'skyrocket_customizer_defaults', $customizer_defaults );
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Register our sample default controls
|
135 |
-
*/
|
136 |
-
public function wcast_register_sample_default_controls( $wp_customize ) {
|
137 |
-
/**
|
138 |
-
* Load all our Customizer Custom Controls
|
139 |
-
*/
|
140 |
-
require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
|
141 |
-
|
142 |
-
// Preview Order
|
143 |
-
$wp_customize->add_setting( 'wcast_email_preview_order_id',
|
144 |
-
array(
|
145 |
-
'default' => 'mockup',
|
146 |
-
'transport' => 'refresh',
|
147 |
-
'sanitize_callback' => ''
|
148 |
-
)
|
149 |
-
);
|
150 |
-
$wp_customize->add_control( new Skyrocket_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_email_preview_order_id',
|
151 |
-
array(
|
152 |
-
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
153 |
-
'description' => '',
|
154 |
-
'section' => 'custom_order_status_email',
|
155 |
-
'input_attrs' => array(
|
156 |
-
'placeholder' => __( 'Mockup Order', 'woo-advanced-shipment-tracking' ),
|
157 |
-
'class' => 'preview_order_select',
|
158 |
-
),
|
159 |
-
'choices' => wcast_customizer()->get_order_ids(),
|
160 |
-
)
|
161 |
-
) );
|
162 |
-
|
163 |
-
// Preview Order
|
164 |
-
$wp_customize->add_setting( 'wcast_order_status_email_type',
|
165 |
-
array(
|
166 |
-
'default' => 'mockup',
|
167 |
-
'transport' => 'postMessage',
|
168 |
-
'sanitize_callback' => '',
|
169 |
-
'type' => 'option',
|
170 |
-
)
|
171 |
-
);
|
172 |
-
$wp_customize->add_control( new Skyrocket_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_order_status_email_type',
|
173 |
-
array(
|
174 |
-
'label' => __( 'Email Type', 'woo-advanced-shipment-tracking' ),
|
175 |
-
'description' => '',
|
176 |
-
'section' => 'custom_order_status_email',
|
177 |
-
'input_attrs' => array(
|
178 |
-
'placeholder' => __( 'Select email type', 'woo-advanced-shipment-tracking' ),
|
179 |
-
'class' => 'preview_email_type',
|
180 |
-
),
|
181 |
-
'choices' => array(
|
182 |
-
'partially_shipped' => __( 'Partially Shipped', 'woo-advanced-shipment-tracking' ),
|
183 |
-
'updated_tracking' => __( 'Updated Tracking', 'woo-advanced-shipment-tracking' ),
|
184 |
-
'in_transit' => __( 'In Transit', 'woo-advanced-shipment-tracking' ),
|
185 |
-
'on_hold' => __( 'On Hold', 'woo-advanced-shipment-tracking' ),
|
186 |
-
'return_to_sender' => __( 'Return To Sender', 'woo-advanced-shipment-tracking' ),
|
187 |
-
'available_for_pickup' => __( 'Available For Pickup', 'woo-advanced-shipment-tracking' ),
|
188 |
-
'out_for_delivery' => __( 'Out For Delivery', 'woo-advanced-shipment-tracking' ),
|
189 |
-
'delivered' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
|
190 |
-
'failure' => __( 'Failed Attempt', 'woo-advanced-shipment-tracking' ),
|
191 |
-
),
|
192 |
-
)
|
193 |
-
) );
|
194 |
-
|
195 |
-
// Display Shipment Provider image/thumbnail
|
196 |
-
$wp_customize->add_setting( 'customizer_delivered_order_settings_enabled',
|
197 |
-
array(
|
198 |
-
'default' => $this->defaults['wcast_enable_delivered_email'],
|
199 |
-
'transport' => 'postMessage',
|
200 |
-
'type' => 'option',
|
201 |
-
'sanitize_callback' => ''
|
202 |
-
)
|
203 |
-
);
|
204 |
-
$wp_customize->add_control( 'customizer_delivered_order_settings_enabled',
|
205 |
-
array(
|
206 |
-
'label' => __( 'Enable Delivered order status email', 'woo-advanced-shipment-tracking' ),
|
207 |
-
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
208 |
-
'section' => 'custom_order_status_email',
|
209 |
-
'type' => 'checkbox',
|
210 |
-
'active_callback' => array( $this, 'active_callback' ),
|
211 |
-
)
|
212 |
-
);
|
213 |
-
|
214 |
-
// Header Text
|
215 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[recipient]',
|
216 |
-
array(
|
217 |
-
'default' => $this->defaults['wcast_delivered_email_to'],
|
218 |
-
'transport' => 'postMessage',
|
219 |
-
'type' => 'option',
|
220 |
-
'sanitize_callback' => ''
|
221 |
-
)
|
222 |
-
);
|
223 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[recipient]',
|
224 |
-
array(
|
225 |
-
'label' => __( 'Recipient(s)', 'woocommerce' ),
|
226 |
-
'description' => esc_html__( 'Enter emails here or use variables such as {customer_email}. Multiple emails can be separated by commas.', 'woocommerce' ),
|
227 |
-
'section' => 'custom_order_status_email',
|
228 |
-
'type' => 'text',
|
229 |
-
'input_attrs' => array(
|
230 |
-
'class' => '',
|
231 |
-
'style' => '',
|
232 |
-
'placeholder' => __( 'E.g. {customer.email}, admin@example.org', 'woo-advanced-shipment-tracking' ),
|
233 |
-
),
|
234 |
-
'active_callback' => array( $this, 'active_callback' ),
|
235 |
-
)
|
236 |
-
);
|
237 |
-
|
238 |
-
// Header Text
|
239 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[subject]',
|
240 |
-
array(
|
241 |
-
'default' => $this->defaults['wcast_delivered_email_subject'],
|
242 |
-
'transport' => 'postMessage',
|
243 |
-
'type' => 'option',
|
244 |
-
'sanitize_callback' => ''
|
245 |
-
)
|
246 |
-
);
|
247 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[subject]',
|
248 |
-
array(
|
249 |
-
'label' => __( 'Subject', 'woocommerce' ),
|
250 |
-
'description' => esc_html__( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {order_number}',
|
251 |
-
'section' => 'custom_order_status_email',
|
252 |
-
'type' => 'text',
|
253 |
-
'input_attrs' => array(
|
254 |
-
'class' => '',
|
255 |
-
'style' => '',
|
256 |
-
'placeholder' => __( $this->defaults['wcast_delivered_email_subject'], 'woo-advanced-shipment-tracking' ),
|
257 |
-
),
|
258 |
-
'active_callback' => array( $this, 'active_callback' ),
|
259 |
-
)
|
260 |
-
);
|
261 |
-
|
262 |
-
// Header Text
|
263 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[heading]',
|
264 |
-
array(
|
265 |
-
'default' => $this->defaults['wcast_delivered_email_heading'],
|
266 |
-
'transport' => 'postMessage',
|
267 |
-
'type' => 'option',
|
268 |
-
'sanitize_callback' => ''
|
269 |
-
)
|
270 |
-
);
|
271 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[heading]',
|
272 |
-
array(
|
273 |
-
'label' => __( 'Email heading', 'woocommerce' ),
|
274 |
-
'description' => esc_html__( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {order_number}',
|
275 |
-
'section' => 'custom_order_status_email',
|
276 |
-
'type' => 'text',
|
277 |
-
'input_attrs' => array(
|
278 |
-
'class' => '',
|
279 |
-
'style' => '',
|
280 |
-
'placeholder' => __( $this->defaults['wcast_delivered_email_heading'], 'woo-advanced-shipment-tracking' ),
|
281 |
-
),
|
282 |
-
'active_callback' => array( $this, 'active_callback' ),
|
283 |
-
)
|
284 |
-
);
|
285 |
-
|
286 |
-
|
287 |
-
// Test of TinyMCE control
|
288 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[wcast_delivered_email_content]',
|
289 |
-
array(
|
290 |
-
'default' => $this->defaults['wcast_delivered_email_content'],
|
291 |
-
'transport' => 'refresh',
|
292 |
-
'type' => 'option',
|
293 |
-
'sanitize_callback' => 'wp_kses_post'
|
294 |
-
)
|
295 |
-
);
|
296 |
-
$wp_customize->add_control( new Skyrocket_TinyMCE_Custom_control( $wp_customize, 'woocommerce_customer_delivered_order_settings[wcast_delivered_email_content]',
|
297 |
-
array(
|
298 |
-
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
299 |
-
'description' => '',
|
300 |
-
'section' => 'custom_order_status_email',
|
301 |
-
'input_attrs' => array(
|
302 |
-
'toolbar1' => 'bold italic bullist numlist alignleft aligncenter alignright link',
|
303 |
-
'mediaButtons' => true,
|
304 |
-
'placeholder' => __( $this->defaults['wcast_delivered_email_content'], 'woo-advanced-shipment-tracking' ),
|
305 |
-
),
|
306 |
-
'active_callback' => array( $this, 'active_callback' ),
|
307 |
-
)
|
308 |
-
) );
|
309 |
-
|
310 |
-
$wp_customize->add_setting( 'wcast_email_code_block',
|
311 |
-
array(
|
312 |
-
'default' => $this->defaults['wcast_email_code_block'],
|
313 |
-
'transport' => 'postMessage',
|
314 |
-
'sanitize_callback' => ''
|
315 |
-
)
|
316 |
-
);
|
317 |
-
$wp_customize->add_control( new WP_Customize_codeinfoblock_Control( $wp_customize, 'wcast_email_code_block',
|
318 |
-
array(
|
319 |
-
'label' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ),
|
320 |
-
'description' => '<code>{site_title}<br>{customer_email}<br>{customer_first_name}<br>{customer_last_name}<br>{customer_company_name}<br>{customer_username}<br>{order_number}</code>',
|
321 |
-
'section' => 'custom_order_status_email',
|
322 |
-
'active_callback' => array( $this, 'active_callback' ),
|
323 |
-
)
|
324 |
-
) );
|
325 |
-
|
326 |
-
// Display Shipment Provider image/thumbnail
|
327 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[wcast_show_tracking_details]',
|
328 |
-
array(
|
329 |
-
'default' => $this->defaults['wcast_show_tracking_details'],
|
330 |
-
'transport' => 'refresh',
|
331 |
-
'type' => 'option',
|
332 |
-
'sanitize_callback' => ''
|
333 |
-
)
|
334 |
-
);
|
335 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[wcast_show_tracking_details]',
|
336 |
-
array(
|
337 |
-
'label' => __( 'Display tracking details', 'woo-advanced-shipment-tracking' ),
|
338 |
-
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
339 |
-
'section' => 'custom_order_status_email',
|
340 |
-
'type' => 'checkbox',
|
341 |
-
'active_callback' => array( $this, 'active_callback' ),
|
342 |
-
)
|
343 |
-
);
|
344 |
-
// Display Shipment Provider image/thumbnail
|
345 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[wcast_show_order_details]',
|
346 |
-
array(
|
347 |
-
'default' => $this->defaults['wcast_show_order_details'],
|
348 |
-
'transport' => 'refresh',
|
349 |
-
'type' => 'option',
|
350 |
-
'sanitize_callback' => ''
|
351 |
-
)
|
352 |
-
);
|
353 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[wcast_show_order_details]',
|
354 |
-
array(
|
355 |
-
'label' => __( 'Display order details', 'woo-advanced-shipment-tracking' ),
|
356 |
-
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
357 |
-
'section' => 'custom_order_status_email',
|
358 |
-
'type' => 'checkbox',
|
359 |
-
'active_callback' => array( $this, 'active_callback' ),
|
360 |
-
)
|
361 |
-
);
|
362 |
-
|
363 |
-
// Display Shipment Provider image/thumbnail
|
364 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[wcast_show_shipping_address]',
|
365 |
-
array(
|
366 |
-
'default' => $this->defaults['wcast_show_shipping_address'],
|
367 |
-
'transport' => 'refresh',
|
368 |
-
'type' => 'option',
|
369 |
-
'sanitize_callback' => ''
|
370 |
-
)
|
371 |
-
);
|
372 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[wcast_show_shipping_address]',
|
373 |
-
array(
|
374 |
-
'label' => __( 'Display Shipping Address', 'woo-advanced-shipment-tracking' ),
|
375 |
-
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
376 |
-
'section' => 'custom_order_status_email',
|
377 |
-
'type' => 'checkbox',
|
378 |
-
'active_callback' => array( $this, 'active_callback' ),
|
379 |
-
)
|
380 |
-
);
|
381 |
-
|
382 |
-
// Display Shipment Provider image/thumbnail
|
383 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[wcast_show_billing_address]',
|
384 |
-
array(
|
385 |
-
'default' => $this->defaults['wcast_show_billing_address'],
|
386 |
-
'transport' => 'refresh',
|
387 |
-
'type' => 'option',
|
388 |
-
'sanitize_callback' => ''
|
389 |
-
)
|
390 |
-
);
|
391 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[wcast_show_billing_address]',
|
392 |
-
array(
|
393 |
-
'label' => __( 'Display Billing Address', 'woo-advanced-shipment-tracking' ),
|
394 |
-
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
395 |
-
'section' => 'custom_order_status_email',
|
396 |
-
'type' => 'checkbox',
|
397 |
-
'active_callback' => array( $this, 'active_callback' ),
|
398 |
-
)
|
399 |
-
);
|
400 |
-
|
401 |
-
// Display Shipment Provider image/thumbnail
|
402 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[wcast_enable_delivered_ga_tracking]',
|
403 |
-
array(
|
404 |
-
'default' => '',
|
405 |
-
'transport' => 'refresh',
|
406 |
-
'type' => 'option',
|
407 |
-
'sanitize_callback' => ''
|
408 |
-
)
|
409 |
-
);
|
410 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[wcast_enable_delivered_ga_tracking]',
|
411 |
-
array(
|
412 |
-
'label' => __( 'Enable Google Analytics tracking', 'woo-advanced-shipment-tracking' ),
|
413 |
-
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
414 |
-
'section' => 'custom_order_status_email',
|
415 |
-
'type' => 'checkbox',
|
416 |
-
'active_callback' => array( $this, 'active_callback' ),
|
417 |
-
)
|
418 |
-
);
|
419 |
-
|
420 |
-
|
421 |
-
$wp_customize->add_setting( 'woocommerce_customer_delivered_order_settings[wcast_delivered_analytics_link]',
|
422 |
-
array(
|
423 |
-
'default' => '',
|
424 |
-
'transport' => 'refresh',
|
425 |
-
'type' => 'option',
|
426 |
-
'sanitize_callback' => ''
|
427 |
-
)
|
428 |
-
);
|
429 |
-
$wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[wcast_delivered_analytics_link]',
|
430 |
-
array(
|
431 |
-
'label' => __( 'Google Analytics link tracking', 'woo-advanced-shipment-tracking' ),
|
432 |
-
'description' => esc_html__( 'This will be appended to URL in the email content – e.g. utm_source=ast&utm_medium=email&utm_campaign=delivered', 'woo-advanced-shipment-tracking' ),
|
433 |
-
'section' => 'custom_order_status_email',
|
434 |
-
'type' => 'text',
|
435 |
-
'input_attrs' => array(
|
436 |
-
'class' => '',
|
437 |
-
'style' => '',
|
438 |
-
'placeholder' => __( '', 'woo-advanced-shipment-tracking' ),
|
439 |
-
),
|
440 |
-
'active_callback' => array( $this, 'active_callback' ),
|
441 |
-
)
|
442 |
-
);
|
443 |
-
}
|
444 |
-
|
445 |
-
public function active_callback(){
|
446 |
-
if ( wcast_initialise_customizer_email::is_own_preview_request() ) {
|
447 |
-
return true;
|
448 |
-
} else{
|
449 |
-
return false;
|
450 |
-
}
|
451 |
-
}
|
452 |
-
|
453 |
-
/**
|
454 |
-
* Set up preview
|
455 |
-
*
|
456 |
-
* @access public
|
457 |
-
* @return void
|
458 |
-
*/
|
459 |
-
public function set_up_preview() {
|
460 |
-
|
461 |
-
// Make sure this is own preview request.
|
462 |
-
if ( ! wcast_initialise_customizer_email::is_own_preview_request() ) {
|
463 |
-
return;
|
464 |
-
}
|
465 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/delivered_preview.php';
|
466 |
-
exit;
|
467 |
-
}
|
468 |
-
|
469 |
-
/**
|
470 |
-
* code for preview of delivered order status email
|
471 |
-
*/
|
472 |
-
public function preview_delivered_email(){
|
473 |
-
// Load WooCommerce emails.
|
474 |
-
$wc_emails = WC_Emails::instance();
|
475 |
-
$emails = $wc_emails->get_emails();
|
476 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
477 |
-
|
478 |
-
if($preview_id == '' || $preview_id == 'mockup') {
|
479 |
-
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
480 |
-
echo $content;
|
481 |
-
return;
|
482 |
-
}
|
483 |
-
|
484 |
-
$order = wc_get_order( $preview_id );
|
485 |
-
|
486 |
-
if(!$order){
|
487 |
-
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
488 |
-
echo $content;
|
489 |
-
return;
|
490 |
-
}
|
491 |
-
|
492 |
-
$email_type = 'WC_Email_Customer_Delivered_Order';
|
493 |
-
|
494 |
-
if ( false === $email_type ) {
|
495 |
-
return false;
|
496 |
-
}
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
// Reference email.
|
501 |
-
if ( isset( $emails[ $email_type ] ) && is_object( $emails[ $email_type ] ) ) {
|
502 |
-
$email = $emails[ $email_type ];
|
503 |
-
}
|
504 |
-
$order_status = 'delivered';
|
505 |
-
// Get an order
|
506 |
-
$order = self::get_wc_order_for_preview( $order_status, $preview_id );
|
507 |
-
|
508 |
-
// Make sure gateways are running in case the email needs to input content from them.
|
509 |
-
WC()->payment_gateways();
|
510 |
-
// Make sure shipping is running in case the email needs to input content from it.
|
511 |
-
WC()->shipping();
|
512 |
-
|
513 |
-
$email->object = $order;
|
514 |
-
$email->find['order-date'] = '{order_date}';
|
515 |
-
$email->find['order-number'] = '{order_number}';
|
516 |
-
if ( is_object( $order ) ) {
|
517 |
-
$email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
|
518 |
-
$email->replace['order-number'] = $email->object->get_order_number();
|
519 |
-
// Other properties
|
520 |
-
$email->recipient = $email->object->get_billing_email();
|
521 |
-
}
|
522 |
-
|
523 |
-
// Get email content and apply styles.
|
524 |
-
$content = $email->get_content();
|
525 |
-
|
526 |
-
$content = $email->style_inline( $content );
|
527 |
-
$content = apply_filters( 'woocommerce_mail_content', $content );
|
528 |
-
|
529 |
-
echo $content;
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* Get WooCommerce order for preview
|
534 |
-
*
|
535 |
-
* @access public
|
536 |
-
* @param string $order_status
|
537 |
-
* @return object
|
538 |
-
*/
|
539 |
-
public static function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
|
540 |
-
if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
|
541 |
-
return wc_get_order( $order_id );
|
542 |
-
} else {
|
543 |
-
// Use mockup order
|
544 |
-
|
545 |
-
// Instantiate order object
|
546 |
-
$order = new WC_Order();
|
547 |
-
|
548 |
-
// Other order properties
|
549 |
-
$order->set_props( array(
|
550 |
-
'id' => 1,
|
551 |
-
'status' => ( null === $order_status ? 'processing' : $order_status ),
|
552 |
-
'billing_first_name' => 'Sherlock',
|
553 |
-
'billing_last_name' => 'Holmes',
|
554 |
-
'billing_company' => 'Detectives Ltd.',
|
555 |
-
'billing_address_1' => '221B Baker Street',
|
556 |
-
'billing_city' => 'London',
|
557 |
-
'billing_postcode' => 'NW1 6XE',
|
558 |
-
'billing_country' => 'GB',
|
559 |
-
'billing_email' => 'sherlock@holmes.co.uk',
|
560 |
-
'billing_phone' => '02079304832',
|
561 |
-
'date_created' => date( 'Y-m-d H:i:s' ),
|
562 |
-
'total' => 24.90,
|
563 |
-
) );
|
564 |
-
|
565 |
-
// Item #1
|
566 |
-
$order_item = new WC_Order_Item_Product();
|
567 |
-
$order_item->set_props( array(
|
568 |
-
'name' => 'A Study in Scarlet',
|
569 |
-
'subtotal' => '9.95',
|
570 |
-
'sku' => 'kwd_ex_1',
|
571 |
-
) );
|
572 |
-
$order->add_item( $order_item );
|
573 |
-
|
574 |
-
// Item #2
|
575 |
-
$order_item = new WC_Order_Item_Product();
|
576 |
-
$order_item->set_props( array(
|
577 |
-
'name' => 'The Hound of the Baskervilles',
|
578 |
-
'subtotal' => '14.95',
|
579 |
-
'sku' => 'kwd_ex_2',
|
580 |
-
) );
|
581 |
-
$order->add_item( $order_item );
|
582 |
-
|
583 |
-
// Return mockup order
|
584 |
-
return $order;
|
585 |
-
}
|
586 |
-
|
587 |
-
}
|
588 |
-
}
|
589 |
-
/**
|
590 |
-
* Initialise our Customizer settings
|
591 |
-
*/
|
592 |
-
|
593 |
-
$wcast_customizer_settings = new wcast_initialise_customizer_email();
|
594 |
-
add_action( 'customize_save_customizer_delivered_order_settings_enabled', 'woocommerce_customer_delivered_order_settings_fun', 100, 1 );
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Update Delivered order email enable/disable
|
598 |
-
*
|
599 |
-
*/
|
600 |
-
function woocommerce_customer_delivered_order_settings_fun($data){
|
601 |
-
$post_values = json_decode( wp_unslash( $_POST['customized'] ), true );
|
602 |
-
$delivered_order_settings = get_option( 'woocommerce_customer_delivered_order_settings');
|
603 |
-
|
604 |
-
if(isset($post_values['customizer_delivered_order_settings_enabled']) && ($post_values['customizer_delivered_order_settings_enabled'] == 1)){
|
605 |
-
$delivered_order_settings['enabled'] = 'yes';
|
606 |
-
} else{
|
607 |
-
$delivered_order_settings['enabled'] = 'no';
|
608 |
-
}
|
609 |
-
update_option( 'woocommerce_customer_delivered_order_settings',$delivered_order_settings);
|
610 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/customizer/class-wc-exception-email-customizer.php
ADDED
@@ -0,0 +1,402 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Customizer Setup and Custom Controls
|
4 |
+
*
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Adds the individual sections, settings, and controls to the theme customizer
|
9 |
+
*/
|
10 |
+
class wcast_exception_customizer_email {
|
11 |
+
// Get our default values
|
12 |
+
public function __construct() {
|
13 |
+
// Get our Customizer defaults
|
14 |
+
$this->defaults = $this->wcast_generate_defaults();
|
15 |
+
|
16 |
+
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
18 |
+
|
19 |
+
// Register our sample default controls
|
20 |
+
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
+
|
22 |
+
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
24 |
+
|
25 |
+
// Register our sections
|
26 |
+
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
27 |
+
|
28 |
+
// Remove unrelated components.
|
29 |
+
add_filter( 'customize_loaded_components', array( wcast_customizer(), 'remove_unrelated_components' ), 99, 2 );
|
30 |
+
|
31 |
+
// Remove unrelated sections.
|
32 |
+
add_filter( 'customize_section_active', array( wcast_customizer(), 'remove_unrelated_sections' ), 10, 2 );
|
33 |
+
|
34 |
+
// Unhook divi front end.
|
35 |
+
add_action( 'woomail_footer', array( wcast_customizer(), 'unhook_divi' ), 10 );
|
36 |
+
|
37 |
+
// Unhook Flatsome js
|
38 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'unhook_flatsome' ), 50 );
|
39 |
+
|
40 |
+
add_filter( 'customize_controls_enqueue_scripts', array( wcast_customizer(), 'enqueue_customizer_scripts' ) );
|
41 |
+
|
42 |
+
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
+
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Checks to see if we are opening our custom customizer preview
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @return bool
|
52 |
+
*/
|
53 |
+
public function is_own_preview_request() {
|
54 |
+
return isset( $_REQUEST['wcast-exception-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-exception-email-customizer-preview'];
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Checks to see if we are opening our custom customizer controls
|
59 |
+
*
|
60 |
+
* @access public
|
61 |
+
* @return bool
|
62 |
+
*/
|
63 |
+
public function is_own_customizer_request() {
|
64 |
+
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* code for initialize default value for customizer
|
69 |
+
*/
|
70 |
+
public function wcast_generate_defaults() {
|
71 |
+
$customizer_defaults = array(
|
72 |
+
'wcast_exception_email_subject' => __( 'Your order #{order_number} is Exception', 'woo-advanced-shipment-tracking' ),
|
73 |
+
'wcast_exception_email_heading' => __( 'Exception', 'woo-advanced-shipment-tracking' ),
|
74 |
+
'wcast_exception_email_content' => __( "Hi there. we thought you'd like to know that your recent order from {site_title} is Exception", 'woo-advanced-shipment-tracking' ),
|
75 |
+
'wcast_enable_exception_email' => '',
|
76 |
+
'wcast_exception_email_to' => '{customer_email}',
|
77 |
+
'wcast_exception_show_tracking_details' => '',
|
78 |
+
'wcast_exception_show_order_details' => 1,
|
79 |
+
'wcast_exception_hide_shipping_item_price' => 1,
|
80 |
+
'wcast_exception_show_shipping_address' => 1,
|
81 |
+
'wcast_exception_email_code_block' => '',
|
82 |
+
);
|
83 |
+
|
84 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Register our sample default controls
|
89 |
+
*/
|
90 |
+
public function wcast_register_sample_default_controls( $wp_customize ) {
|
91 |
+
/**
|
92 |
+
* Load all our Customizer Custom Controls
|
93 |
+
*/
|
94 |
+
require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
|
95 |
+
|
96 |
+
// Display Shipment Provider image/thumbnail
|
97 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_enable_exception_email]',
|
98 |
+
array(
|
99 |
+
'default' => $this->defaults['wcast_enable_exception_email'],
|
100 |
+
'transport' => 'postMessage',
|
101 |
+
'type' => 'option',
|
102 |
+
'sanitize_callback' => ''
|
103 |
+
)
|
104 |
+
);
|
105 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_enable_exception_email]',
|
106 |
+
array(
|
107 |
+
'label' => __( 'Enable Exception email', 'woo-advanced-shipment-tracking' ),
|
108 |
+
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
109 |
+
'section' => 'trackship_shipment_status_email',
|
110 |
+
'type' => 'checkbox',
|
111 |
+
'active_callback' => array( $this, 'active_callback' ),
|
112 |
+
)
|
113 |
+
);
|
114 |
+
|
115 |
+
// Header Text
|
116 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_email_to]',
|
117 |
+
array(
|
118 |
+
'default' => $this->defaults['wcast_exception_email_to'],
|
119 |
+
'transport' => 'postMessage',
|
120 |
+
'type' => 'option',
|
121 |
+
'sanitize_callback' => ''
|
122 |
+
)
|
123 |
+
);
|
124 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_exception_email_to]',
|
125 |
+
array(
|
126 |
+
'label' => __( 'Recipient(s)', 'woocommerce' ),
|
127 |
+
'description' => esc_html__( 'Enter emails here or use variables such as {customer_email}. Multiple emails can be separated by commas.', 'woocommerce' ),
|
128 |
+
'section' => 'trackship_shipment_status_email',
|
129 |
+
'type' => 'text',
|
130 |
+
'input_attrs' => array(
|
131 |
+
'class' => '',
|
132 |
+
'style' => '',
|
133 |
+
'placeholder' => __( 'E.g. {customer.email}, admin@example.org', 'woo-advanced-shipment-tracking' ),
|
134 |
+
),
|
135 |
+
'active_callback' => array( $this, 'active_callback' ),
|
136 |
+
)
|
137 |
+
);
|
138 |
+
|
139 |
+
// Header Text
|
140 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_email_subject]',
|
141 |
+
array(
|
142 |
+
'default' => $this->defaults['wcast_exception_email_subject'],
|
143 |
+
'transport' => 'postMessage',
|
144 |
+
'type' => 'option',
|
145 |
+
'sanitize_callback' => ''
|
146 |
+
)
|
147 |
+
);
|
148 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_exception_email_subject]',
|
149 |
+
array(
|
150 |
+
'label' => __( 'Email Subject', 'woo-advanced-shipment-tracking' ),
|
151 |
+
'description' => esc_html__( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {order_number}',
|
152 |
+
'section' => 'trackship_shipment_status_email',
|
153 |
+
'type' => 'text',
|
154 |
+
'input_attrs' => array(
|
155 |
+
'class' => '',
|
156 |
+
'style' => '',
|
157 |
+
'placeholder' => __( $this->defaults['wcast_exception_email_subject'], 'woo-advanced-shipment-tracking' ),
|
158 |
+
),
|
159 |
+
'active_callback' => array( $this, 'active_callback' ),
|
160 |
+
)
|
161 |
+
);
|
162 |
+
|
163 |
+
// Header Text
|
164 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_email_heading]',
|
165 |
+
array(
|
166 |
+
'default' => $this->defaults['wcast_exception_email_heading'],
|
167 |
+
'transport' => 'refresh',
|
168 |
+
'type' => 'option',
|
169 |
+
'sanitize_callback' => ''
|
170 |
+
)
|
171 |
+
);
|
172 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_exception_email_heading]',
|
173 |
+
array(
|
174 |
+
'label' => __( 'Email heading', 'woocommerce' ),
|
175 |
+
'description' => esc_html__( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {order_number}',
|
176 |
+
'section' => 'trackship_shipment_status_email',
|
177 |
+
'type' => 'text',
|
178 |
+
'input_attrs' => array(
|
179 |
+
'class' => '',
|
180 |
+
'style' => '',
|
181 |
+
'placeholder' => __( $this->defaults['wcast_exception_email_heading'], 'woo-advanced-shipment-tracking' ),
|
182 |
+
),
|
183 |
+
'active_callback' => array( $this, 'active_callback' ),
|
184 |
+
)
|
185 |
+
);
|
186 |
+
|
187 |
+
// Test of TinyMCE control
|
188 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_email_content]',
|
189 |
+
array(
|
190 |
+
'default' => $this->defaults['wcast_exception_email_content'],
|
191 |
+
'transport' => 'refresh',
|
192 |
+
'type' => 'option',
|
193 |
+
'sanitize_callback' => 'wp_kses_post'
|
194 |
+
)
|
195 |
+
);
|
196 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_exception_email_settings[wcast_exception_email_content]',
|
197 |
+
array(
|
198 |
+
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
199 |
+
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
200 |
+
'section' => 'trackship_shipment_status_email',
|
201 |
+
'input_attrs' => array(
|
202 |
+
'toolbar1' => 'bold italic bullist numlist alignleft aligncenter alignright link',
|
203 |
+
'mediaButtons' => true,
|
204 |
+
'placeholder' => __( $this->defaults['wcast_exception_email_content'], 'woo-advanced-shipment-tracking' ),
|
205 |
+
),
|
206 |
+
'active_callback' => array( $this, 'active_callback' ),
|
207 |
+
)
|
208 |
+
) );
|
209 |
+
|
210 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_email_code_block]',
|
211 |
+
array(
|
212 |
+
'default' => $this->defaults['wcast_exception_email_code_block'],
|
213 |
+
'transport' => 'postMessage',
|
214 |
+
'type' => 'option',
|
215 |
+
'sanitize_callback' => ''
|
216 |
+
)
|
217 |
+
);
|
218 |
+
$wp_customize->add_control( new WP_Customize_codeinfoblock_Control( $wp_customize, 'wcast_exception_email_settings[wcast_exception_email_code_block]',
|
219 |
+
array(
|
220 |
+
'label' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ),
|
221 |
+
'description' => '<code>{site_title}<br>{customer_email}<br>{customer_first_name}<br>{customer_last_name}<br>{customer_company_name}<br>{customer_username}<br>{order_number}<br>{est_delivery_date}</code>',
|
222 |
+
'section' => 'trackship_shipment_status_email',
|
223 |
+
'active_callback' => array( $this, 'active_callback' ),
|
224 |
+
)
|
225 |
+
) );
|
226 |
+
|
227 |
+
// Display Shipment Provider image/thumbnail
|
228 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_show_order_details]',
|
229 |
+
array(
|
230 |
+
'default' => $this->defaults['wcast_exception_show_order_details'],
|
231 |
+
'transport' => 'refresh',
|
232 |
+
'type' => 'option',
|
233 |
+
'sanitize_callback' => ''
|
234 |
+
)
|
235 |
+
);
|
236 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_exception_show_order_details]',
|
237 |
+
array(
|
238 |
+
'label' => __( 'Display the Shipping items', 'woo-advanced-shipment-tracking' ),
|
239 |
+
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
240 |
+
'section' => 'trackship_shipment_status_email',
|
241 |
+
'type' => 'checkbox',
|
242 |
+
'active_callback' => array( $this, 'active_callback' ),
|
243 |
+
)
|
244 |
+
);
|
245 |
+
|
246 |
+
// Display Shipment Provider image/thumbnail
|
247 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_hide_shipping_item_price]',
|
248 |
+
array(
|
249 |
+
'default' => $this->defaults['wcast_exception_hide_shipping_item_price'],
|
250 |
+
'transport' => 'refresh',
|
251 |
+
'type' => 'option',
|
252 |
+
'sanitize_callback' => ''
|
253 |
+
)
|
254 |
+
);
|
255 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_exception_hide_shipping_item_price]',
|
256 |
+
array(
|
257 |
+
'label' => __( 'Hide Shipping Items Price', 'woo-advanced-shipment-tracking' ),
|
258 |
+
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
259 |
+
'section' => 'trackship_shipment_status_email',
|
260 |
+
'type' => 'checkbox',
|
261 |
+
'active_callback' => array( $this, 'active_callback_only_show_order_details' ),
|
262 |
+
)
|
263 |
+
);
|
264 |
+
|
265 |
+
// Display Shipment Provider image/thumbnail
|
266 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_show_shipping_address]',
|
267 |
+
array(
|
268 |
+
'default' => $this->defaults['wcast_exception_show_shipping_address'],
|
269 |
+
'transport' => 'refresh',
|
270 |
+
'type' => 'option',
|
271 |
+
'sanitize_callback' => ''
|
272 |
+
)
|
273 |
+
);
|
274 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_exception_show_shipping_address]',
|
275 |
+
array(
|
276 |
+
'label' => __( 'Display the shipping address', 'woo-advanced-shipment-tracking' ),
|
277 |
+
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
278 |
+
'section' => 'trackship_shipment_status_email',
|
279 |
+
'type' => 'checkbox',
|
280 |
+
'active_callback' => array( $this, 'active_callback' ),
|
281 |
+
)
|
282 |
+
);
|
283 |
+
|
284 |
+
$wp_customize->add_setting( 'wcast_exception_email_settings[wcast_exception_analytics_link]',
|
285 |
+
array(
|
286 |
+
'default' => '',
|
287 |
+
'transport' => 'refresh',
|
288 |
+
'type' => 'option',
|
289 |
+
'sanitize_callback' => ''
|
290 |
+
)
|
291 |
+
);
|
292 |
+
$wp_customize->add_control( 'wcast_exception_email_settings[wcast_exception_analytics_link]',
|
293 |
+
array(
|
294 |
+
'label' => __( 'Google Analytics link tracking', 'woo-advanced-shipment-tracking' ),
|
295 |
+
'description' => esc_html__( 'This will be appended to URL in the email content', 'woo-advanced-shipment-tracking' ),
|
296 |
+
'section' => 'trackship_shipment_status_email',
|
297 |
+
'type' => 'text',
|
298 |
+
'input_attrs' => array(
|
299 |
+
'class' => '',
|
300 |
+
'style' => '',
|
301 |
+
'placeholder' => __( '', 'woo-advanced-shipment-tracking' ),
|
302 |
+
),
|
303 |
+
'active_callback' => array( $this, 'active_callback' ),
|
304 |
+
)
|
305 |
+
);
|
306 |
+
}
|
307 |
+
|
308 |
+
public function active_callback(){
|
309 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
310 |
+
}
|
311 |
+
|
312 |
+
public function active_callback_only_show_order_details(){
|
313 |
+
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
314 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_exception_email_settings','wcast_exception_show_order_details',$this->defaults['wcast_exception_show_order_details']);
|
315 |
+
|
316 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Set up preview
|
321 |
+
*
|
322 |
+
* @access public
|
323 |
+
* @return void
|
324 |
+
*/
|
325 |
+
public function set_up_preview() {
|
326 |
+
|
327 |
+
// Make sure this is own preview request.
|
328 |
+
if ( ! $this->is_own_preview_request() )return;
|
329 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/exception_preview.php';exit;
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* code for preview of exception email
|
334 |
+
*/
|
335 |
+
public function preview_exception_email(){
|
336 |
+
|
337 |
+
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
338 |
+
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
339 |
+
|
340 |
+
$email_heading = $ast->get_option_value_from_array('wcast_exception_email_settings','wcast_exception_email_heading',$this->defaults['wcast_exception_email_heading']);
|
341 |
+
$email_content = $ast->get_option_value_from_array('wcast_exception_email_settings','wcast_exception_email_content',$this->defaults['wcast_exception_email_content']);
|
342 |
+
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_exception_email_settings','wcast_exception_show_order_details',$this->defaults['wcast_exception_show_order_details']);
|
343 |
+
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_exception_email_settings','wcast_exception_hide_shipping_item_price',$this->defaults['wcast_exception_hide_shipping_item_price']);
|
344 |
+
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_exception_email_settings','wcast_exception_show_shipping_address',$this->defaults['wcast_exception_show_shipping_address']);
|
345 |
+
|
346 |
+
if($preview_id == '' || $preview_id == 'mockup') {
|
347 |
+
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
348 |
+
echo $content;
|
349 |
+
return;
|
350 |
+
}
|
351 |
+
|
352 |
+
$order = wc_get_order( $preview_id );
|
353 |
+
|
354 |
+
if(!$order){
|
355 |
+
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
356 |
+
echo $content;
|
357 |
+
return;
|
358 |
+
}
|
359 |
+
|
360 |
+
// get the preview email subject
|
361 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
362 |
+
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
363 |
+
|
364 |
+
$wcast_exception_analytics_link = $ast->get_option_value_from_array('wcast_exception_email_settings','wcast_exception_analytics_link','');
|
365 |
+
if($wcast_exception_analytics_link){
|
366 |
+
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
367 |
+
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
368 |
+
}
|
369 |
+
|
370 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
371 |
+
$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'exception' );
|
372 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
373 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
374 |
+
|
375 |
+
// create a new email
|
376 |
+
$email = new WC_Email();
|
377 |
+
$mailer = WC()->mailer();
|
378 |
+
|
379 |
+
// wrap the content with the email template and then add styles
|
380 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* code for append analytics link in email content
|
385 |
+
*/
|
386 |
+
public function _appendCampaignToString($match){
|
387 |
+
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
388 |
+
$wcast_exception_analytics_link = $ast->get_option_value_from_array('wcast_exception_email_settings','wcast_exception_analytics_link','');
|
389 |
+
|
390 |
+
$url = $match[2];
|
391 |
+
if (strpos($url, '?') === false) {
|
392 |
+
$url .= '?';
|
393 |
+
}
|
394 |
+
$url .= $wcast_exception_analytics_link;
|
395 |
+
return $match[1].$url.$match[3];
|
396 |
+
}
|
397 |
+
}
|
398 |
+
/**
|
399 |
+
* Initialise our Customizer settings
|
400 |
+
*/
|
401 |
+
|
402 |
+
$wcast_exception_customizer_email = new wcast_exception_customizer_email();
|
includes/customizer/class-wc-failure-email-customizer.php
CHANGED
@@ -12,18 +12,16 @@ class wcast_failure_customizer_email {
|
|
12 |
public function __construct() {
|
13 |
// Get our Customizer defaults
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
|
|
15 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
16 |
-
if(!$wc_ast_api_key)
|
17 |
-
|
18 |
-
}
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
-
if ( !
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
// Register our sections
|
28 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
29 |
|
@@ -43,31 +41,7 @@ class wcast_failure_customizer_email {
|
|
43 |
|
44 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
45 |
|
46 |
-
add_action( 'customize_preview_init', array(
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* add css and js for preview
|
52 |
-
*/
|
53 |
-
public function enqueue_preview_scripts() {
|
54 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
55 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
56 |
-
// Send variables to Javascript
|
57 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
58 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
59 |
-
'site_title' => $this->get_blogname(),
|
60 |
-
'order_number' => $preview_id,
|
61 |
-
));
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Get blog name formatted for emails.
|
66 |
-
*
|
67 |
-
* @return string
|
68 |
-
*/
|
69 |
-
public function get_blogname() {
|
70 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -76,7 +50,7 @@ class wcast_failure_customizer_email {
|
|
76 |
* @access public
|
77 |
* @return bool
|
78 |
*/
|
79 |
-
public
|
80 |
return isset( $_REQUEST['wcast-failure-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-failure-email-customizer-preview'];
|
81 |
}
|
82 |
|
@@ -86,37 +60,10 @@ class wcast_failure_customizer_email {
|
|
86 |
* @access public
|
87 |
* @return bool
|
88 |
*/
|
89 |
-
public
|
90 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
91 |
}
|
92 |
|
93 |
-
/**
|
94 |
-
* Get Customizer URL
|
95 |
-
*
|
96 |
-
*/
|
97 |
-
public static function get_customizer_url( $email, $shipment_status, $return_tab ) {
|
98 |
-
$customizer_url = add_query_arg( array(
|
99 |
-
'wcast-customizer' => '1',
|
100 |
-
'email' => $email,
|
101 |
-
'shipment_status' => $shipment_status,
|
102 |
-
'autofocus[section]' => 'trackship_shipment_status_email',
|
103 |
-
'url' => urlencode( add_query_arg( array( 'wcast-failure-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
104 |
-
'return' => urlencode( wcast_failure_customizer_email::get_email_settings_page_url($return_tab) ),
|
105 |
-
), admin_url( 'customize.php' ) );
|
106 |
-
|
107 |
-
return $customizer_url;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Get WooCommerce email settings page URL
|
112 |
-
*
|
113 |
-
* @access public
|
114 |
-
* @return string
|
115 |
-
*/
|
116 |
-
public static function get_email_settings_page_url($return_tab) {
|
117 |
-
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
118 |
-
}
|
119 |
-
|
120 |
/**
|
121 |
* code for initialize default value for customizer
|
122 |
*/
|
@@ -134,7 +81,7 @@ class wcast_failure_customizer_email {
|
|
134 |
'wcast_failure_email_code_block' => '',
|
135 |
);
|
136 |
|
137 |
-
return apply_filters( '
|
138 |
}
|
139 |
|
140 |
/**
|
@@ -246,7 +193,7 @@ class wcast_failure_customizer_email {
|
|
246 |
'sanitize_callback' => 'wp_kses_post'
|
247 |
)
|
248 |
);
|
249 |
-
$wp_customize->add_control( new
|
250 |
array(
|
251 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
252 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
@@ -359,23 +306,15 @@ class wcast_failure_customizer_email {
|
|
359 |
}
|
360 |
|
361 |
public function active_callback(){
|
362 |
-
|
363 |
-
return true;
|
364 |
-
} else{
|
365 |
-
return false;
|
366 |
-
}
|
367 |
}
|
368 |
|
369 |
public function active_callback_only_show_order_details(){
|
370 |
|
371 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
372 |
-
$show_order_details = $ast->
|
373 |
|
374 |
-
|
375 |
-
return true;
|
376 |
-
} else{
|
377 |
-
return false;
|
378 |
-
}
|
379 |
}
|
380 |
|
381 |
/**
|
@@ -387,41 +326,23 @@ class wcast_failure_customizer_email {
|
|
387 |
public function set_up_preview() {
|
388 |
|
389 |
// Make sure this is own preview request.
|
390 |
-
if ( !
|
391 |
-
|
392 |
-
}
|
393 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/failure_preview.php';
|
394 |
-
exit;
|
395 |
}
|
396 |
|
397 |
/**
|
398 |
* code for preview of failure email
|
399 |
*/
|
400 |
public function preview_failure_email(){
|
401 |
-
|
402 |
-
$wc_emails = WC_Emails::instance();
|
403 |
-
$emails = $wc_emails->get_emails();
|
404 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
405 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
406 |
|
407 |
-
$order_id = $ast->get_custom_order_number( $preview_id );
|
408 |
-
|
409 |
$email_heading = $ast->get_option_value_from_array('wcast_failure_email_settings','wcast_failure_email_heading',$this->defaults['wcast_failure_email_heading']);
|
410 |
-
|
411 |
-
$email_heading = str_replace( '{site_title}', $this->get_blogname(), $email_heading );
|
412 |
-
$email_heading = str_replace( '{order_number}', $order_id, $email_heading );
|
413 |
-
|
414 |
$email_content = $ast->get_option_value_from_array('wcast_failure_email_settings','wcast_failure_email_content',$this->defaults['wcast_failure_email_content']);
|
415 |
-
|
416 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_failure_email_settings','wcast_failure_show_order_details',$this->defaults['wcast_failure_show_order_details']);
|
417 |
-
|
418 |
-
$
|
419 |
-
|
420 |
-
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_failure_email_settings','wcast_failure_show_shipping_address',$this->defaults['wcast_failure_show_shipping_address']);
|
421 |
-
|
422 |
-
$sent_to_admin = false;
|
423 |
-
$plain_text = false;
|
424 |
-
$email = '';
|
425 |
|
426 |
if($preview_id == '' || $preview_id == 'mockup') {
|
427 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
@@ -437,78 +358,27 @@ class wcast_failure_customizer_email {
|
|
437 |
return;
|
438 |
}
|
439 |
|
440 |
-
$mailer = WC()->mailer();
|
441 |
-
|
442 |
// get the preview email subject
|
443 |
-
$email_heading =
|
444 |
-
|
445 |
-
|
446 |
-
$message = wc_trackship_email_manager()->email_content($email_content,$preview_id,$order);
|
447 |
|
448 |
$wcast_failure_analytics_link = $ast->get_option_value_from_array('wcast_failure_email_settings','wcast_failure_analytics_link','');
|
449 |
-
|
450 |
if($wcast_failure_analytics_link){
|
451 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
452 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
453 |
}
|
454 |
|
455 |
-
$
|
456 |
-
|
457 |
-
|
458 |
-
$
|
459 |
-
|
460 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
461 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
462 |
-
'order_id' => $preview_id,
|
463 |
-
'show_shipment_status' => true,
|
464 |
-
'new_status' => 'failure',
|
465 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
466 |
-
} else{
|
467 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
468 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
469 |
-
'order_id' => $preview_id,
|
470 |
-
'show_shipment_status' => true,
|
471 |
-
'new_status' => 'failure',
|
472 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
473 |
-
}
|
474 |
-
$message .= ob_get_clean();
|
475 |
-
|
476 |
-
if($wcast_show_order_details == 1){
|
477 |
-
|
478 |
-
ob_start();
|
479 |
-
wc_get_template(
|
480 |
-
'emails/wcast-email-order-details.php', array(
|
481 |
-
'order' => $order,
|
482 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
483 |
-
'sent_to_admin' => $sent_to_admin,
|
484 |
-
'plain_text' => $plain_text,
|
485 |
-
'email' => $email,
|
486 |
-
),
|
487 |
-
'woocommerce-advanced-shipment-tracking/',
|
488 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
489 |
-
);
|
490 |
-
$message .= ob_get_clean();
|
491 |
-
}
|
492 |
-
|
493 |
-
if($wcast_show_shipping_address == 1){
|
494 |
-
ob_start();
|
495 |
-
wc_get_template(
|
496 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
497 |
-
'order' => $order,
|
498 |
-
'sent_to_admin' => $sent_to_admin,
|
499 |
-
),
|
500 |
-
'woocommerce-advanced-shipment-tracking/',
|
501 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
502 |
-
);
|
503 |
-
$message .= ob_get_clean();
|
504 |
-
}
|
505 |
// create a new email
|
506 |
$email = new WC_Email();
|
507 |
-
$
|
508 |
|
509 |
// wrap the content with the email template and then add styles
|
510 |
-
|
511 |
-
echo $message;
|
512 |
}
|
513 |
|
514 |
/**
|
12 |
public function __construct() {
|
13 |
// Get our Customizer defaults
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
+
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
18 |
+
|
|
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
24 |
+
|
|
|
|
|
25 |
// Register our sections
|
26 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
27 |
|
41 |
|
42 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
/**
|
50 |
* @access public
|
51 |
* @return bool
|
52 |
*/
|
53 |
+
public function is_own_preview_request() {
|
54 |
return isset( $_REQUEST['wcast-failure-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-failure-email-customizer-preview'];
|
55 |
}
|
56 |
|
60 |
* @access public
|
61 |
* @return bool
|
62 |
*/
|
63 |
+
public function is_own_customizer_request() {
|
64 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
/**
|
68 |
* code for initialize default value for customizer
|
69 |
*/
|
81 |
'wcast_failure_email_code_block' => '',
|
82 |
);
|
83 |
|
84 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
85 |
}
|
86 |
|
87 |
/**
|
193 |
'sanitize_callback' => 'wp_kses_post'
|
194 |
)
|
195 |
);
|
196 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_failure_email_settings[wcast_failure_email_content]',
|
197 |
array(
|
198 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
199 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
306 |
}
|
307 |
|
308 |
public function active_callback(){
|
309 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
310 |
}
|
311 |
|
312 |
public function active_callback_only_show_order_details(){
|
313 |
|
314 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
315 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_failure_email_settings','wcast_failure_show_order_details',$this->defaults['wcast_failure_show_order_details']);
|
316 |
|
317 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
|
|
|
|
|
|
|
|
318 |
}
|
319 |
|
320 |
/**
|
326 |
public function set_up_preview() {
|
327 |
|
328 |
// Make sure this is own preview request.
|
329 |
+
if ( ! $this->is_own_preview_request() )return;
|
330 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/failure_preview.php';exit;
|
|
|
|
|
|
|
331 |
}
|
332 |
|
333 |
/**
|
334 |
* code for preview of failure email
|
335 |
*/
|
336 |
public function preview_failure_email(){
|
337 |
+
|
|
|
|
|
338 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
339 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
340 |
|
|
|
|
|
341 |
$email_heading = $ast->get_option_value_from_array('wcast_failure_email_settings','wcast_failure_email_heading',$this->defaults['wcast_failure_email_heading']);
|
|
|
|
|
|
|
|
|
342 |
$email_content = $ast->get_option_value_from_array('wcast_failure_email_settings','wcast_failure_email_content',$this->defaults['wcast_failure_email_content']);
|
|
|
343 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_failure_email_settings','wcast_failure_show_order_details',$this->defaults['wcast_failure_show_order_details']);
|
344 |
+
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_failure_email_settings','wcast_failure_hide_shipping_item_price',$this->defaults['wcast_failure_hide_shipping_item_price']);
|
345 |
+
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_failure_email_settings','wcast_failure_show_shipping_address',$this->defaults['wcast_failure_show_shipping_address']);
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
if($preview_id == '' || $preview_id == 'mockup') {
|
348 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
358 |
return;
|
359 |
}
|
360 |
|
|
|
|
|
361 |
// get the preview email subject
|
362 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
363 |
+
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
|
|
|
|
364 |
|
365 |
$wcast_failure_analytics_link = $ast->get_option_value_from_array('wcast_failure_email_settings','wcast_failure_analytics_link','');
|
|
|
366 |
if($wcast_failure_analytics_link){
|
367 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
368 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
369 |
}
|
370 |
|
371 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
372 |
+
$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'failure' );
|
373 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
374 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
375 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
// create a new email
|
377 |
$email = new WC_Email();
|
378 |
+
$mailer = WC()->mailer();
|
379 |
|
380 |
// wrap the content with the email template and then add styles
|
381 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
|
|
382 |
}
|
383 |
|
384 |
/**
|
includes/customizer/class-wc-intransit-email-customizer.php
CHANGED
@@ -14,18 +14,13 @@ class wcast_intransit_customizer_email {
|
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
-
|
18 |
-
if(!$wc_ast_api_key){
|
19 |
-
return;
|
20 |
-
}
|
21 |
|
22 |
// Register our sample default controls
|
23 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
24 |
|
25 |
// Only proceed if this is own request.
|
26 |
-
if ( !
|
27 |
-
return;
|
28 |
-
}
|
29 |
|
30 |
// Register our sections
|
31 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
@@ -46,40 +41,16 @@ class wcast_intransit_customizer_email {
|
|
46 |
|
47 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
48 |
|
49 |
-
add_action( 'customize_preview_init', array(
|
50 |
-
|
51 |
}
|
52 |
|
53 |
-
/**
|
54 |
-
* add css and js for preview
|
55 |
-
*/
|
56 |
-
public function enqueue_preview_scripts() {
|
57 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
58 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
59 |
-
// Send variables to Javascript
|
60 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
61 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
62 |
-
'site_title' => $this->get_blogname(),
|
63 |
-
'order_number' => $preview_id,
|
64 |
-
));
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Get blog name formatted for emails.
|
69 |
-
*
|
70 |
-
* @return string
|
71 |
-
*/
|
72 |
-
public function get_blogname() {
|
73 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
74 |
-
}
|
75 |
-
|
76 |
/**
|
77 |
* Checks to see if we are opening our custom customizer preview
|
78 |
*
|
79 |
* @access public
|
80 |
* @return bool
|
81 |
*/
|
82 |
-
public
|
83 |
return isset( $_REQUEST['wcast-intransit-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-intransit-email-customizer-preview'];
|
84 |
}
|
85 |
|
@@ -89,7 +60,7 @@ class wcast_intransit_customizer_email {
|
|
89 |
* @access public
|
90 |
* @return bool
|
91 |
*/
|
92 |
-
public
|
93 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
94 |
}
|
95 |
|
@@ -97,17 +68,16 @@ class wcast_intransit_customizer_email {
|
|
97 |
* Get Customizer URL
|
98 |
*
|
99 |
*/
|
100 |
-
public
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
return $customizer_url;
|
111 |
}
|
112 |
|
113 |
/**
|
@@ -116,8 +86,8 @@ class wcast_intransit_customizer_email {
|
|
116 |
* @access public
|
117 |
* @return string
|
118 |
*/
|
119 |
-
public
|
120 |
-
return admin_url( 'admin.php?page=
|
121 |
}
|
122 |
|
123 |
/**
|
@@ -136,7 +106,7 @@ class wcast_intransit_customizer_email {
|
|
136 |
'wcast_intransit_email_code_block' => '',
|
137 |
);
|
138 |
|
139 |
-
return apply_filters( '
|
140 |
}
|
141 |
|
142 |
/**
|
@@ -156,7 +126,7 @@ class wcast_intransit_customizer_email {
|
|
156 |
'sanitize_callback' => ''
|
157 |
)
|
158 |
);
|
159 |
-
$wp_customize->add_control( new
|
160 |
array(
|
161 |
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
162 |
'description' => '',
|
@@ -178,7 +148,7 @@ class wcast_intransit_customizer_email {
|
|
178 |
'type' => 'option',
|
179 |
)
|
180 |
);
|
181 |
-
$wp_customize->add_control( new
|
182 |
array(
|
183 |
'label' => __( 'Shipment Status', 'woo-advanced-shipment-tracking' ),
|
184 |
'description' => '',
|
@@ -195,6 +165,7 @@ class wcast_intransit_customizer_email {
|
|
195 |
'out_for_delivery' => __( 'Out For Delivery', 'woo-advanced-shipment-tracking' ),
|
196 |
'delivered' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
|
197 |
'failure' => __( 'Failed Attempt', 'woo-advanced-shipment-tracking' ),
|
|
|
198 |
),
|
199 |
)
|
200 |
) );
|
@@ -299,7 +270,7 @@ class wcast_intransit_customizer_email {
|
|
299 |
'sanitize_callback' => 'wp_kses_post'
|
300 |
)
|
301 |
);
|
302 |
-
$wp_customize->add_control( new
|
303 |
array(
|
304 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
305 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
@@ -412,23 +383,13 @@ class wcast_intransit_customizer_email {
|
|
412 |
}
|
413 |
|
414 |
public function active_callback(){
|
415 |
-
|
416 |
-
return true;
|
417 |
-
} else{
|
418 |
-
return false;
|
419 |
-
}
|
420 |
}
|
421 |
|
422 |
public function active_callback_only_show_order_details(){
|
423 |
-
|
424 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
425 |
-
$show_order_details = $ast->
|
426 |
-
|
427 |
-
if ( wcast_intransit_customizer_email::is_own_preview_request() && $show_order_details ) {
|
428 |
-
return true;
|
429 |
-
} else{
|
430 |
-
return false;
|
431 |
-
}
|
432 |
}
|
433 |
|
434 |
/**
|
@@ -438,43 +399,25 @@ class wcast_intransit_customizer_email {
|
|
438 |
* @return void
|
439 |
*/
|
440 |
public function set_up_preview() {
|
441 |
-
|
442 |
// Make sure this is own preview request.
|
443 |
-
if ( !
|
444 |
-
|
445 |
-
}
|
446 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/intransit_preview.php';
|
447 |
-
exit;
|
448 |
}
|
449 |
|
450 |
/**
|
451 |
* code for preview of in transit email
|
452 |
*/
|
453 |
public function preview_intransit_email(){
|
454 |
-
|
455 |
-
$
|
456 |
-
$emails = $wc_emails->get_emails();
|
457 |
-
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
458 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
459 |
|
460 |
-
$order_id = $ast->get_custom_order_number( $preview_id );
|
461 |
-
|
462 |
$email_heading = $ast->get_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_email_heading',$this->defaults['wcast_intransit_email_heading']);
|
463 |
-
$email_heading = str_replace( '{site_title}', $this->get_blogname(), $email_heading );
|
464 |
-
$email_heading = str_replace( '{order_number}', $order_id, $email_heading );
|
465 |
-
|
466 |
$email_content = $ast->get_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_email_content',$this->defaults['wcast_intransit_email_content']);
|
467 |
-
|
468 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_show_order_details',$this->defaults['wcast_intransit_show_order_details']);
|
469 |
-
|
470 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_hide_shipping_item_price',$this->defaults['wcast_intransit_hide_shipping_item_price']);
|
471 |
-
|
472 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_show_shipping_address',$this->defaults['wcast_intransit_show_shipping_address']);
|
473 |
|
474 |
-
$sent_to_admin = false;
|
475 |
-
$plain_text = false;
|
476 |
-
$email = '';
|
477 |
-
|
478 |
if($preview_id == '' || $preview_id == 'mockup') {
|
479 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
480 |
echo $content;
|
@@ -487,78 +430,29 @@ class wcast_intransit_customizer_email {
|
|
487 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
488 |
echo $content;
|
489 |
return;
|
490 |
-
}
|
491 |
-
|
492 |
-
$mailer = WC()->mailer();
|
493 |
|
494 |
// get the preview email subject
|
495 |
-
$email_heading =
|
496 |
-
//ob_start();
|
497 |
-
|
498 |
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
499 |
|
500 |
$wcast_intransit_analytics_link = $ast->get_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_analytics_link','');
|
501 |
-
|
502 |
if($wcast_intransit_analytics_link){
|
503 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
504 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
505 |
}
|
506 |
-
|
507 |
-
$wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
508 |
|
509 |
-
|
510 |
-
$
|
511 |
-
if
|
512 |
-
|
513 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
514 |
-
'order_id' => $preview_id,
|
515 |
-
'show_shipment_status' => true,
|
516 |
-
'new_status' => 'in_transit',
|
517 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
518 |
-
} else{
|
519 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
520 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
521 |
-
'order_id' => $preview_id,
|
522 |
-
'show_shipment_status' => true,
|
523 |
-
'new_status' => 'in_transit',
|
524 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
525 |
-
}
|
526 |
-
$message .= ob_get_clean();
|
527 |
|
528 |
-
if($wcast_show_order_details == 1){
|
529 |
-
ob_start();
|
530 |
-
wc_get_template(
|
531 |
-
'emails/wcast-email-order-details.php', array(
|
532 |
-
'order' => $order,
|
533 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
534 |
-
'sent_to_admin' => $sent_to_admin,
|
535 |
-
'plain_text' => $plain_text,
|
536 |
-
'email' => $email,
|
537 |
-
),
|
538 |
-
'woocommerce-advanced-shipment-tracking/',
|
539 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
540 |
-
);
|
541 |
-
$message .= ob_get_clean();
|
542 |
-
}
|
543 |
-
|
544 |
-
if($wcast_show_shipping_address == 1){
|
545 |
-
ob_start();
|
546 |
-
wc_get_template(
|
547 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
548 |
-
'order' => $order,
|
549 |
-
'sent_to_admin' => $sent_to_admin,
|
550 |
-
),
|
551 |
-
'woocommerce-advanced-shipment-tracking/',
|
552 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
553 |
-
);
|
554 |
-
$message .= ob_get_clean();
|
555 |
-
}
|
556 |
// create a new email
|
557 |
$email = new WC_Email();
|
558 |
-
$
|
|
|
559 |
// wrap the content with the email template and then add styles
|
560 |
-
|
561 |
-
echo $message;
|
562 |
}
|
563 |
|
564 |
/**
|
@@ -580,4 +474,4 @@ class wcast_intransit_customizer_email {
|
|
580 |
* Initialise our Customizer settings
|
581 |
*/
|
582 |
|
583 |
-
$
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
|
|
|
|
|
|
18 |
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
|
|
|
|
24 |
|
25 |
// Register our sections
|
26 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
41 |
|
42 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
|
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* Checks to see if we are opening our custom customizer preview
|
49 |
*
|
50 |
* @access public
|
51 |
* @return bool
|
52 |
*/
|
53 |
+
public function is_own_preview_request() {
|
54 |
return isset( $_REQUEST['wcast-intransit-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-intransit-email-customizer-preview'];
|
55 |
}
|
56 |
|
60 |
* @access public
|
61 |
* @return bool
|
62 |
*/
|
63 |
+
public function is_own_customizer_request() {
|
64 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
65 |
}
|
66 |
|
68 |
* Get Customizer URL
|
69 |
*
|
70 |
*/
|
71 |
+
public function get_customizer_url( $email, $shipment_status, $return_tab ) {
|
72 |
+
$preview_status = str_replace( "_", "", $shipment_status );
|
73 |
+
return add_query_arg( array(
|
74 |
+
'wcast-customizer' => '1',
|
75 |
+
'email' => $email,
|
76 |
+
'shipment_status' => $shipment_status,
|
77 |
+
'autofocus[section]' => 'trackship_shipment_status_email',
|
78 |
+
'url' => urlencode( add_query_arg( array( 'wcast-'.$preview_status.'-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
79 |
+
'return' => urlencode( $this->get_email_settings_page_url($return_tab) ),
|
80 |
+
), admin_url( 'customize.php' ) );
|
|
|
81 |
}
|
82 |
|
83 |
/**
|
86 |
* @access public
|
87 |
* @return string
|
88 |
*/
|
89 |
+
public function get_email_settings_page_url($return_tab) {
|
90 |
+
return admin_url( 'admin.php?page=trackship-for-woocommerce&tab=' . $return_tab );
|
91 |
}
|
92 |
|
93 |
/**
|
106 |
'wcast_intransit_email_code_block' => '',
|
107 |
);
|
108 |
|
109 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
110 |
}
|
111 |
|
112 |
/**
|
126 |
'sanitize_callback' => ''
|
127 |
)
|
128 |
);
|
129 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_intransit_email_preview_order_id',
|
130 |
array(
|
131 |
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
132 |
'description' => '',
|
148 |
'type' => 'option',
|
149 |
)
|
150 |
);
|
151 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_shipment_status_type',
|
152 |
array(
|
153 |
'label' => __( 'Shipment Status', 'woo-advanced-shipment-tracking' ),
|
154 |
'description' => '',
|
165 |
'out_for_delivery' => __( 'Out For Delivery', 'woo-advanced-shipment-tracking' ),
|
166 |
'delivered' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
|
167 |
'failure' => __( 'Failed Attempt', 'woo-advanced-shipment-tracking' ),
|
168 |
+
'exception' => __( 'Exception', 'woo-advanced-shipment-tracking' ),
|
169 |
),
|
170 |
)
|
171 |
) );
|
270 |
'sanitize_callback' => 'wp_kses_post'
|
271 |
)
|
272 |
);
|
273 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_intransit_email_settings[wcast_intransit_email_content]',
|
274 |
array(
|
275 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
276 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
383 |
}
|
384 |
|
385 |
public function active_callback(){
|
386 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
387 |
}
|
388 |
|
389 |
public function active_callback_only_show_order_details(){
|
|
|
390 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
391 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_show_order_details',$this->defaults['wcast_intransit_show_order_details']);
|
392 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
|
|
|
|
|
|
|
|
|
|
393 |
}
|
394 |
|
395 |
/**
|
399 |
* @return void
|
400 |
*/
|
401 |
public function set_up_preview() {
|
|
|
402 |
// Make sure this is own preview request.
|
403 |
+
if ( ! $this->is_own_preview_request() )return;
|
404 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/intransit_preview.php';exit;
|
|
|
|
|
|
|
405 |
}
|
406 |
|
407 |
/**
|
408 |
* code for preview of in transit email
|
409 |
*/
|
410 |
public function preview_intransit_email(){
|
411 |
+
|
412 |
+
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
|
|
|
|
413 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
414 |
|
|
|
|
|
415 |
$email_heading = $ast->get_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_email_heading',$this->defaults['wcast_intransit_email_heading']);
|
|
|
|
|
|
|
416 |
$email_content = $ast->get_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_email_content',$this->defaults['wcast_intransit_email_content']);
|
|
|
417 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_show_order_details',$this->defaults['wcast_intransit_show_order_details']);
|
|
|
418 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_hide_shipping_item_price',$this->defaults['wcast_intransit_hide_shipping_item_price']);
|
|
|
419 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_show_shipping_address',$this->defaults['wcast_intransit_show_shipping_address']);
|
420 |
|
|
|
|
|
|
|
|
|
421 |
if($preview_id == '' || $preview_id == 'mockup') {
|
422 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
423 |
echo $content;
|
430 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
431 |
echo $content;
|
432 |
return;
|
433 |
+
}
|
|
|
|
|
434 |
|
435 |
// get the preview email subject
|
436 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
|
|
|
|
437 |
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
438 |
|
439 |
$wcast_intransit_analytics_link = $ast->get_option_value_from_array('wcast_intransit_email_settings','wcast_intransit_analytics_link','');
|
|
|
440 |
if($wcast_intransit_analytics_link){
|
441 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
442 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
443 |
}
|
|
|
|
|
444 |
|
445 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
446 |
+
$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'in_transit' );
|
447 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
448 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
// create a new email
|
451 |
$email = new WC_Email();
|
452 |
+
$mailer = WC()->mailer();
|
453 |
+
|
454 |
// wrap the content with the email template and then add styles
|
455 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
|
|
456 |
}
|
457 |
|
458 |
/**
|
474 |
* Initialise our Customizer settings
|
475 |
*/
|
476 |
|
477 |
+
$wcast_intransit_customizer_email = new wcast_intransit_customizer_email();
|
includes/customizer/class-wc-late-shipments-email-customizer.php
CHANGED
@@ -14,10 +14,8 @@ class wcast_late_shipments_customizer_email {
|
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
-
|
18 |
-
|
19 |
-
return;
|
20 |
-
}
|
21 |
}
|
22 |
|
23 |
/**
|
@@ -38,7 +36,7 @@ class wcast_late_shipments_customizer_email {
|
|
38 |
'wcast_late_shipments_email_code_block' => '',
|
39 |
);
|
40 |
|
41 |
-
return apply_filters( '
|
42 |
}
|
43 |
}
|
44 |
/**
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
18 |
+
|
|
|
|
|
19 |
}
|
20 |
|
21 |
/**
|
36 |
'wcast_late_shipments_email_code_block' => '',
|
37 |
);
|
38 |
|
39 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
40 |
}
|
41 |
}
|
42 |
/**
|
includes/customizer/class-wc-onhold-email-customizer.php
CHANGED
@@ -14,18 +14,14 @@ class wcast_onhold_customizer_email {
|
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
-
|
18 |
-
if(!$wc_ast_api_key){
|
19 |
-
return;
|
20 |
-
}
|
21 |
|
22 |
// Register our sample default controls
|
23 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
24 |
|
25 |
// Only proceed if this is own request.
|
26 |
-
if ( !
|
27 |
-
|
28 |
-
}
|
29 |
// Register our sections
|
30 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
31 |
|
@@ -45,31 +41,7 @@ class wcast_onhold_customizer_email {
|
|
45 |
|
46 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
47 |
|
48 |
-
add_action( 'customize_preview_init', array(
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* add css and js for preview
|
54 |
-
*/
|
55 |
-
public function enqueue_preview_scripts() {
|
56 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
57 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
58 |
-
// Send variables to Javascript
|
59 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
60 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
61 |
-
'site_title' => $this->get_blogname(),
|
62 |
-
'order_number' => $preview_id,
|
63 |
-
));
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Get blog name formatted for emails.
|
68 |
-
*
|
69 |
-
* @return string
|
70 |
-
*/
|
71 |
-
public function get_blogname() {
|
72 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -78,7 +50,7 @@ class wcast_onhold_customizer_email {
|
|
78 |
* @access public
|
79 |
* @return bool
|
80 |
*/
|
81 |
-
public
|
82 |
return isset( $_REQUEST['wcast-onhold-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-onhold-email-customizer-preview'];
|
83 |
}
|
84 |
|
@@ -88,36 +60,9 @@ class wcast_onhold_customizer_email {
|
|
88 |
* @access public
|
89 |
* @return bool
|
90 |
*/
|
91 |
-
public
|
92 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Get Customizer URL
|
97 |
-
*
|
98 |
-
*/
|
99 |
-
public static function get_customizer_url( $email, $shipment_status, $return_tab ) {
|
100 |
-
$customizer_url = add_query_arg( array(
|
101 |
-
'wcast-customizer' => '1',
|
102 |
-
'email' => $email,
|
103 |
-
'shipment_status' => $shipment_status,
|
104 |
-
'autofocus[section]' => 'trackship_shipment_status_email',
|
105 |
-
'url' => urlencode( add_query_arg( array( 'wcast-onhold-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
106 |
-
'return' => urlencode( wcast_onhold_customizer_email::get_email_settings_page_url($return_tab) ),
|
107 |
-
), admin_url( 'customize.php' ) );
|
108 |
-
|
109 |
-
return $customizer_url;
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Get WooCommerce email settings page URL
|
114 |
-
*
|
115 |
-
* @access public
|
116 |
-
* @return string
|
117 |
-
*/
|
118 |
-
public static function get_email_settings_page_url($return_tab) {
|
119 |
-
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
120 |
-
}
|
121 |
|
122 |
/**
|
123 |
* code for initialize default value for customizer
|
@@ -136,7 +81,7 @@ class wcast_onhold_customizer_email {
|
|
136 |
'wcast_onhold_email_code_block' => '',
|
137 |
);
|
138 |
|
139 |
-
return apply_filters( '
|
140 |
}
|
141 |
|
142 |
/**
|
@@ -248,7 +193,7 @@ class wcast_onhold_customizer_email {
|
|
248 |
'sanitize_callback' => 'wp_kses_post'
|
249 |
)
|
250 |
);
|
251 |
-
$wp_customize->add_control( new
|
252 |
array(
|
253 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
254 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
@@ -361,23 +306,13 @@ class wcast_onhold_customizer_email {
|
|
361 |
}
|
362 |
|
363 |
public function active_callback(){
|
364 |
-
|
365 |
-
return true;
|
366 |
-
} else{
|
367 |
-
return false;
|
368 |
-
}
|
369 |
}
|
370 |
|
371 |
public function active_callback_only_show_order_details(){
|
372 |
-
|
373 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
374 |
-
$show_order_details = $ast->
|
375 |
-
|
376 |
-
if ( wcast_onhold_customizer_email::is_own_preview_request() && $show_order_details ) {
|
377 |
-
return true;
|
378 |
-
} else{
|
379 |
-
return false;
|
380 |
-
}
|
381 |
}
|
382 |
/**
|
383 |
* Set up preview
|
@@ -386,42 +321,24 @@ class wcast_onhold_customizer_email {
|
|
386 |
* @return void
|
387 |
*/
|
388 |
public function set_up_preview() {
|
389 |
-
|
390 |
// Make sure this is own preview request.
|
391 |
-
if ( !
|
392 |
-
|
393 |
-
}
|
394 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/onhold_preview.php';
|
395 |
-
exit;
|
396 |
}
|
397 |
|
398 |
/**
|
399 |
* code for preview of in transit email
|
400 |
*/
|
401 |
public function preview_onhold_email(){
|
402 |
-
|
403 |
-
$wc_emails = WC_Emails::instance();
|
404 |
-
$emails = $wc_emails->get_emails();
|
405 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
406 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
407 |
|
408 |
-
$order_id = $ast->get_custom_order_number( $preview_id );
|
409 |
-
|
410 |
$email_heading = $ast->get_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_email_heading',$this->defaults['wcast_onhold_email_heading']);
|
411 |
-
$email_heading = str_replace( '{site_title}', $this->get_blogname(), $email_heading );
|
412 |
-
$email_heading = str_replace( '{order_number}', $order_id, $email_heading );
|
413 |
-
|
414 |
$email_content = $ast->get_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_email_content',$this->defaults['wcast_onhold_email_content']);
|
415 |
-
|
416 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_show_order_details',$this->defaults['wcast_onhold_show_order_details']);
|
417 |
-
|
418 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_hide_shipping_item_price',$this->defaults['wcast_onhold_hide_shipping_item_price']);
|
419 |
-
|
420 |
-
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_show_shipping_address',$this->defaults['wcast_onhold_show_shipping_address']);
|
421 |
-
|
422 |
-
$sent_to_admin = false;
|
423 |
-
$plain_text = false;
|
424 |
-
$email = '';
|
425 |
|
426 |
if($preview_id == '' || $preview_id == 'mockup') {
|
427 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
@@ -437,76 +354,27 @@ class wcast_onhold_customizer_email {
|
|
437 |
return;
|
438 |
}
|
439 |
|
440 |
-
$mailer = WC()->mailer();
|
441 |
-
|
442 |
// get the preview email subject
|
443 |
-
$email_heading =
|
444 |
-
|
445 |
-
|
446 |
-
$message = wc_trackship_email_manager()->email_content($email_content,$preview_id,$order);
|
447 |
|
448 |
$wcast_onhold_analytics_link = $ast->get_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_analytics_link','');
|
449 |
-
|
450 |
if($wcast_onhold_analytics_link){
|
451 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
452 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
453 |
}
|
454 |
-
|
455 |
-
$wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
456 |
|
457 |
-
|
458 |
-
$
|
459 |
-
if
|
460 |
-
|
461 |
-
|
462 |
-
'order_id' => $preview_id,
|
463 |
-
'show_shipment_status' => true,
|
464 |
-
'new_status' => 'on_hold',
|
465 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
466 |
-
} else{
|
467 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
468 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
469 |
-
'order_id' => $preview_id,
|
470 |
-
'show_shipment_status' => true,
|
471 |
-
'new_status' => 'on_hold',
|
472 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
473 |
-
}
|
474 |
-
$message .= ob_get_clean();
|
475 |
-
|
476 |
-
if($wcast_show_order_details == 1){
|
477 |
-
ob_start();
|
478 |
-
wc_get_template(
|
479 |
-
'emails/wcast-email-order-details.php', array(
|
480 |
-
'order' => $order,
|
481 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
482 |
-
'sent_to_admin' => $sent_to_admin,
|
483 |
-
'plain_text' => $plain_text,
|
484 |
-
'email' => $email,
|
485 |
-
),
|
486 |
-
'woocommerce-advanced-shipment-tracking/',
|
487 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
488 |
-
);
|
489 |
-
$message .= ob_get_clean();
|
490 |
-
}
|
491 |
-
|
492 |
-
if($wcast_show_shipping_address == 1){
|
493 |
-
ob_start();
|
494 |
-
wc_get_template(
|
495 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
496 |
-
'order' => $order,
|
497 |
-
'sent_to_admin' => $sent_to_admin,
|
498 |
-
),
|
499 |
-
'woocommerce-advanced-shipment-tracking/',
|
500 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
501 |
-
);
|
502 |
-
$message .= ob_get_clean();
|
503 |
-
}
|
504 |
// create a new email
|
505 |
$email = new WC_Email();
|
506 |
-
$
|
|
|
507 |
// wrap the content with the email template and then add styles
|
508 |
-
|
509 |
-
echo $message;
|
510 |
}
|
511 |
|
512 |
/**
|
@@ -527,5 +395,4 @@ class wcast_onhold_customizer_email {
|
|
527 |
/**
|
528 |
* Initialise our Customizer settings
|
529 |
*/
|
530 |
-
|
531 |
-
$wcast_customizer_settings = new wcast_onhold_customizer_email();
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
|
|
|
|
|
|
18 |
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
24 |
+
|
|
|
25 |
// Register our sections
|
26 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
27 |
|
41 |
|
42 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
/**
|
50 |
* @access public
|
51 |
* @return bool
|
52 |
*/
|
53 |
+
public function is_own_preview_request() {
|
54 |
return isset( $_REQUEST['wcast-onhold-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-onhold-email-customizer-preview'];
|
55 |
}
|
56 |
|
60 |
* @access public
|
61 |
* @return bool
|
62 |
*/
|
63 |
+
public function is_own_customizer_request() {
|
64 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
65 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
/**
|
68 |
* code for initialize default value for customizer
|
81 |
'wcast_onhold_email_code_block' => '',
|
82 |
);
|
83 |
|
84 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
85 |
}
|
86 |
|
87 |
/**
|
193 |
'sanitize_callback' => 'wp_kses_post'
|
194 |
)
|
195 |
);
|
196 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_onhold_email_settings[wcast_onhold_email_content]',
|
197 |
array(
|
198 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
199 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
306 |
}
|
307 |
|
308 |
public function active_callback(){
|
309 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
310 |
}
|
311 |
|
312 |
public function active_callback_only_show_order_details(){
|
|
|
313 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
314 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_show_order_details',$this->defaults['wcast_onhold_show_order_details']);
|
315 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
|
|
|
|
|
|
|
|
|
|
316 |
}
|
317 |
/**
|
318 |
* Set up preview
|
321 |
* @return void
|
322 |
*/
|
323 |
public function set_up_preview() {
|
|
|
324 |
// Make sure this is own preview request.
|
325 |
+
if ( ! $this->is_own_preview_request() )return;
|
326 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/onhold_preview.php';exit;
|
|
|
|
|
|
|
327 |
}
|
328 |
|
329 |
/**
|
330 |
* code for preview of in transit email
|
331 |
*/
|
332 |
public function preview_onhold_email(){
|
333 |
+
|
|
|
|
|
334 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
335 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
336 |
|
|
|
|
|
337 |
$email_heading = $ast->get_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_email_heading',$this->defaults['wcast_onhold_email_heading']);
|
|
|
|
|
|
|
338 |
$email_content = $ast->get_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_email_content',$this->defaults['wcast_onhold_email_content']);
|
|
|
339 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_show_order_details',$this->defaults['wcast_onhold_show_order_details']);
|
|
|
340 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_hide_shipping_item_price',$this->defaults['wcast_onhold_hide_shipping_item_price']);
|
341 |
+
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_show_shipping_address',$this->defaults['wcast_onhold_show_shipping_address']);
|
|
|
|
|
|
|
|
|
|
|
342 |
|
343 |
if($preview_id == '' || $preview_id == 'mockup') {
|
344 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
354 |
return;
|
355 |
}
|
356 |
|
|
|
|
|
357 |
// get the preview email subject
|
358 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
359 |
+
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
|
|
|
|
360 |
|
361 |
$wcast_onhold_analytics_link = $ast->get_option_value_from_array('wcast_onhold_email_settings','wcast_onhold_analytics_link','');
|
|
|
362 |
if($wcast_onhold_analytics_link){
|
363 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
364 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
365 |
}
|
|
|
|
|
366 |
|
367 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
368 |
+
$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'on_hold' );
|
369 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
370 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
371 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
// create a new email
|
373 |
$email = new WC_Email();
|
374 |
+
$mailer = WC()->mailer();
|
375 |
+
|
376 |
// wrap the content with the email template and then add styles
|
377 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
|
|
378 |
}
|
379 |
|
380 |
/**
|
395 |
/**
|
396 |
* Initialise our Customizer settings
|
397 |
*/
|
398 |
+
new wcast_onhold_customizer_email();
|
|
includes/customizer/class-wc-outfordelivery-email-customizer.php
CHANGED
@@ -14,17 +14,14 @@ class wcast_outfordelivery_customizer_email {
|
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
-
if(!$wc_ast_api_key)
|
18 |
-
return;
|
19 |
-
}
|
20 |
|
21 |
// Register our sample default controls
|
22 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
23 |
|
24 |
// Only proceed if this is own request.
|
25 |
-
if ( !
|
26 |
-
|
27 |
-
}
|
28 |
// Register our sections
|
29 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
30 |
|
@@ -44,40 +41,16 @@ class wcast_outfordelivery_customizer_email {
|
|
44 |
|
45 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
46 |
|
47 |
-
add_action( 'customize_preview_init', array(
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* add css and js for preview
|
53 |
-
*/
|
54 |
-
public function enqueue_preview_scripts() {
|
55 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
56 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
57 |
-
// Send variables to Javascript
|
58 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
59 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
60 |
-
'site_title' => $this->get_blogname(),
|
61 |
-
'order_number' => $preview_id,
|
62 |
-
));
|
63 |
}
|
64 |
|
65 |
-
/**
|
66 |
-
* Get blog name formatted for emails.
|
67 |
-
*
|
68 |
-
* @return string
|
69 |
-
*/
|
70 |
-
public function get_blogname() {
|
71 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
72 |
-
}
|
73 |
-
|
74 |
/**
|
75 |
* Checks to see if we are opening our custom customizer preview
|
76 |
*
|
77 |
* @access public
|
78 |
* @return bool
|
79 |
*/
|
80 |
-
public
|
81 |
return isset( $_REQUEST['wcast-outfordelivery-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-outfordelivery-email-customizer-preview'];
|
82 |
}
|
83 |
|
@@ -87,36 +60,9 @@ class wcast_outfordelivery_customizer_email {
|
|
87 |
* @access public
|
88 |
* @return bool
|
89 |
*/
|
90 |
-
public
|
91 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Get Customizer URL
|
96 |
-
*
|
97 |
-
*/
|
98 |
-
public static function get_customizer_url( $email, $shipment_status, $return_tab ) {
|
99 |
-
$customizer_url = add_query_arg( array(
|
100 |
-
'wcast-customizer' => '1',
|
101 |
-
'email' => $email,
|
102 |
-
'shipment_status' => $shipment_status,
|
103 |
-
'autofocus[section]' => 'trackship_shipment_status_email',
|
104 |
-
'url' => urlencode( add_query_arg( array( 'wcast-outfordelivery-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
105 |
-
'return' => urlencode( wcast_outfordelivery_customizer_email::get_email_settings_page_url($return_tab) ),
|
106 |
-
), admin_url( 'customize.php' ) );
|
107 |
-
|
108 |
-
return $customizer_url;
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Get WooCommerce email settings page URL
|
113 |
-
*
|
114 |
-
* @access public
|
115 |
-
* @return string
|
116 |
-
*/
|
117 |
-
public static function get_email_settings_page_url($return_tab) {
|
118 |
-
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
119 |
-
}
|
120 |
|
121 |
/**
|
122 |
* code for initialize default value for customizer
|
@@ -134,7 +80,7 @@ class wcast_outfordelivery_customizer_email {
|
|
134 |
'wcast_outfordelivery_email_code_block' => '',
|
135 |
);
|
136 |
|
137 |
-
return apply_filters( '
|
138 |
}
|
139 |
|
140 |
/**
|
@@ -246,7 +192,7 @@ class wcast_outfordelivery_customizer_email {
|
|
246 |
'sanitize_callback' => 'wp_kses_post'
|
247 |
)
|
248 |
);
|
249 |
-
$wp_customize->add_control( new
|
250 |
array(
|
251 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
252 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
@@ -359,23 +305,13 @@ class wcast_outfordelivery_customizer_email {
|
|
359 |
}
|
360 |
|
361 |
public function active_callback(){
|
362 |
-
|
363 |
-
return true;
|
364 |
-
} else{
|
365 |
-
return false;
|
366 |
-
}
|
367 |
}
|
368 |
|
369 |
public function active_callback_only_show_order_details(){
|
370 |
-
|
371 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
372 |
-
$show_order_details = $ast->
|
373 |
-
|
374 |
-
if ( wcast_outfordelivery_customizer_email::is_own_preview_request() && $show_order_details ) {
|
375 |
-
return true;
|
376 |
-
} else{
|
377 |
-
return false;
|
378 |
-
}
|
379 |
}
|
380 |
|
381 |
/**
|
@@ -385,43 +321,25 @@ class wcast_outfordelivery_customizer_email {
|
|
385 |
* @return void
|
386 |
*/
|
387 |
public function set_up_preview() {
|
388 |
-
|
389 |
// Make sure this is own preview request.
|
390 |
-
if ( !
|
391 |
-
|
392 |
-
}
|
393 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/outfordelivery_preview.php';
|
394 |
-
exit;
|
395 |
}
|
396 |
|
397 |
/**
|
398 |
* code for preview of out for delivery email
|
399 |
*/
|
400 |
public function preview_outfordelivery_email(){
|
401 |
-
|
402 |
-
$wc_emails = WC_Emails::instance();
|
403 |
-
$emails = $wc_emails->get_emails();
|
404 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
405 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
406 |
|
407 |
-
$order_id = $ast->get_custom_order_number( $preview_id );
|
408 |
-
|
409 |
$email_heading = $ast->get_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_email_heading',$this->defaults['wcast_outfordelivery_email_heading']);
|
410 |
-
$email_heading = str_replace( '{site_title}', $this->get_blogname(), $email_heading );
|
411 |
-
$email_heading = str_replace( '{order_number}', $order_id, $email_heading );
|
412 |
-
|
413 |
$email_content = $ast->get_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_email_content',$this->defaults['wcast_outfordelivery_email_content']);
|
414 |
-
|
415 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_show_order_details',$this->defaults['wcast_outfordelivery_show_order_details']);
|
416 |
-
|
417 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_hide_shipping_item_price',$this->defaults['wcast_outfordelivery_hide_shipping_item_price']);
|
418 |
-
|
419 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_show_shipping_address',$this->defaults['wcast_outfordelivery_show_shipping_address']);
|
420 |
|
421 |
-
$sent_to_admin = false;
|
422 |
-
$plain_text = false;
|
423 |
-
$email = '';
|
424 |
-
|
425 |
if($preview_id == '' || $preview_id == 'mockup') {
|
426 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
427 |
echo $content;
|
@@ -436,79 +354,27 @@ class wcast_outfordelivery_customizer_email {
|
|
436 |
return;
|
437 |
}
|
438 |
|
439 |
-
$mailer = WC()->mailer();
|
440 |
-
|
441 |
// get the preview email subject
|
442 |
-
$email_heading =
|
443 |
-
|
444 |
-
|
445 |
-
$message = wc_trackship_email_manager()->email_content($email_content,$preview_id,$order);
|
446 |
|
447 |
$wcast_outfordelivery_analytics_link = $ast->get_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_analytics_link','');
|
448 |
-
|
449 |
if($wcast_outfordelivery_analytics_link){
|
450 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
451 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
452 |
}
|
453 |
|
454 |
-
$
|
455 |
-
|
456 |
-
|
457 |
-
$
|
458 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
459 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
460 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
461 |
-
'order_id' => $preview_id,
|
462 |
-
'show_shipment_status' => true,
|
463 |
-
'new_status' => 'out_for_delivery',
|
464 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
465 |
-
} else{
|
466 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
467 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
468 |
-
'order_id' => $preview_id,
|
469 |
-
'show_shipment_status' => true,
|
470 |
-
'new_status' => 'out_for_delivery',
|
471 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
472 |
-
}
|
473 |
-
$message .= ob_get_clean();
|
474 |
-
|
475 |
-
if($wcast_show_order_details == 1){
|
476 |
-
|
477 |
-
ob_start();
|
478 |
-
wc_get_template(
|
479 |
-
'emails/wcast-email-order-details.php', array(
|
480 |
-
'order' => $order,
|
481 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
482 |
-
'sent_to_admin' => $sent_to_admin,
|
483 |
-
'plain_text' => $plain_text,
|
484 |
-
'email' => $email,
|
485 |
-
),
|
486 |
-
'woocommerce-advanced-shipment-tracking/',
|
487 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
488 |
-
);
|
489 |
-
$message .= ob_get_clean();
|
490 |
-
}
|
491 |
-
|
492 |
-
if($wcast_show_shipping_address == 1){
|
493 |
-
ob_start();
|
494 |
-
wc_get_template(
|
495 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
496 |
-
'order' => $order,
|
497 |
-
'sent_to_admin' => $sent_to_admin,
|
498 |
-
),
|
499 |
-
'woocommerce-advanced-shipment-tracking/',
|
500 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
501 |
-
);
|
502 |
-
$message .= ob_get_clean();
|
503 |
-
}
|
504 |
|
505 |
// create a new email
|
506 |
$email = new WC_Email();
|
507 |
-
$
|
508 |
|
509 |
// wrap the content with the email template and then add styles
|
510 |
-
|
511 |
-
echo $message;
|
512 |
}
|
513 |
|
514 |
/**
|
@@ -530,4 +396,4 @@ class wcast_outfordelivery_customizer_email {
|
|
530 |
* Initialise our Customizer settings
|
531 |
*/
|
532 |
|
533 |
-
$
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
|
|
|
|
18 |
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
24 |
+
|
|
|
25 |
// Register our sections
|
26 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
27 |
|
41 |
|
42 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* Checks to see if we are opening our custom customizer preview
|
49 |
*
|
50 |
* @access public
|
51 |
* @return bool
|
52 |
*/
|
53 |
+
public function is_own_preview_request() {
|
54 |
return isset( $_REQUEST['wcast-outfordelivery-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-outfordelivery-email-customizer-preview'];
|
55 |
}
|
56 |
|
60 |
* @access public
|
61 |
* @return bool
|
62 |
*/
|
63 |
+
public function is_own_customizer_request() {
|
64 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
65 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
/**
|
68 |
* code for initialize default value for customizer
|
80 |
'wcast_outfordelivery_email_code_block' => '',
|
81 |
);
|
82 |
|
83 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
84 |
}
|
85 |
|
86 |
/**
|
192 |
'sanitize_callback' => 'wp_kses_post'
|
193 |
)
|
194 |
);
|
195 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_outfordelivery_email_settings[wcast_outfordelivery_email_content]',
|
196 |
array(
|
197 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
198 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
305 |
}
|
306 |
|
307 |
public function active_callback(){
|
308 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
309 |
}
|
310 |
|
311 |
public function active_callback_only_show_order_details(){
|
|
|
312 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
313 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_show_order_details',$this->defaults['wcast_outfordelivery_show_order_details']);
|
314 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
|
|
|
|
|
|
|
|
|
|
315 |
}
|
316 |
|
317 |
/**
|
321 |
* @return void
|
322 |
*/
|
323 |
public function set_up_preview() {
|
|
|
324 |
// Make sure this is own preview request.
|
325 |
+
if ( ! $this->is_own_preview_request() )return;
|
326 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/outfordelivery_preview.php';exit;
|
|
|
|
|
|
|
327 |
}
|
328 |
|
329 |
/**
|
330 |
* code for preview of out for delivery email
|
331 |
*/
|
332 |
public function preview_outfordelivery_email(){
|
333 |
+
|
|
|
|
|
334 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
335 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
336 |
|
|
|
|
|
337 |
$email_heading = $ast->get_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_email_heading',$this->defaults['wcast_outfordelivery_email_heading']);
|
|
|
|
|
|
|
338 |
$email_content = $ast->get_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_email_content',$this->defaults['wcast_outfordelivery_email_content']);
|
|
|
339 |
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_show_order_details',$this->defaults['wcast_outfordelivery_show_order_details']);
|
|
|
340 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_hide_shipping_item_price',$this->defaults['wcast_outfordelivery_hide_shipping_item_price']);
|
|
|
341 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_show_shipping_address',$this->defaults['wcast_outfordelivery_show_shipping_address']);
|
342 |
|
|
|
|
|
|
|
|
|
343 |
if($preview_id == '' || $preview_id == 'mockup') {
|
344 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
345 |
echo $content;
|
354 |
return;
|
355 |
}
|
356 |
|
|
|
|
|
357 |
// get the preview email subject
|
358 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
359 |
+
$message = wc_trackship_email_manager()->email_content( $email_content, $preview_id, $order );
|
|
|
|
|
360 |
|
361 |
$wcast_outfordelivery_analytics_link = $ast->get_option_value_from_array('wcast_outfordelivery_email_settings','wcast_outfordelivery_analytics_link','');
|
|
|
362 |
if($wcast_outfordelivery_analytics_link){
|
363 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
364 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
365 |
}
|
366 |
|
367 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
368 |
+
$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'out_for_delivery' );
|
369 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
370 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
|
372 |
// create a new email
|
373 |
$email = new WC_Email();
|
374 |
+
$mailer = WC()->mailer();
|
375 |
|
376 |
// wrap the content with the email template and then add styles
|
377 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
|
|
378 |
}
|
379 |
|
380 |
/**
|
396 |
* Initialise our Customizer settings
|
397 |
*/
|
398 |
|
399 |
+
$wcast_outfordelivery_customizer_email = new wcast_outfordelivery_customizer_email();
|
includes/customizer/class-wc-partial-shipped-email-customizer.php
CHANGED
@@ -8,6 +8,8 @@
|
|
8 |
* Adds the individual sections, settings, and controls to the theme customizer
|
9 |
*/
|
10 |
class wcast_partial_shipped_customizer_email {
|
|
|
|
|
11 |
// Get our default values
|
12 |
public function __construct() {
|
13 |
// Get our Customizer defaults
|
@@ -17,9 +19,7 @@ class wcast_partial_shipped_customizer_email {
|
|
17 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
18 |
|
19 |
// Only proceed if this is own request.
|
20 |
-
if ( !
|
21 |
-
return;
|
22 |
-
}
|
23 |
|
24 |
// Register our sections
|
25 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
@@ -46,7 +46,7 @@ class wcast_partial_shipped_customizer_email {
|
|
46 |
public function enqueue_preview_scripts() {
|
47 |
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
48 |
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
49 |
-
|
50 |
$preview_id = get_theme_mod('wcast_partial_shipped_preview_order_id');
|
51 |
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
52 |
'site_title' => $this->get_blogname(),
|
@@ -69,7 +69,7 @@ class wcast_partial_shipped_customizer_email {
|
|
69 |
* @access public
|
70 |
* @return bool
|
71 |
*/
|
72 |
-
public
|
73 |
return isset( $_REQUEST['wcast-partial-shipped-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-partial-shipped-email-customizer-preview'];
|
74 |
}
|
75 |
|
@@ -79,7 +79,7 @@ class wcast_partial_shipped_customizer_email {
|
|
79 |
* @access public
|
80 |
* @return bool
|
81 |
*/
|
82 |
-
public
|
83 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'custom_order_status_email';
|
84 |
}
|
85 |
|
@@ -87,17 +87,15 @@ class wcast_partial_shipped_customizer_email {
|
|
87 |
* Get Customizer URL
|
88 |
*
|
89 |
*/
|
90 |
-
public
|
91 |
-
|
92 |
'wcast-customizer' => '1',
|
93 |
'email' => $email,
|
94 |
'order_status' => $order_status,
|
95 |
'autofocus[section]' => 'custom_order_status_email',
|
96 |
'url' => urlencode( add_query_arg( array( 'wcast-partial-shipped-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
97 |
-
'return' => urlencode(
|
98 |
-
), admin_url( 'customize.php' ) );
|
99 |
-
|
100 |
-
return $customizer_url;
|
101 |
}
|
102 |
|
103 |
/**
|
@@ -106,7 +104,7 @@ class wcast_partial_shipped_customizer_email {
|
|
106 |
* @access public
|
107 |
* @return string
|
108 |
*/
|
109 |
-
public
|
110 |
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
|
111 |
}
|
112 |
|
@@ -121,7 +119,7 @@ class wcast_partial_shipped_customizer_email {
|
|
121 |
'wcast_enable_partial_shipped_email' => 'no',
|
122 |
);
|
123 |
|
124 |
-
return apply_filters( '
|
125 |
}
|
126 |
|
127 |
/**
|
@@ -131,22 +129,7 @@ class wcast_partial_shipped_customizer_email {
|
|
131 |
/**
|
132 |
* Load all our Customizer Custom Controls
|
133 |
*/
|
134 |
-
require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
|
135 |
-
|
136 |
-
/*$wp_customize->add_setting( 'partial_shipped_order_email_heading',
|
137 |
-
array(
|
138 |
-
'default' => '',
|
139 |
-
'transport' => 'postMessage',
|
140 |
-
'sanitize_callback' => ''
|
141 |
-
)
|
142 |
-
);
|
143 |
-
$wp_customize->add_control( new WP_Customize_Heading_Control( $wp_customize, 'partial_shipped_order_email_heading',
|
144 |
-
array(
|
145 |
-
'label' => __( 'Partially Shipped status email', 'woo-advanced-shipment-tracking' ),
|
146 |
-
'description' => '',
|
147 |
-
'section' => 'custom_order_status_email'
|
148 |
-
)
|
149 |
-
) );*/
|
150 |
|
151 |
// Preview Order
|
152 |
$wp_customize->add_setting( 'wcast_email_preview_order_id',
|
@@ -156,7 +139,7 @@ class wcast_partial_shipped_customizer_email {
|
|
156 |
'sanitize_callback' => ''
|
157 |
)
|
158 |
);
|
159 |
-
$wp_customize->add_control( new
|
160 |
array(
|
161 |
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
162 |
'description' => '',
|
@@ -170,10 +153,10 @@ class wcast_partial_shipped_customizer_email {
|
|
170 |
) );
|
171 |
|
172 |
$order_status = array(
|
173 |
-
'partially_shipped' => __( 'Partially Shipped', 'woo-advanced-shipment-tracking' ),
|
174 |
-
'updated_tracking' => __( 'Updated Tracking', 'woo-advanced-shipment-tracking' ),
|
175 |
);
|
176 |
-
$order_status = apply_filters('wcast_order_status_email_type', $
|
|
|
177 |
// Preview Order
|
178 |
$wp_customize->add_setting( 'wcast_order_status_email_type',
|
179 |
array(
|
@@ -183,7 +166,7 @@ class wcast_partial_shipped_customizer_email {
|
|
183 |
'type' => 'option',
|
184 |
)
|
185 |
);
|
186 |
-
$wp_customize->add_control( new
|
187 |
array(
|
188 |
'label' => __( 'Email Type', 'woo-advanced-shipment-tracking' ),
|
189 |
'description' => '',
|
@@ -213,28 +196,7 @@ class wcast_partial_shipped_customizer_email {
|
|
213 |
'type' => 'checkbox',
|
214 |
'active_callback' => array( $this, 'active_callback' ),
|
215 |
)
|
216 |
-
);
|
217 |
-
|
218 |
-
/*// Preview Order
|
219 |
-
$wp_customize->add_setting( 'wcast_partial_shipped_preview_order_id',
|
220 |
-
array(
|
221 |
-
'default' => 'mockup',
|
222 |
-
'transport' => 'refresh',
|
223 |
-
'sanitize_callback' => ''
|
224 |
-
)
|
225 |
-
);
|
226 |
-
$wp_customize->add_control( new Skyrocket_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_partial_shipped_preview_order_id',
|
227 |
-
array(
|
228 |
-
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
229 |
-
'description' => '',
|
230 |
-
'section' => 'custom_order_status_email',
|
231 |
-
'input_attrs' => array(
|
232 |
-
'placeholder' => __( 'Please select a order...', 'woo-advanced-shipment-tracking' ),
|
233 |
-
'class' => 'preview_order_select',
|
234 |
-
),
|
235 |
-
'choices' => wcast_customizer()->get_order_ids(),
|
236 |
-
)
|
237 |
-
) );*/
|
238 |
|
239 |
// Header Text
|
240 |
$wp_customize->add_setting( 'woocommerce_customer_partial_shipped_order_settings[subject]',
|
@@ -294,7 +256,7 @@ class wcast_partial_shipped_customizer_email {
|
|
294 |
'type' => 'option',
|
295 |
)
|
296 |
);
|
297 |
-
$wp_customize->add_control( new
|
298 |
array(
|
299 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
300 |
'description' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {customer_email}, {customer_first_name}, {customer_last_name}, {customer_username}, {order_number}',
|
@@ -326,11 +288,7 @@ class wcast_partial_shipped_customizer_email {
|
|
326 |
}
|
327 |
|
328 |
public function active_callback(){
|
329 |
-
|
330 |
-
return true;
|
331 |
-
} else{
|
332 |
-
return false;
|
333 |
-
}
|
334 |
}
|
335 |
|
336 |
/**
|
@@ -340,13 +298,9 @@ class wcast_partial_shipped_customizer_email {
|
|
340 |
* @return void
|
341 |
*/
|
342 |
public function set_up_preview() {
|
343 |
-
|
344 |
// Make sure this is own preview request.
|
345 |
-
if ( !
|
346 |
-
|
347 |
-
}
|
348 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/partial_shipped_preview.php';
|
349 |
-
exit;
|
350 |
}
|
351 |
|
352 |
/**
|
@@ -378,15 +332,13 @@ class wcast_partial_shipped_customizer_email {
|
|
378 |
return false;
|
379 |
}
|
380 |
|
381 |
-
|
382 |
-
|
383 |
// Reference email.
|
384 |
if ( isset( $emails[ $email_type ] ) && is_object( $emails[ $email_type ] ) ) {
|
385 |
$email = $emails[ $email_type ];
|
386 |
}
|
387 |
$order_status = 'partial-shipped';
|
388 |
// Get an order
|
389 |
-
$order =
|
390 |
|
391 |
// Make sure gateways are running in case the email needs to input content from them.
|
392 |
WC()->payment_gateways();
|
@@ -419,7 +371,7 @@ class wcast_partial_shipped_customizer_email {
|
|
419 |
* @param string $order_status
|
420 |
* @return object
|
421 |
*/
|
422 |
-
public
|
423 |
if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
|
424 |
return wc_get_order( $order_id );
|
425 |
} else {
|
@@ -469,11 +421,32 @@ class wcast_partial_shipped_customizer_email {
|
|
469 |
|
470 |
}
|
471 |
}
|
|
|
472 |
/**
|
473 |
-
*
|
474 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
|
476 |
-
$wcast_partial_shipped_customizer_settings = new wcast_partial_shipped_customizer_email();
|
477 |
add_action( 'customize_save_customizer_partial_shipped_order_settings_enabled', 'woocommerce_customer_partial_shipped_order_settings_fun', 100, 1 );
|
478 |
|
479 |
/**
|
8 |
* Adds the individual sections, settings, and controls to the theme customizer
|
9 |
*/
|
10 |
class wcast_partial_shipped_customizer_email {
|
11 |
+
|
12 |
+
|
13 |
// Get our default values
|
14 |
public function __construct() {
|
15 |
// Get our Customizer defaults
|
19 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
20 |
|
21 |
// Only proceed if this is own request.
|
22 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
|
|
|
|
23 |
|
24 |
// Register our sections
|
25 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
46 |
public function enqueue_preview_scripts() {
|
47 |
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
48 |
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
49 |
+
// Send variables to Javascript
|
50 |
$preview_id = get_theme_mod('wcast_partial_shipped_preview_order_id');
|
51 |
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
52 |
'site_title' => $this->get_blogname(),
|
69 |
* @access public
|
70 |
* @return bool
|
71 |
*/
|
72 |
+
public function is_own_preview_request() {
|
73 |
return isset( $_REQUEST['wcast-partial-shipped-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-partial-shipped-email-customizer-preview'];
|
74 |
}
|
75 |
|
79 |
* @access public
|
80 |
* @return bool
|
81 |
*/
|
82 |
+
public function is_own_customizer_request() {
|
83 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'custom_order_status_email';
|
84 |
}
|
85 |
|
87 |
* Get Customizer URL
|
88 |
*
|
89 |
*/
|
90 |
+
public function get_customizer_url( $email, $order_status ) {
|
91 |
+
return add_query_arg( array(
|
92 |
'wcast-customizer' => '1',
|
93 |
'email' => $email,
|
94 |
'order_status' => $order_status,
|
95 |
'autofocus[section]' => 'custom_order_status_email',
|
96 |
'url' => urlencode( add_query_arg( array( 'wcast-partial-shipped-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
97 |
+
'return' => urlencode( $this->get_email_settings_page_url() ),
|
98 |
+
), admin_url( 'customize.php' ) );
|
|
|
|
|
99 |
}
|
100 |
|
101 |
/**
|
104 |
* @access public
|
105 |
* @return string
|
106 |
*/
|
107 |
+
public function get_email_settings_page_url() {
|
108 |
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
|
109 |
}
|
110 |
|
119 |
'wcast_enable_partial_shipped_email' => 'no',
|
120 |
);
|
121 |
|
122 |
+
return apply_filters( 'partially_shipped_customizer_defaults', $customizer_defaults );
|
123 |
}
|
124 |
|
125 |
/**
|
129 |
/**
|
130 |
* Load all our Customizer Custom Controls
|
131 |
*/
|
132 |
+
require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
// Preview Order
|
135 |
$wp_customize->add_setting( 'wcast_email_preview_order_id',
|
139 |
'sanitize_callback' => ''
|
140 |
)
|
141 |
);
|
142 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_email_preview_order_id',
|
143 |
array(
|
144 |
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
145 |
'description' => '',
|
153 |
) );
|
154 |
|
155 |
$order_status = array(
|
156 |
+
'partially_shipped' => __( 'Partially Shipped', 'woo-advanced-shipment-tracking' ),
|
|
|
157 |
);
|
158 |
+
$order_status = apply_filters('wcast_order_status_email_type', $order_status);
|
159 |
+
|
160 |
// Preview Order
|
161 |
$wp_customize->add_setting( 'wcast_order_status_email_type',
|
162 |
array(
|
166 |
'type' => 'option',
|
167 |
)
|
168 |
);
|
169 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_order_status_email_type',
|
170 |
array(
|
171 |
'label' => __( 'Email Type', 'woo-advanced-shipment-tracking' ),
|
172 |
'description' => '',
|
196 |
'type' => 'checkbox',
|
197 |
'active_callback' => array( $this, 'active_callback' ),
|
198 |
)
|
199 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
// Header Text
|
202 |
$wp_customize->add_setting( 'woocommerce_customer_partial_shipped_order_settings[subject]',
|
256 |
'type' => 'option',
|
257 |
)
|
258 |
);
|
259 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'woocommerce_customer_partial_shipped_order_settings[wcast_partial_shipped_email_content]',
|
260 |
array(
|
261 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
262 |
'description' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {customer_email}, {customer_first_name}, {customer_last_name}, {customer_username}, {order_number}',
|
288 |
}
|
289 |
|
290 |
public function active_callback(){
|
291 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
|
294 |
/**
|
298 |
* @return void
|
299 |
*/
|
300 |
public function set_up_preview() {
|
|
|
301 |
// Make sure this is own preview request.
|
302 |
+
if ( ! $this->is_own_preview_request() )return;
|
303 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/partial_shipped_preview.php';exit;
|
|
|
|
|
|
|
304 |
}
|
305 |
|
306 |
/**
|
332 |
return false;
|
333 |
}
|
334 |
|
|
|
|
|
335 |
// Reference email.
|
336 |
if ( isset( $emails[ $email_type ] ) && is_object( $emails[ $email_type ] ) ) {
|
337 |
$email = $emails[ $email_type ];
|
338 |
}
|
339 |
$order_status = 'partial-shipped';
|
340 |
// Get an order
|
341 |
+
$order = $this->get_wc_order_for_preview( $order_status, $preview_id );
|
342 |
|
343 |
// Make sure gateways are running in case the email needs to input content from them.
|
344 |
WC()->payment_gateways();
|
371 |
* @param string $order_status
|
372 |
* @return object
|
373 |
*/
|
374 |
+
public function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
|
375 |
if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
|
376 |
return wc_get_order( $order_id );
|
377 |
} else {
|
421 |
|
422 |
}
|
423 |
}
|
424 |
+
|
425 |
/**
|
426 |
+
* Returns an instance of zorem_woocommerce_advanced_shipment_tracking.
|
427 |
+
*
|
428 |
+
* @since 1.6.5
|
429 |
+
* @version 1.6.5
|
430 |
+
*
|
431 |
+
* @return zorem_woocommerce_advanced_shipment_tracking
|
432 |
+
*/
|
433 |
+
function ps_customizer() {
|
434 |
+
static $instance;
|
435 |
+
|
436 |
+
if ( ! isset( $instance ) ) {
|
437 |
+
$instance = new wcast_partial_shipped_customizer_email();
|
438 |
+
}
|
439 |
+
|
440 |
+
return $instance;
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Register this class globally.
|
445 |
+
*
|
446 |
+
* Backward compatibility.
|
447 |
+
*/
|
448 |
+
ps_customizer();
|
449 |
|
|
|
450 |
add_action( 'customize_save_customizer_partial_shipped_order_settings_enabled', 'woocommerce_customer_partial_shipped_order_settings_fun', 100, 1 );
|
451 |
|
452 |
/**
|
includes/customizer/class-wc-returntosender-email-customizer.php
CHANGED
@@ -12,17 +12,16 @@ class wcast_returntosender_customizer_email {
|
|
12 |
public function __construct() {
|
13 |
// Get our Customizer defaults
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
|
|
15 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
16 |
-
if(!$wc_ast_api_key)
|
17 |
-
|
18 |
-
}
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
-
if ( !
|
24 |
-
|
25 |
-
}
|
26 |
// Register our sections
|
27 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
28 |
|
@@ -42,40 +41,17 @@ class wcast_returntosender_customizer_email {
|
|
42 |
|
43 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
44 |
|
45 |
-
add_action( 'customize_preview_init', array(
|
46 |
|
47 |
}
|
48 |
|
49 |
-
/**
|
50 |
-
* add css and js for preview
|
51 |
-
*/
|
52 |
-
public function enqueue_preview_scripts() {
|
53 |
-
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
54 |
-
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
55 |
-
// Send variables to Javascript
|
56 |
-
$preview_id = get_theme_mod('wcast_email_preview_order_id');
|
57 |
-
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
58 |
-
'site_title' => $this->get_blogname(),
|
59 |
-
'order_number' => $preview_id,
|
60 |
-
));
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Get blog name formatted for emails.
|
65 |
-
*
|
66 |
-
* @return string
|
67 |
-
*/
|
68 |
-
public function get_blogname() {
|
69 |
-
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
70 |
-
}
|
71 |
-
|
72 |
/**
|
73 |
* Checks to see if we are opening our custom customizer preview
|
74 |
*
|
75 |
* @access public
|
76 |
* @return bool
|
77 |
*/
|
78 |
-
public
|
79 |
return isset( $_REQUEST['wcast-returntosender-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-returntosender-email-customizer-preview'];
|
80 |
}
|
81 |
|
@@ -85,36 +61,9 @@ class wcast_returntosender_customizer_email {
|
|
85 |
* @access public
|
86 |
* @return bool
|
87 |
*/
|
88 |
-
public
|
89 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Get Customizer URL
|
94 |
-
*
|
95 |
-
*/
|
96 |
-
public static function get_customizer_url( $email, $shipment_status, $return_tab ) {
|
97 |
-
$customizer_url = add_query_arg( array(
|
98 |
-
'wcast-customizer' => '1',
|
99 |
-
'email' => $email,
|
100 |
-
'shipment_status' => $shipment_status,
|
101 |
-
'autofocus[section]' => 'trackship_shipment_status_email',
|
102 |
-
'url' => urlencode( add_query_arg( array( 'wcast-returntosender-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
103 |
-
'return' => urlencode( wcast_returntosender_customizer_email::get_email_settings_page_url($return_tab) ),
|
104 |
-
), admin_url( 'customize.php' ) );
|
105 |
-
|
106 |
-
return $customizer_url;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Get WooCommerce email settings page URL
|
111 |
-
*
|
112 |
-
* @access public
|
113 |
-
* @return string
|
114 |
-
*/
|
115 |
-
public static function get_email_settings_page_url($return_tab) {
|
116 |
-
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
117 |
-
}
|
118 |
|
119 |
/**
|
120 |
* code for initialize default value for customizer
|
@@ -133,7 +82,7 @@ class wcast_returntosender_customizer_email {
|
|
133 |
'wcast_returntosender_email_code_block' => '',
|
134 |
);
|
135 |
|
136 |
-
return apply_filters( '
|
137 |
}
|
138 |
|
139 |
/**
|
@@ -245,7 +194,7 @@ class wcast_returntosender_customizer_email {
|
|
245 |
'sanitize_callback' => 'wp_kses_post'
|
246 |
)
|
247 |
);
|
248 |
-
$wp_customize->add_control( new
|
249 |
array(
|
250 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
251 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
@@ -357,23 +306,13 @@ class wcast_returntosender_customizer_email {
|
|
357 |
}
|
358 |
|
359 |
public function active_callback(){
|
360 |
-
|
361 |
-
return true;
|
362 |
-
} else{
|
363 |
-
return false;
|
364 |
-
}
|
365 |
}
|
366 |
|
367 |
public function active_callback_only_show_order_details(){
|
368 |
-
|
369 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
370 |
-
$show_order_details = $ast->
|
371 |
-
|
372 |
-
if ( wcast_returntosender_customizer_email::is_own_preview_request() && $show_order_details ) {
|
373 |
-
return true;
|
374 |
-
} else{
|
375 |
-
return false;
|
376 |
-
}
|
377 |
}
|
378 |
/**
|
379 |
* Set up preview
|
@@ -382,43 +321,24 @@ class wcast_returntosender_customizer_email {
|
|
382 |
* @return void
|
383 |
*/
|
384 |
public function set_up_preview() {
|
385 |
-
|
386 |
// Make sure this is own preview request.
|
387 |
-
if ( !
|
388 |
-
|
389 |
-
}
|
390 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/returntosender_preview.php';
|
391 |
-
exit;
|
392 |
}
|
393 |
|
394 |
/**
|
395 |
* code for preview of return to sender email
|
396 |
*/
|
397 |
public function preview_returntosender_email(){
|
398 |
-
|
399 |
-
$wc_emails = WC_Emails::instance();
|
400 |
-
$emails = $wc_emails->get_emails();
|
401 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
402 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
403 |
|
404 |
-
$order_id = $ast->get_custom_order_number( $preview_id );
|
405 |
-
|
406 |
$email_heading = $ast->get_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_email_heading',$this->defaults['wcast_returntosender_email_heading']);
|
407 |
-
$
|
408 |
-
$email_heading = str_replace( '{order_number}', $order_id, $email_heading );
|
409 |
-
|
410 |
-
$email_content = $ast->get_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_email_content',$this->defaults['wcast_returntosender_email_content']);
|
411 |
-
|
412 |
-
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_show_order_details',$this->defaults['wcast_returntosender_show_order_details']);
|
413 |
-
|
414 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_hide_shipping_item_price',$this->defaults['wcast_returntosender_hide_shipping_item_price']);
|
415 |
-
|
416 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_show_shipping_address',$this->defaults['wcast_returntosender_show_shipping_address']);
|
417 |
|
418 |
-
$sent_to_admin = false;
|
419 |
-
$plain_text = false;
|
420 |
-
$email = '';
|
421 |
-
|
422 |
if($preview_id == '' || $preview_id == 'mockup') {
|
423 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
424 |
echo $content;
|
@@ -431,81 +351,29 @@ class wcast_returntosender_customizer_email {
|
|
431 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
432 |
echo $content;
|
433 |
return;
|
434 |
-
}
|
435 |
-
|
436 |
-
$mailer = WC()->mailer();
|
437 |
|
438 |
// get the preview email subject
|
439 |
-
$email_heading =
|
440 |
-
//ob_start();
|
441 |
-
|
442 |
$message = wc_trackship_email_manager()->email_content($email_content,$preview_id,$order);
|
443 |
|
444 |
$wcast_returntosender_analytics_link = $ast->get_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_analytics_link','');
|
445 |
-
|
446 |
if($wcast_returntosender_analytics_link){
|
447 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
448 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
449 |
}
|
450 |
|
451 |
-
$
|
452 |
-
|
453 |
-
|
454 |
-
$
|
455 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
456 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
457 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
458 |
-
'order_id' => $preview_id,
|
459 |
-
'show_shipment_status' => true,
|
460 |
-
'new_status' => 'return_to_sender',
|
461 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
462 |
-
} else{
|
463 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
464 |
-
'tracking_items' => $wast->get_tracking_items( $preview_id, true ),
|
465 |
-
'order_id' => $preview_id,
|
466 |
-
'show_shipment_status' => true,
|
467 |
-
'new_status' => 'return_to_sender',
|
468 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
469 |
-
}
|
470 |
-
$message .= ob_get_clean();
|
471 |
-
|
472 |
-
if($wcast_show_order_details == 1){
|
473 |
-
|
474 |
-
ob_start();
|
475 |
-
wc_get_template(
|
476 |
-
'emails/wcast-email-order-details.php', array(
|
477 |
-
'order' => $order,
|
478 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
479 |
-
'sent_to_admin' => $sent_to_admin,
|
480 |
-
'plain_text' => $plain_text,
|
481 |
-
'email' => $email,
|
482 |
-
),
|
483 |
-
'woocommerce-advanced-shipment-tracking/',
|
484 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
485 |
-
);
|
486 |
-
$message .= ob_get_clean();
|
487 |
-
}
|
488 |
-
|
489 |
-
if($wcast_show_shipping_address == 1){
|
490 |
-
ob_start();
|
491 |
-
wc_get_template(
|
492 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
493 |
-
'order' => $order,
|
494 |
-
'sent_to_admin' => $sent_to_admin,
|
495 |
-
),
|
496 |
-
'woocommerce-advanced-shipment-tracking/',
|
497 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
498 |
-
);
|
499 |
-
$message .= ob_get_clean();
|
500 |
-
}
|
501 |
|
502 |
// create a new email
|
503 |
$email = new WC_Email();
|
504 |
-
$
|
505 |
|
506 |
// wrap the content with the email template and then add styles
|
507 |
-
|
508 |
-
echo $message;
|
509 |
}
|
510 |
|
511 |
/**
|
@@ -527,4 +395,4 @@ class wcast_returntosender_customizer_email {
|
|
527 |
* Initialise our Customizer settings
|
528 |
*/
|
529 |
|
530 |
-
$
|
12 |
public function __construct() {
|
13 |
// Get our Customizer defaults
|
14 |
$this->defaults = $this->wcast_generate_defaults();
|
15 |
+
|
16 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
17 |
+
if(!$wc_ast_api_key)return;
|
18 |
+
|
|
|
19 |
// Register our sample default controls
|
20 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
21 |
|
22 |
// Only proceed if this is own request.
|
23 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
24 |
+
|
|
|
25 |
// Register our sections
|
26 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
27 |
|
41 |
|
42 |
add_action( 'parse_request', array( $this, 'set_up_preview' ) );
|
43 |
|
44 |
+
add_action( 'customize_preview_init', array( wcast_customizer(), 'enqueue_preview_scripts' ) );
|
45 |
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* Checks to see if we are opening our custom customizer preview
|
50 |
*
|
51 |
* @access public
|
52 |
* @return bool
|
53 |
*/
|
54 |
+
public function is_own_preview_request() {
|
55 |
return isset( $_REQUEST['wcast-returntosender-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-returntosender-email-customizer-preview'];
|
56 |
}
|
57 |
|
61 |
* @access public
|
62 |
* @return bool
|
63 |
*/
|
64 |
+
public function is_own_customizer_request() {
|
65 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'trackship_shipment_status_email';
|
66 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
/**
|
69 |
* code for initialize default value for customizer
|
82 |
'wcast_returntosender_email_code_block' => '',
|
83 |
);
|
84 |
|
85 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
86 |
}
|
87 |
|
88 |
/**
|
194 |
'sanitize_callback' => 'wp_kses_post'
|
195 |
)
|
196 |
);
|
197 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'wcast_returntosender_email_settings[wcast_returntosender_email_content]',
|
198 |
array(
|
199 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
200 |
'description' => __( '', 'woo-advanced-shipment-tracking' ),
|
306 |
}
|
307 |
|
308 |
public function active_callback(){
|
309 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
310 |
}
|
311 |
|
312 |
public function active_callback_only_show_order_details(){
|
|
|
313 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
314 |
+
$show_order_details = $ast->get_checkbox_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_show_order_details',$this->defaults['wcast_returntosender_show_order_details']);
|
315 |
+
return ( $this->is_own_preview_request() && $show_order_details ) ? true : false ;
|
|
|
|
|
|
|
|
|
|
|
316 |
}
|
317 |
/**
|
318 |
* Set up preview
|
321 |
* @return void
|
322 |
*/
|
323 |
public function set_up_preview() {
|
|
|
324 |
// Make sure this is own preview request.
|
325 |
+
if ( ! $this->is_own_preview_request() )return;
|
326 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/returntosender_preview.php';exit;
|
|
|
|
|
|
|
327 |
}
|
328 |
|
329 |
/**
|
330 |
* code for preview of return to sender email
|
331 |
*/
|
332 |
public function preview_returntosender_email(){
|
333 |
+
|
|
|
|
|
334 |
$preview_id = get_theme_mod('wcast_intransit_email_preview_order_id');
|
335 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
336 |
|
|
|
|
|
337 |
$email_heading = $ast->get_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_email_heading',$this->defaults['wcast_returntosender_email_heading']);
|
338 |
+
$email_content = $ast->get_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_email_content',$this->defaults['wcast_returntosender_email_content']);$wcast_show_order_details = $ast->get_checkbox_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_show_order_details',$this->defaults['wcast_returntosender_show_order_details']);
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_hide_shipping_item_price',$this->defaults['wcast_returntosender_hide_shipping_item_price']);
|
|
|
340 |
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_show_shipping_address',$this->defaults['wcast_returntosender_show_shipping_address']);
|
341 |
|
|
|
|
|
|
|
|
|
342 |
if($preview_id == '' || $preview_id == 'mockup') {
|
343 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
344 |
echo $content;
|
351 |
$content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
|
352 |
echo $content;
|
353 |
return;
|
354 |
+
}
|
|
|
|
|
355 |
|
356 |
// get the preview email subject
|
357 |
+
$email_heading = wc_trackship_email_manager()->email_heading( $email_heading, $preview_id, $order );
|
|
|
|
|
358 |
$message = wc_trackship_email_manager()->email_content($email_content,$preview_id,$order);
|
359 |
|
360 |
$wcast_returntosender_analytics_link = $ast->get_option_value_from_array('wcast_returntosender_email_settings','wcast_returntosender_analytics_link','');
|
|
|
361 |
if($wcast_returntosender_analytics_link){
|
362 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
363 |
$message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
|
364 |
}
|
365 |
|
366 |
+
$tracking_items = $ast->get_tracking_items( $preview_id, true );
|
367 |
+
$message .= $ast->tracking_info_template( $preview_id, $tracking_items, 'return_to_sender' );
|
368 |
+
if( $wcast_show_order_details )$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
369 |
+
if( $wcast_show_shipping_address )$message .= $ast->order_shipping_details_template( $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
// create a new email
|
372 |
$email = new WC_Email();
|
373 |
+
$mailer = WC()->mailer();
|
374 |
|
375 |
// wrap the content with the email template and then add styles
|
376 |
+
echo apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
|
|
377 |
}
|
378 |
|
379 |
/**
|
395 |
* Initialise our Customizer settings
|
396 |
*/
|
397 |
|
398 |
+
$wcast_returntosender_customizer_email = new wcast_returntosender_customizer_email();
|
includes/customizer/class-wc-tracking-info-customizer.php
CHANGED
@@ -19,9 +19,7 @@ class wcast_initialise_customizer_settings {
|
|
19 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
20 |
|
21 |
// Only proceed if this is own request.
|
22 |
-
if ( !
|
23 |
-
return;
|
24 |
-
}
|
25 |
|
26 |
// Register our sections
|
27 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
@@ -74,7 +72,7 @@ class wcast_initialise_customizer_settings {
|
|
74 |
* @access public
|
75 |
* @return bool
|
76 |
*/
|
77 |
-
public
|
78 |
return isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview'];
|
79 |
}
|
80 |
|
@@ -84,7 +82,7 @@ class wcast_initialise_customizer_settings {
|
|
84 |
* @access public
|
85 |
* @return bool
|
86 |
*/
|
87 |
-
public
|
88 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'ast_tracking_general_section';
|
89 |
}
|
90 |
|
@@ -92,18 +90,15 @@ class wcast_initialise_customizer_settings {
|
|
92 |
* Get Customizer URL
|
93 |
*
|
94 |
*/
|
95 |
-
public
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
), admin_url( 'customize.php' ) );
|
105 |
-
|
106 |
-
return $customizer_url;
|
107 |
}
|
108 |
|
109 |
/**
|
@@ -112,7 +107,7 @@ class wcast_initialise_customizer_settings {
|
|
112 |
* @access public
|
113 |
* @return string
|
114 |
*/
|
115 |
-
public
|
116 |
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
117 |
}
|
118 |
|
@@ -182,7 +177,7 @@ class wcast_initialise_customizer_settings {
|
|
182 |
'sanitize_callback' => ''
|
183 |
)
|
184 |
);
|
185 |
-
$wp_customize->add_control( new
|
186 |
array(
|
187 |
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
188 |
'description' => esc_html__( 'Select an order to preview and design the tracking info display.', 'woo-advanced-shipment-tracking' ),
|
@@ -296,7 +291,7 @@ class wcast_initialise_customizer_settings {
|
|
296 |
'type' => 'option',
|
297 |
)
|
298 |
);
|
299 |
-
$wp_customize->add_control( new
|
300 |
array(
|
301 |
'label' => __( 'Tracking display layout', 'woo-advanced-shipment-tracking' ),
|
302 |
'section' => 'ast_tracking_general_section',
|
@@ -789,7 +784,7 @@ class wcast_initialise_customizer_settings {
|
|
789 |
'type' => 'option',
|
790 |
)
|
791 |
);
|
792 |
-
$wp_customize->add_control( new
|
793 |
array(
|
794 |
'label' => __( 'Headers font weight', 'woo-advanced-shipment-tracking' ),
|
795 |
'section' => 'ast_tracking_general_section',
|
@@ -884,7 +879,7 @@ class wcast_initialise_customizer_settings {
|
|
884 |
'type' => 'option',
|
885 |
)
|
886 |
);
|
887 |
-
$wp_customize->add_control( new
|
888 |
array(
|
889 |
'label' => __( 'Content line height', 'woo-advanced-shipment-tracking' ),
|
890 |
'section' => 'ast_tracking_general_section',
|
@@ -907,7 +902,7 @@ class wcast_initialise_customizer_settings {
|
|
907 |
'type' => 'option',
|
908 |
)
|
909 |
);
|
910 |
-
$wp_customize->add_control( new
|
911 |
array(
|
912 |
'label' => __( 'Content font weight', 'woo-advanced-shipment-tracking' ),
|
913 |
'section' => 'ast_tracking_general_section',
|
@@ -1022,81 +1017,78 @@ class wcast_initialise_customizer_settings {
|
|
1022 |
public function active_callback_for_hide_trackig_header(){
|
1023 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1024 |
$hide_trackig_header = $ast->get_option_value_from_array('tracking_info_settings','hide_trackig_header','');
|
1025 |
-
|
1026 |
-
if( !$hide_trackig_header ){
|
1027 |
-
return true;
|
1028 |
-
} else{
|
1029 |
-
return false;
|
1030 |
-
}
|
1031 |
}
|
1032 |
|
1033 |
public function active_callback_for_table_layout(){
|
|
|
|
|
|
|
|
|
1034 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1035 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1036 |
-
|
1037 |
-
|
1038 |
-
} else{
|
1039 |
-
return false;
|
1040 |
-
}
|
1041 |
}
|
1042 |
|
1043 |
public function active_callback_for_table_layout_table_header(){
|
|
|
|
|
|
|
|
|
1044 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1045 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1046 |
$hide_table_header = $ast->get_option_value_from_array( 'tracking_info_settings','hide_table_header', '' );
|
1047 |
|
1048 |
-
|
1049 |
-
return true;
|
1050 |
-
} else{
|
1051 |
-
return false;
|
1052 |
-
}
|
1053 |
}
|
1054 |
|
1055 |
public function active_callback_for_table_layout_tracking_link(){
|
|
|
|
|
|
|
|
|
1056 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1057 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1058 |
$tracking_number_link = $ast->get_option_value_from_array( 'tracking_info_settings','tracking_number_link', '' );
|
1059 |
|
1060 |
-
|
1061 |
-
return true;
|
1062 |
-
} else{
|
1063 |
-
return false;
|
1064 |
-
}
|
1065 |
}
|
1066 |
|
1067 |
public function active_callback_for_table_layout_tracking_link_track_header(){
|
|
|
|
|
|
|
|
|
1068 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1069 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1070 |
$tracking_number_link = $ast->get_option_value_from_array( 'tracking_info_settings','tracking_number_link', '' );
|
1071 |
$show_track_label = $ast->get_option_value_from_array( 'tracking_info_settings','show_track_label', '' );
|
1072 |
|
1073 |
-
|
1074 |
-
return true;
|
1075 |
-
} else{
|
1076 |
-
return false;
|
1077 |
-
}
|
1078 |
}
|
1079 |
|
1080 |
public function active_callback_for_simple_layout(){
|
|
|
|
|
|
|
|
|
1081 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1082 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1083 |
-
|
1084 |
-
|
1085 |
-
} else{
|
1086 |
-
return false;
|
1087 |
-
}
|
1088 |
}
|
1089 |
|
1090 |
public function active_callback_for_simple_layout_show_provider_border(){
|
|
|
|
|
|
|
|
|
1091 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1092 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1093 |
$show_provider_border = $ast->get_option_value_from_array( 'tracking_info_settings','show_provider_border', $this->defaults['show_provider_border'] );
|
1094 |
|
1095 |
-
|
1096 |
-
return true;
|
1097 |
-
} else{
|
1098 |
-
return false;
|
1099 |
-
}
|
1100 |
}
|
1101 |
|
1102 |
/**
|
@@ -1106,13 +1098,9 @@ class wcast_initialise_customizer_settings {
|
|
1106 |
* @return void
|
1107 |
*/
|
1108 |
public function set_up_preview() {
|
1109 |
-
|
1110 |
// Make sure this is own preview request.
|
1111 |
-
if ( !
|
1112 |
-
|
1113 |
-
}
|
1114 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/preview.php';
|
1115 |
-
exit;
|
1116 |
}
|
1117 |
|
1118 |
/**
|
@@ -1120,7 +1108,7 @@ class wcast_initialise_customizer_settings {
|
|
1120 |
*/
|
1121 |
public function preview_completed_email(){
|
1122 |
|
1123 |
-
$ast =
|
1124 |
|
1125 |
$tracking_info_settings = get_option('tracking_info_settings');
|
1126 |
|
@@ -1136,9 +1124,9 @@ class wcast_initialise_customizer_settings {
|
|
1136 |
$email_template = 'customer_completed_order';
|
1137 |
$preview_id = get_theme_mod('wcast_preview_order_id');
|
1138 |
$email_type = 'WC_Email_Customer_Completed_Order';
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
|
1143 |
$order_status = 'completed';
|
1144 |
|
@@ -1155,7 +1143,7 @@ class wcast_initialise_customizer_settings {
|
|
1155 |
}
|
1156 |
|
1157 |
// Get an order
|
1158 |
-
$order =
|
1159 |
|
1160 |
// Make sure gateways are running in case the email needs to input content from them.
|
1161 |
WC()->payment_gateways();
|
@@ -1189,7 +1177,7 @@ class wcast_initialise_customizer_settings {
|
|
1189 |
* @param string $order_status
|
1190 |
* @return object
|
1191 |
*/
|
1192 |
-
public
|
1193 |
if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
|
1194 |
return wc_get_order( $order_id );
|
1195 |
} else {
|
19 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
20 |
|
21 |
// Only proceed if this is own request.
|
22 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
|
|
|
|
23 |
|
24 |
// Register our sections
|
25 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
72 |
* @access public
|
73 |
* @return bool
|
74 |
*/
|
75 |
+
public function is_own_preview_request() {
|
76 |
return isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview'];
|
77 |
}
|
78 |
|
82 |
* @access public
|
83 |
* @return bool
|
84 |
*/
|
85 |
+
public function is_own_customizer_request() {
|
86 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'ast_tracking_general_section';
|
87 |
}
|
88 |
|
90 |
* Get Customizer URL
|
91 |
*
|
92 |
*/
|
93 |
+
public function get_customizer_url($email,$return_tab) {
|
94 |
+
return add_query_arg( array(
|
95 |
+
'wcast-customizer' => '1',
|
96 |
+
'email' => $email,
|
97 |
+
//'autofocus[section]' => 'ast_tracking_general_section',
|
98 |
+
'url' => urlencode( add_query_arg( array( 'wcast-tracking-preview' => '1' ), home_url( '/' ) ) ),
|
99 |
+
'return' => urlencode( $this->get_email_settings_page_url($return_tab) ),
|
100 |
+
//'autofocus[panel]' => 'ast_tracking_display_panel',
|
101 |
+
), admin_url( 'customize.php' ) );
|
|
|
|
|
|
|
102 |
}
|
103 |
|
104 |
/**
|
107 |
* @access public
|
108 |
* @return string
|
109 |
*/
|
110 |
+
public function get_email_settings_page_url($return_tab) {
|
111 |
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking&tab='.$return_tab );
|
112 |
}
|
113 |
|
177 |
'sanitize_callback' => ''
|
178 |
)
|
179 |
);
|
180 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_preview_order_id',
|
181 |
array(
|
182 |
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
183 |
'description' => esc_html__( 'Select an order to preview and design the tracking info display.', 'woo-advanced-shipment-tracking' ),
|
291 |
'type' => 'option',
|
292 |
)
|
293 |
);
|
294 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'tracking_info_settings[select_tracking_template]',
|
295 |
array(
|
296 |
'label' => __( 'Tracking display layout', 'woo-advanced-shipment-tracking' ),
|
297 |
'section' => 'ast_tracking_general_section',
|
784 |
'type' => 'option',
|
785 |
)
|
786 |
);
|
787 |
+
$wp_customize->add_control( new AST_Slider_Custom_Control( $wp_customize, 'tracking_info_settings[table_header_font_weight]',
|
788 |
array(
|
789 |
'label' => __( 'Headers font weight', 'woo-advanced-shipment-tracking' ),
|
790 |
'section' => 'ast_tracking_general_section',
|
879 |
'type' => 'option',
|
880 |
)
|
881 |
);
|
882 |
+
$wp_customize->add_control( new AST_Slider_Custom_Control( $wp_customize, 'tracking_info_settings[table_content_line_height]',
|
883 |
array(
|
884 |
'label' => __( 'Content line height', 'woo-advanced-shipment-tracking' ),
|
885 |
'section' => 'ast_tracking_general_section',
|
902 |
'type' => 'option',
|
903 |
)
|
904 |
);
|
905 |
+
$wp_customize->add_control( new AST_Slider_Custom_Control( $wp_customize, 'tracking_info_settings[table_content_font_weight]',
|
906 |
array(
|
907 |
'label' => __( 'Content font weight', 'woo-advanced-shipment-tracking' ),
|
908 |
'section' => 'ast_tracking_general_section',
|
1017 |
public function active_callback_for_hide_trackig_header(){
|
1018 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1019 |
$hide_trackig_header = $ast->get_option_value_from_array('tracking_info_settings','hide_trackig_header','');
|
1020 |
+
return ( !$hide_trackig_header ) ? true : false ;
|
|
|
|
|
|
|
|
|
|
|
1021 |
}
|
1022 |
|
1023 |
public function active_callback_for_table_layout(){
|
1024 |
+
|
1025 |
+
$fluid_template = apply_filters( 'check_if_fluid_template_exist', false );
|
1026 |
+
if( $fluid_template )return false;
|
1027 |
+
|
1028 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1029 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1030 |
+
|
1031 |
+
return ( $select_tracking_template == 'default_table' ) ? true : false ;
|
|
|
|
|
|
|
1032 |
}
|
1033 |
|
1034 |
public function active_callback_for_table_layout_table_header(){
|
1035 |
+
|
1036 |
+
$fluid_template = apply_filters( 'check_if_fluid_template_exist', false );
|
1037 |
+
if( $fluid_template )return false;
|
1038 |
+
|
1039 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1040 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1041 |
$hide_table_header = $ast->get_option_value_from_array( 'tracking_info_settings','hide_table_header', '' );
|
1042 |
|
1043 |
+
return ( $select_tracking_template == 'default_table' && !$hide_table_header ) ? true : false ;
|
|
|
|
|
|
|
|
|
1044 |
}
|
1045 |
|
1046 |
public function active_callback_for_table_layout_tracking_link(){
|
1047 |
+
|
1048 |
+
$fluid_template = apply_filters( 'check_if_fluid_template_exist', false );
|
1049 |
+
if( $fluid_template )return false;
|
1050 |
+
|
1051 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1052 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1053 |
$tracking_number_link = $ast->get_option_value_from_array( 'tracking_info_settings','tracking_number_link', '' );
|
1054 |
|
1055 |
+
return ( $select_tracking_template == 'default_table' && !$tracking_number_link ) ? true : false ;
|
|
|
|
|
|
|
|
|
1056 |
}
|
1057 |
|
1058 |
public function active_callback_for_table_layout_tracking_link_track_header(){
|
1059 |
+
|
1060 |
+
$fluid_template = apply_filters( 'check_if_fluid_template_exist', false );
|
1061 |
+
if( $fluid_template )return false;
|
1062 |
+
|
1063 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1064 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1065 |
$tracking_number_link = $ast->get_option_value_from_array( 'tracking_info_settings','tracking_number_link', '' );
|
1066 |
$show_track_label = $ast->get_option_value_from_array( 'tracking_info_settings','show_track_label', '' );
|
1067 |
|
1068 |
+
return ( $select_tracking_template == 'default_table' && !$tracking_number_link && $show_track_label ) ? true : false ;
|
|
|
|
|
|
|
|
|
1069 |
}
|
1070 |
|
1071 |
public function active_callback_for_simple_layout(){
|
1072 |
+
|
1073 |
+
$fluid_template = apply_filters( 'check_if_fluid_template_exist', false );
|
1074 |
+
if( $fluid_template )return false;
|
1075 |
+
|
1076 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1077 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1078 |
+
|
1079 |
+
return ( $select_tracking_template == 'simple_list' ) ? true : false ;
|
|
|
|
|
|
|
1080 |
}
|
1081 |
|
1082 |
public function active_callback_for_simple_layout_show_provider_border(){
|
1083 |
+
|
1084 |
+
$fluid_template = apply_filters( 'check_if_fluid_template_exist', false );
|
1085 |
+
if( $fluid_template )return false;
|
1086 |
+
|
1087 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
1088 |
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$this->defaults['select_tracking_template']);
|
1089 |
$show_provider_border = $ast->get_option_value_from_array( 'tracking_info_settings','show_provider_border', $this->defaults['show_provider_border'] );
|
1090 |
|
1091 |
+
return ( $select_tracking_template == 'simple_list' && $show_provider_border ) ? true : false ;
|
|
|
|
|
|
|
|
|
1092 |
}
|
1093 |
|
1094 |
/**
|
1098 |
* @return void
|
1099 |
*/
|
1100 |
public function set_up_preview() {
|
|
|
1101 |
// Make sure this is own preview request.
|
1102 |
+
if ( ! $this->is_own_preview_request() )return;
|
1103 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/preview.php';exit;
|
|
|
|
|
|
|
1104 |
}
|
1105 |
|
1106 |
/**
|
1108 |
*/
|
1109 |
public function preview_completed_email(){
|
1110 |
|
1111 |
+
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
1112 |
|
1113 |
$tracking_info_settings = get_option('tracking_info_settings');
|
1114 |
|
1124 |
$email_template = 'customer_completed_order';
|
1125 |
$preview_id = get_theme_mod('wcast_preview_order_id');
|
1126 |
$email_type = 'WC_Email_Customer_Completed_Order';
|
1127 |
+
|
1128 |
+
if ( false === $email_type )return false;
|
1129 |
+
|
1130 |
|
1131 |
$order_status = 'completed';
|
1132 |
|
1143 |
}
|
1144 |
|
1145 |
// Get an order
|
1146 |
+
$order = $this->get_wc_order_for_preview( $order_status, $preview_id );
|
1147 |
|
1148 |
// Make sure gateways are running in case the email needs to input content from them.
|
1149 |
WC()->payment_gateways();
|
1177 |
* @param string $order_status
|
1178 |
* @return object
|
1179 |
*/
|
1180 |
+
public function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
|
1181 |
if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
|
1182 |
return wc_get_order( $order_id );
|
1183 |
} else {
|
includes/customizer/class-wc-tracking-page-customizer.php
CHANGED
@@ -19,9 +19,7 @@ class ts_tracking_page_customizer {
|
|
19 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
20 |
|
21 |
// Only proceed if this is own request.
|
22 |
-
if ( !
|
23 |
-
return;
|
24 |
-
}
|
25 |
|
26 |
// Register our sections
|
27 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
@@ -74,7 +72,7 @@ class ts_tracking_page_customizer {
|
|
74 |
* @access public
|
75 |
* @return bool
|
76 |
*/
|
77 |
-
public
|
78 |
return isset( $_REQUEST['action'] ) && 'preview_tracking_page' === $_REQUEST['action'];
|
79 |
}
|
80 |
|
@@ -84,7 +82,7 @@ class ts_tracking_page_customizer {
|
|
84 |
* @access public
|
85 |
* @return bool
|
86 |
*/
|
87 |
-
public
|
88 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'ast_tracking_page_section';
|
89 |
}
|
90 |
|
@@ -92,17 +90,14 @@ class ts_tracking_page_customizer {
|
|
92 |
* Get Customizer URL
|
93 |
*
|
94 |
*/
|
95 |
-
public
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
), admin_url( 'customize.php' ) );
|
104 |
-
|
105 |
-
return $customizer_url;
|
106 |
}
|
107 |
|
108 |
/**
|
@@ -111,8 +106,8 @@ class ts_tracking_page_customizer {
|
|
111 |
* @access public
|
112 |
* @return string
|
113 |
*/
|
114 |
-
public
|
115 |
-
return admin_url( 'admin.php?page=
|
116 |
}
|
117 |
|
118 |
/**
|
@@ -154,7 +149,7 @@ class ts_tracking_page_customizer {
|
|
154 |
'type' => 'option',
|
155 |
)
|
156 |
);
|
157 |
-
$wp_customize->add_control( new
|
158 |
array(
|
159 |
'label' => __( 'Widget Tracker Type', 'woo-advanced-shipment-tracking' ),
|
160 |
'section' => 'ast_tracking_page_section',
|
@@ -209,7 +204,7 @@ class ts_tracking_page_customizer {
|
|
209 |
'type' => 'option',
|
210 |
)
|
211 |
);
|
212 |
-
$wp_customize->add_control( new
|
213 |
array(
|
214 |
'label' => __( 'Events Display Type', 'woo-advanced-shipment-tracking' ),
|
215 |
'section' => 'ast_tracking_page_section',
|
@@ -255,23 +250,7 @@ class ts_tracking_page_customizer {
|
|
255 |
'section' => 'ast_tracking_page_section',
|
256 |
'type' => 'checkbox',
|
257 |
)
|
258 |
-
);
|
259 |
-
|
260 |
-
$wp_customize->add_setting( 'wc_ast_remove_trackship_branding',
|
261 |
-
array(
|
262 |
-
'default' => $this->defaults['wc_ast_remove_trackship_branding'],
|
263 |
-
'transport' => 'refresh',
|
264 |
-
'sanitize_callback' => '',
|
265 |
-
'type' => 'option',
|
266 |
-
)
|
267 |
-
);
|
268 |
-
$wp_customize->add_control( 'wc_ast_remove_trackship_branding',
|
269 |
-
array(
|
270 |
-
'label' => __( 'Hide TrackShip Branding', 'woo-advanced-shipment-tracking' ),
|
271 |
-
'section' => 'ast_tracking_page_section',
|
272 |
-
'type' => 'checkbox',
|
273 |
-
)
|
274 |
-
);
|
275 |
}
|
276 |
|
277 |
}
|
19 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
20 |
|
21 |
// Only proceed if this is own request.
|
22 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
|
|
|
|
23 |
|
24 |
// Register our sections
|
25 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
72 |
* @access public
|
73 |
* @return bool
|
74 |
*/
|
75 |
+
public function is_own_preview_request() {
|
76 |
return isset( $_REQUEST['action'] ) && 'preview_tracking_page' === $_REQUEST['action'];
|
77 |
}
|
78 |
|
82 |
* @access public
|
83 |
* @return bool
|
84 |
*/
|
85 |
+
public function is_own_customizer_request() {
|
86 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'ast_tracking_page_section';
|
87 |
}
|
88 |
|
90 |
* Get Customizer URL
|
91 |
*
|
92 |
*/
|
93 |
+
public function get_customizer_url( $email, $return_tab ) {
|
94 |
+
return add_query_arg( array(
|
95 |
+
'wcast-customizer' => '1',
|
96 |
+
'email' => $email,
|
97 |
+
'autofocus[section]' => 'ast_tracking_page_section',
|
98 |
+
'url' => urlencode( add_query_arg( array( 'action' => 'preview_tracking_page' ), home_url( '/' ) ) ),
|
99 |
+
'return' => urlencode( $this->get_email_settings_page_url( $return_tab ) ),
|
100 |
+
), admin_url( 'customize.php' ) );
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
/**
|
106 |
* @access public
|
107 |
* @return string
|
108 |
*/
|
109 |
+
public function get_email_settings_page_url( $return_tab ) {
|
110 |
+
return admin_url( 'admin.php?page=trackship-for-woocommerce&tab='.$return_tab );
|
111 |
}
|
112 |
|
113 |
/**
|
149 |
'type' => 'option',
|
150 |
)
|
151 |
);
|
152 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'wc_ast_select_tracking_page_layout',
|
153 |
array(
|
154 |
'label' => __( 'Widget Tracker Type', 'woo-advanced-shipment-tracking' ),
|
155 |
'section' => 'ast_tracking_page_section',
|
204 |
'type' => 'option',
|
205 |
)
|
206 |
);
|
207 |
+
$wp_customize->add_control( new AST_Dropdown_Select_Custom_Control( $wp_customize, 'wc_ast_hide_tracking_events',
|
208 |
array(
|
209 |
'label' => __( 'Events Display Type', 'woo-advanced-shipment-tracking' ),
|
210 |
'section' => 'ast_tracking_page_section',
|
250 |
'section' => 'ast_tracking_page_section',
|
251 |
'type' => 'checkbox',
|
252 |
)
|
253 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
|
256 |
}
|
includes/customizer/class-wc-updated-tracking-email-customizer.php
CHANGED
@@ -17,9 +17,8 @@ class wcast_updated_tracking_customizer_email {
|
|
17 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
18 |
|
19 |
// Only proceed if this is own request.
|
20 |
-
if ( !
|
21 |
-
|
22 |
-
}
|
23 |
// Register our sections
|
24 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
25 |
|
@@ -68,7 +67,7 @@ class wcast_updated_tracking_customizer_email {
|
|
68 |
* @access public
|
69 |
* @return bool
|
70 |
*/
|
71 |
-
public
|
72 |
return isset( $_REQUEST['wcast-updated-tracking-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-updated-tracking-email-customizer-preview'];
|
73 |
}
|
74 |
|
@@ -78,7 +77,7 @@ class wcast_updated_tracking_customizer_email {
|
|
78 |
* @access public
|
79 |
* @return bool
|
80 |
*/
|
81 |
-
public
|
82 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'custom_order_status_email';
|
83 |
}
|
84 |
|
@@ -86,17 +85,15 @@ class wcast_updated_tracking_customizer_email {
|
|
86 |
* Get Customizer URL
|
87 |
*
|
88 |
*/
|
89 |
-
public
|
90 |
-
|
91 |
'wcast-customizer' => '1',
|
92 |
'email' => $email,
|
93 |
'order_status' => $order_status,
|
94 |
'autofocus[section]' => 'custom_order_status_email',
|
95 |
'url' => urlencode( add_query_arg( array( 'wcast-updated-tracking-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
96 |
-
'return' => urlencode(
|
97 |
-
), admin_url( 'customize.php' ) );
|
98 |
-
|
99 |
-
return $customizer_url;
|
100 |
}
|
101 |
|
102 |
/**
|
@@ -105,7 +102,7 @@ class wcast_updated_tracking_customizer_email {
|
|
105 |
* @access public
|
106 |
* @return string
|
107 |
*/
|
108 |
-
public
|
109 |
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
|
110 |
}
|
111 |
|
@@ -120,7 +117,7 @@ class wcast_updated_tracking_customizer_email {
|
|
120 |
'wcast_enable_updated_tracking_email' => 'no',
|
121 |
);
|
122 |
|
123 |
-
return apply_filters( '
|
124 |
}
|
125 |
|
126 |
/**
|
@@ -130,22 +127,7 @@ class wcast_updated_tracking_customizer_email {
|
|
130 |
/**
|
131 |
* Load all our Customizer Custom Controls
|
132 |
*/
|
133 |
-
require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
|
134 |
-
|
135 |
-
/*$wp_customize->add_setting( 'updated_tracking_order_email_heading',
|
136 |
-
array(
|
137 |
-
'default' => '',
|
138 |
-
'transport' => 'postMessage',
|
139 |
-
'sanitize_callback' => ''
|
140 |
-
)
|
141 |
-
);
|
142 |
-
$wp_customize->add_control( new WP_Customize_Heading_Control( $wp_customize, 'updated_tracking_order_email_heading',
|
143 |
-
array(
|
144 |
-
'label' => __( 'Updated Tracking status email', 'woo-advanced-shipment-tracking' ),
|
145 |
-
'description' => '',
|
146 |
-
'section' => 'custom_order_status_email'
|
147 |
-
)
|
148 |
-
) );*/
|
149 |
|
150 |
// Display Shipment Provider image/thumbnail
|
151 |
$wp_customize->add_setting( 'customizer_updated_tracking_order_settings_enabled',
|
@@ -164,29 +146,7 @@ class wcast_updated_tracking_customizer_email {
|
|
164 |
'type' => 'checkbox',
|
165 |
'active_callback' => array( $this, 'active_callback' ),
|
166 |
)
|
167 |
-
);
|
168 |
-
|
169 |
-
// Preview Order
|
170 |
-
/*$wp_customize->add_setting( 'wcast_updated_tracking_preview_order_id',
|
171 |
-
array(
|
172 |
-
'default' => 'mockup',
|
173 |
-
'transport' => 'refresh',
|
174 |
-
'sanitize_callback' => ''
|
175 |
-
)
|
176 |
-
);
|
177 |
-
$wp_customize->add_control( new Skyrocket_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_updated_tracking_preview_order_id',
|
178 |
-
array(
|
179 |
-
'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
|
180 |
-
'description' => '',
|
181 |
-
'section' => 'custom_order_status_email',
|
182 |
-
'input_attrs' => array(
|
183 |
-
'placeholder' => __( 'Please select a order...', 'woo-advanced-shipment-tracking' ),
|
184 |
-
'class' => 'preview_order_select',
|
185 |
-
),
|
186 |
-
'choices' => wcast_customizer()->get_order_ids(),
|
187 |
-
'active_callback' => array( $this, 'active_callback' ),
|
188 |
-
)
|
189 |
-
) );*/
|
190 |
|
191 |
// Header Text
|
192 |
$wp_customize->add_setting( 'woocommerce_customer_updated_tracking_order_settings[subject]',
|
@@ -246,7 +206,7 @@ class wcast_updated_tracking_customizer_email {
|
|
246 |
'sanitize_callback' => 'wp_kses_post'
|
247 |
)
|
248 |
);
|
249 |
-
$wp_customize->add_control( new
|
250 |
array(
|
251 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
252 |
'description' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {customer_email}, {customer_first_name}, {customer_last_name}, {customer_username}, {order_number}',
|
@@ -278,11 +238,7 @@ class wcast_updated_tracking_customizer_email {
|
|
278 |
}
|
279 |
|
280 |
public function active_callback(){
|
281 |
-
|
282 |
-
return true;
|
283 |
-
} else{
|
284 |
-
return false;
|
285 |
-
}
|
286 |
}
|
287 |
|
288 |
/**
|
@@ -293,11 +249,8 @@ class wcast_updated_tracking_customizer_email {
|
|
293 |
*/
|
294 |
public function set_up_preview() {
|
295 |
// Make sure this is own preview request.
|
296 |
-
if ( !
|
297 |
-
|
298 |
-
}
|
299 |
-
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/updated_tracking_preview.php';
|
300 |
-
exit;
|
301 |
}
|
302 |
|
303 |
/**
|
@@ -337,7 +290,7 @@ class wcast_updated_tracking_customizer_email {
|
|
337 |
}
|
338 |
$order_status = 'updated-tracking';
|
339 |
// Get an order
|
340 |
-
$order =
|
341 |
|
342 |
// Make sure gateways are running in case the email needs to input content from them.
|
343 |
WC()->payment_gateways();
|
@@ -370,7 +323,7 @@ class wcast_updated_tracking_customizer_email {
|
|
370 |
* @param string $order_status
|
371 |
* @return object
|
372 |
*/
|
373 |
-
public
|
374 |
if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
|
375 |
return wc_get_order( $order_id );
|
376 |
} else {
|
@@ -420,11 +373,32 @@ class wcast_updated_tracking_customizer_email {
|
|
420 |
|
421 |
}
|
422 |
}
|
|
|
423 |
/**
|
424 |
-
*
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
-
$wcast_updated_tracking_customizer_settings = new wcast_updated_tracking_customizer_email();
|
428 |
add_action( 'customize_save_customizer_updated_tracking_order_settings_enabled', 'woocommerce_customer_updated_tracking_order_settings_fun', 100, 1 );
|
429 |
|
430 |
/**
|
17 |
add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
|
18 |
|
19 |
// Only proceed if this is own request.
|
20 |
+
if ( ! $this->is_own_customizer_request() && ! $this->is_own_preview_request() )return;
|
21 |
+
|
|
|
22 |
// Register our sections
|
23 |
add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
|
24 |
|
67 |
* @access public
|
68 |
* @return bool
|
69 |
*/
|
70 |
+
public function is_own_preview_request() {
|
71 |
return isset( $_REQUEST['wcast-updated-tracking-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-updated-tracking-email-customizer-preview'];
|
72 |
}
|
73 |
|
77 |
* @access public
|
78 |
* @return bool
|
79 |
*/
|
80 |
+
public function is_own_customizer_request() {
|
81 |
return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'custom_order_status_email';
|
82 |
}
|
83 |
|
85 |
* Get Customizer URL
|
86 |
*
|
87 |
*/
|
88 |
+
public function get_customizer_url( $email, $order_status ) {
|
89 |
+
return add_query_arg( array(
|
90 |
'wcast-customizer' => '1',
|
91 |
'email' => $email,
|
92 |
'order_status' => $order_status,
|
93 |
'autofocus[section]' => 'custom_order_status_email',
|
94 |
'url' => urlencode( add_query_arg( array( 'wcast-updated-tracking-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
|
95 |
+
'return' => urlencode( $this->get_email_settings_page_url() ),
|
96 |
+
), admin_url( 'customize.php' ) );
|
|
|
|
|
97 |
}
|
98 |
|
99 |
/**
|
102 |
* @access public
|
103 |
* @return string
|
104 |
*/
|
105 |
+
public function get_email_settings_page_url() {
|
106 |
return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
|
107 |
}
|
108 |
|
117 |
'wcast_enable_updated_tracking_email' => 'no',
|
118 |
);
|
119 |
|
120 |
+
return apply_filters( 'ast_customizer_defaults', $customizer_defaults );
|
121 |
}
|
122 |
|
123 |
/**
|
127 |
/**
|
128 |
* Load all our Customizer Custom Controls
|
129 |
*/
|
130 |
+
require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
// Display Shipment Provider image/thumbnail
|
133 |
$wp_customize->add_setting( 'customizer_updated_tracking_order_settings_enabled',
|
146 |
'type' => 'checkbox',
|
147 |
'active_callback' => array( $this, 'active_callback' ),
|
148 |
)
|
149 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
// Header Text
|
152 |
$wp_customize->add_setting( 'woocommerce_customer_updated_tracking_order_settings[subject]',
|
206 |
'sanitize_callback' => 'wp_kses_post'
|
207 |
)
|
208 |
);
|
209 |
+
$wp_customize->add_control( new AST_TinyMCE_Custom_control( $wp_customize, 'woocommerce_customer_updated_tracking_order_settings[wcast_updated_tracking_email_content]',
|
210 |
array(
|
211 |
'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
|
212 |
'description' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {customer_email}, {customer_first_name}, {customer_last_name}, {customer_username}, {order_number}',
|
238 |
}
|
239 |
|
240 |
public function active_callback(){
|
241 |
+
return ( $this->is_own_preview_request() ) ? true : false ;
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
|
244 |
/**
|
249 |
*/
|
250 |
public function set_up_preview() {
|
251 |
// Make sure this is own preview request.
|
252 |
+
if ( ! $this->is_own_preview_request() )return;
|
253 |
+
include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/updated_tracking_preview.php';exit;
|
|
|
|
|
|
|
254 |
}
|
255 |
|
256 |
/**
|
290 |
}
|
291 |
$order_status = 'updated-tracking';
|
292 |
// Get an order
|
293 |
+
$order = $this->get_wc_order_for_preview( $order_status, $preview_id );
|
294 |
|
295 |
// Make sure gateways are running in case the email needs to input content from them.
|
296 |
WC()->payment_gateways();
|
323 |
* @param string $order_status
|
324 |
* @return object
|
325 |
*/
|
326 |
+
public function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
|
327 |
if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
|
328 |
return wc_get_order( $order_id );
|
329 |
} else {
|
373 |
|
374 |
}
|
375 |
}
|
376 |
+
|
377 |
/**
|
378 |
+
* Returns an instance of zorem_woocommerce_advanced_shipment_tracking.
|
379 |
+
*
|
380 |
+
* @since 1.6.5
|
381 |
+
* @version 1.6.5
|
382 |
+
*
|
383 |
+
* @return zorem_woocommerce_advanced_shipment_tracking
|
384 |
+
*/
|
385 |
+
function ut_customizer() {
|
386 |
+
static $instance;
|
387 |
+
|
388 |
+
if ( ! isset( $instance ) ) {
|
389 |
+
$instance = new wcast_updated_tracking_customizer_email();
|
390 |
+
}
|
391 |
+
|
392 |
+
return $instance;
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Register this class globally.
|
397 |
+
*
|
398 |
+
* Backward compatibility.
|
399 |
+
*/
|
400 |
+
ut_customizer();
|
401 |
|
|
|
402 |
add_action( 'customize_save_customizer_updated_tracking_order_settings_enabled', 'woocommerce_customer_updated_tracking_order_settings_fun', 100, 1 );
|
403 |
|
404 |
/**
|
includes/customizer/class-wcast-customizer.php
CHANGED
@@ -15,8 +15,7 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
15 |
/**
|
16 |
* Initialize the main plugin function
|
17 |
*/
|
18 |
-
public function __construct() {
|
19 |
-
|
20 |
}
|
21 |
|
22 |
/**
|
@@ -53,7 +52,29 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
53 |
'title' => __( 'Shipping and Delivery Emails', 'woo-advanced-shipment-tracking' ),
|
54 |
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
55 |
)
|
56 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
/**
|
@@ -66,34 +87,28 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
66 |
wp_enqueue_style('wcast-customizer-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
67 |
wp_enqueue_script('wcast-customizer-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/customizer-scripts.js', array('jquery', 'customize-controls','wp-color-picker'), wc_advanced_shipment_tracking()->version, true);
|
68 |
|
69 |
-
$email_type = 'partially_shipped';
|
70 |
-
|
71 |
-
|
72 |
-
}
|
73 |
-
|
74 |
-
$shipment_status = 'in_transit';
|
75 |
-
if(isset( $_REQUEST['shipment_status'] )){
|
76 |
-
$shipment_status = $_REQUEST['shipment_status'];
|
77 |
-
}
|
78 |
-
|
79 |
// Send variables to Javascript
|
80 |
wp_localize_script('wcast-customizer-scripts', 'wcast_customizer', array(
|
81 |
'ajax_url' => admin_url('admin-ajax.php'),
|
82 |
'email_preview_url' => $this->get_email_preview_url(),
|
83 |
-
'partial_shipped_email_preview_url' => $this->get_partial_shipped_email_preview_url(),
|
|
|
84 |
'updated_tracking_email_preview_url' => $this->get_updated_tracking_email_preview_url(),
|
85 |
'email_type' => $email_type,
|
86 |
'shipment_status' => $shipment_status,
|
87 |
'tracking_preview_url' => $this->get_tracking_preview_url(),
|
88 |
'tracking_page_preview_url' => $this->get_tracking_page_preview_url(),
|
89 |
'customer_failure_preview_url' => $this->get_customer_failure_preview_url(),
|
|
|
90 |
'customer_intransit_preview_url' => $this->get_customer_intransit_preview_url(),
|
91 |
'customer_onhold_preview_url' => $this->get_customer_onhold_preview_url(),
|
92 |
'customer_outfordelivery_preview_url' => $this->get_customer_outfordelivery_preview_url(),
|
93 |
'customer_delivered_preview_url' => $this->get_customer_delivered_preview_url(),
|
94 |
'customer_returntosender_preview_url' => $this->get_customer_returntosender_preview_url(),
|
95 |
-
'customer_availableforpickup_preview_url' => $this->get_customer_availableforpickup_preview_url(),
|
96 |
-
'admin_late_shipments_preview_url' => $this->get_admin_late_shipments_preview_url(),
|
97 |
'trigger_click' => '#accordion-section-'.$_REQUEST['email'].' h3',
|
98 |
));
|
99 |
|
@@ -112,165 +127,151 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
112 |
* Get Customizer URL
|
113 |
*
|
114 |
*/
|
115 |
-
public
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
return $email_preview_url;
|
121 |
}
|
122 |
|
123 |
/**
|
124 |
* Get Customizer URL
|
125 |
*
|
126 |
*/
|
127 |
-
public
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
return $email_preview_url;
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
* Get Customizer URL
|
137 |
*
|
138 |
*/
|
139 |
-
public
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
return $email_preview_url;
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
* Get Customizer URL
|
149 |
*
|
150 |
*/
|
151 |
-
public
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
return $email_preview_url;
|
157 |
}
|
158 |
|
159 |
/**
|
160 |
* Get Customizer URL
|
161 |
*
|
162 |
*/
|
163 |
-
public
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
}
|
170 |
|
171 |
/**
|
172 |
* Get Tracking Page Preview URL
|
173 |
*
|
174 |
*/
|
175 |
-
public
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
return $tracking_page_preview_url;
|
181 |
}
|
182 |
|
183 |
/**
|
184 |
-
* Get
|
185 |
*
|
186 |
*/
|
187 |
-
public
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
return $customer_failure_preview_url;
|
193 |
}
|
194 |
|
195 |
/**
|
196 |
-
* Get
|
197 |
*
|
198 |
*/
|
199 |
-
public
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
return $customer_intransit_preview_url;
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
* Get Tracking page preview URL
|
209 |
*
|
210 |
*/
|
211 |
-
public
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
return $customer_onhold_preview_url;
|
217 |
}
|
218 |
|
219 |
/**
|
220 |
* Get Tracking page preview URL
|
221 |
*
|
222 |
*/
|
223 |
-
public
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
return $customer_intransit_preview_url;
|
229 |
}
|
230 |
|
231 |
/**
|
232 |
* Get Tracking page preview URL
|
233 |
*
|
234 |
*/
|
235 |
-
public
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
return $customer_intransit_preview_url;
|
241 |
}
|
242 |
|
243 |
/**
|
244 |
* Get Tracking page preview URL
|
245 |
*
|
246 |
*/
|
247 |
-
public
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
return $customer_intransit_preview_url;
|
253 |
}
|
254 |
|
255 |
/**
|
256 |
* Get Tracking page preview URL
|
257 |
*
|
258 |
*/
|
259 |
-
public
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
return $customer_intransit_preview_url;
|
265 |
}
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
return
|
273 |
-
|
|
|
|
|
274 |
|
275 |
/**
|
276 |
* Remove unrelated components
|
@@ -282,14 +283,13 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
282 |
*/
|
283 |
public function remove_unrelated_components($components, $wp_customize) {
|
284 |
// Iterate over components
|
285 |
-
foreach ($components as $component_key => $component) {
|
286 |
-
|
287 |
// Check if current component is own component
|
288 |
if ( ! $this->is_own_component( $component ) ) {
|
289 |
unset($components[$component_key]);
|
290 |
}
|
291 |
}
|
292 |
-
|
293 |
// Return remaining components
|
294 |
return $components;
|
295 |
}
|
@@ -312,25 +312,6 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
312 |
return true;
|
313 |
}
|
314 |
|
315 |
-
/**
|
316 |
-
* Remove unrelated controls
|
317 |
-
*
|
318 |
-
* @access public
|
319 |
-
* @param bool $active
|
320 |
-
* @param object $control
|
321 |
-
* @return bool
|
322 |
-
*/
|
323 |
-
public function remove_unrelated_controls( $active, $control ) {
|
324 |
-
|
325 |
-
// Check if current control belongs to own section
|
326 |
-
if ( ! wcast_add_customizer_sections::is_own_section( $control->section ) ) {
|
327 |
-
return false;
|
328 |
-
}
|
329 |
-
|
330 |
-
// We can override $active completely since this runs only on own Customizer requests
|
331 |
-
return $active;
|
332 |
-
}
|
333 |
-
|
334 |
/**
|
335 |
* Check if current component is own component
|
336 |
*
|
@@ -338,7 +319,7 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
338 |
* @param string $component
|
339 |
* @return bool
|
340 |
*/
|
341 |
-
public
|
342 |
return false;
|
343 |
}
|
344 |
|
@@ -349,7 +330,7 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
349 |
* @param string $key
|
350 |
* @return bool
|
351 |
*/
|
352 |
-
public
|
353 |
|
354 |
if ($key === 'wcast_naviation_panel' || $key === 'ast_tracking_general_section' || $key === 'custom_order_status_email' || $key === 'trackship_shipment_status_email' || $key === 'ast_tracking_page_section' ) {
|
355 |
return true;
|
@@ -383,7 +364,7 @@ class WC_Advanced_Shipment_Tracking_Customizer {
|
|
383 |
* @access public
|
384 |
* @return array
|
385 |
*/
|
386 |
-
public
|
387 |
$order_array = array();
|
388 |
$order_array['mockup'] = __( 'Mockup order', 'woo-advanced-shipment-tracking' );
|
389 |
|
15 |
/**
|
16 |
* Initialize the main plugin function
|
17 |
*/
|
18 |
+
public function __construct() {
|
|
|
19 |
}
|
20 |
|
21 |
/**
|
52 |
'title' => __( 'Shipping and Delivery Emails', 'woo-advanced-shipment-tracking' ),
|
53 |
'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
|
54 |
)
|
55 |
+
);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* add css and js for preview
|
60 |
+
*/
|
61 |
+
public function enqueue_preview_scripts() {
|
62 |
+
|
63 |
+
wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
|
64 |
+
wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
65 |
+
wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
|
66 |
+
'site_title' => $this->get_blogname(),
|
67 |
+
'order_number' => get_theme_mod('wcast_email_preview_order_id'),
|
68 |
+
));
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Get blog name formatted for emails.
|
73 |
+
*
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function get_blogname() {
|
77 |
+
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
78 |
}
|
79 |
|
80 |
/**
|
87 |
wp_enqueue_style('wcast-customizer-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer-styles.css', array(), wc_advanced_shipment_tracking()->version );
|
88 |
wp_enqueue_script('wcast-customizer-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/customizer-scripts.js', array('jquery', 'customize-controls','wp-color-picker'), wc_advanced_shipment_tracking()->version, true);
|
89 |
|
90 |
+
$email_type = ( isset($_REQUEST['order_status']) ) ? $_REQUEST['order_status'] : 'partially_shipped';
|
91 |
+
$shipment_status = ( isset($_REQUEST['shipment_status']) ) ? $_REQUEST['shipment_status'] : 'in_transit';
|
92 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
// Send variables to Javascript
|
94 |
wp_localize_script('wcast-customizer-scripts', 'wcast_customizer', array(
|
95 |
'ajax_url' => admin_url('admin-ajax.php'),
|
96 |
'email_preview_url' => $this->get_email_preview_url(),
|
97 |
+
'partial_shipped_email_preview_url' => $this->get_partial_shipped_email_preview_url(),
|
98 |
+
'shipped_email_preview_url' => $this->get_shipped_email_preview_url(),
|
99 |
'updated_tracking_email_preview_url' => $this->get_updated_tracking_email_preview_url(),
|
100 |
'email_type' => $email_type,
|
101 |
'shipment_status' => $shipment_status,
|
102 |
'tracking_preview_url' => $this->get_tracking_preview_url(),
|
103 |
'tracking_page_preview_url' => $this->get_tracking_page_preview_url(),
|
104 |
'customer_failure_preview_url' => $this->get_customer_failure_preview_url(),
|
105 |
+
'customer_exception_preview_url' => $this->get_customer_exception_preview_url(),
|
106 |
'customer_intransit_preview_url' => $this->get_customer_intransit_preview_url(),
|
107 |
'customer_onhold_preview_url' => $this->get_customer_onhold_preview_url(),
|
108 |
'customer_outfordelivery_preview_url' => $this->get_customer_outfordelivery_preview_url(),
|
109 |
'customer_delivered_preview_url' => $this->get_customer_delivered_preview_url(),
|
110 |
'customer_returntosender_preview_url' => $this->get_customer_returntosender_preview_url(),
|
111 |
+
'customer_availableforpickup_preview_url' => $this->get_customer_availableforpickup_preview_url(),
|
|
|
112 |
'trigger_click' => '#accordion-section-'.$_REQUEST['email'].' h3',
|
113 |
));
|
114 |
|
127 |
* Get Customizer URL
|
128 |
*
|
129 |
*/
|
130 |
+
public function get_email_preview_url() {
|
131 |
+
return add_query_arg( array(
|
132 |
+
'wcast-email-customizer-preview' => '1',
|
133 |
+
), home_url( '' ) );
|
|
|
|
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
* Get Customizer URL
|
138 |
*
|
139 |
*/
|
140 |
+
public function get_partial_shipped_email_preview_url() {
|
141 |
+
return add_query_arg( array(
|
142 |
+
'wcast-partial-shipped-email-customizer-preview' => '1',
|
143 |
+
), home_url( '' ) );
|
|
|
|
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
* Get Customizer URL
|
148 |
*
|
149 |
*/
|
150 |
+
public function get_shipped_email_preview_url(){
|
151 |
+
return add_query_arg( array(
|
152 |
+
'wcast-shipped-email-customizer-preview' => '1',
|
153 |
+
), home_url( '' ) );
|
|
|
|
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
* Get Customizer URL
|
158 |
*
|
159 |
*/
|
160 |
+
public function get_custom_completed_email_preview_url() {
|
161 |
+
return add_query_arg( array(
|
162 |
+
'wcast-custom-completed-email-customizer-preview' => '1',
|
163 |
+
), home_url( '' ) );
|
|
|
|
|
164 |
}
|
165 |
|
166 |
/**
|
167 |
* Get Customizer URL
|
168 |
*
|
169 |
*/
|
170 |
+
public function get_updated_tracking_email_preview_url() {
|
171 |
+
return add_query_arg( array(
|
172 |
+
'wcast-updated-tracking-email-customizer-preview' => '1',
|
173 |
+
), home_url( '' ) );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Get Customizer URL
|
178 |
+
*
|
179 |
+
*/
|
180 |
+
public function get_tracking_preview_url() {
|
181 |
+
return add_query_arg( array(
|
182 |
+
'wcast-tracking-preview' => '1',
|
183 |
+
), home_url( '' ) );
|
184 |
}
|
185 |
|
186 |
/**
|
187 |
* Get Tracking Page Preview URL
|
188 |
*
|
189 |
*/
|
190 |
+
public function get_tracking_page_preview_url() {
|
191 |
+
return add_query_arg( array(
|
192 |
+
'action' => 'preview_tracking_page',
|
193 |
+
), home_url( '' ) );
|
|
|
|
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
+
* Get Failuere Shipment status preview URL
|
198 |
*
|
199 |
*/
|
200 |
+
public function get_customer_failure_preview_url() {
|
201 |
+
return add_query_arg( array(
|
202 |
+
'wcast-failure-email-customizer-preview' => '1',
|
203 |
+
), home_url( '' ) );
|
|
|
|
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
* Get Exception Shipment status preview URL
|
208 |
*
|
209 |
*/
|
210 |
+
public function get_customer_exception_preview_url(){
|
211 |
+
return add_query_arg( array(
|
212 |
+
'wcast-exception-email-customizer-preview' => '1',
|
213 |
+
), home_url( '' ) );
|
|
|
|
|
214 |
}
|
215 |
|
216 |
/**
|
217 |
* Get Tracking page preview URL
|
218 |
*
|
219 |
*/
|
220 |
+
public function get_customer_intransit_preview_url() {
|
221 |
+
return add_query_arg( array(
|
222 |
+
'wcast-intransit-email-customizer-preview' => '1',
|
223 |
+
), home_url( '' ) );
|
|
|
|
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
* Get Tracking page preview URL
|
228 |
*
|
229 |
*/
|
230 |
+
public function get_customer_onhold_preview_url() {
|
231 |
+
return add_query_arg( array(
|
232 |
+
'wcast-onhold-email-customizer-preview' => '1',
|
233 |
+
), home_url( '' ) );
|
|
|
|
|
234 |
}
|
235 |
|
236 |
/**
|
237 |
* Get Tracking page preview URL
|
238 |
*
|
239 |
*/
|
240 |
+
public function get_customer_outfordelivery_preview_url() {
|
241 |
+
return add_query_arg( array(
|
242 |
+
'wcast-outfordelivery-email-customizer-preview' => '1',
|
243 |
+
), home_url( '' ) );
|
|
|
|
|
244 |
}
|
245 |
|
246 |
/**
|
247 |
* Get Tracking page preview URL
|
248 |
*
|
249 |
*/
|
250 |
+
public function get_customer_delivered_preview_url() {
|
251 |
+
return add_query_arg( array(
|
252 |
+
'wcast-delivered-email-customizer-preview' => '1',
|
253 |
+
), home_url( '' ) );
|
|
|
|
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
* Get Tracking page preview URL
|
258 |
*
|
259 |
*/
|
260 |
+
public function get_customer_returntosender_preview_url() {
|
261 |
+
return add_query_arg( array(
|
262 |
+
'wcast-returntosender-email-customizer-preview' => '1',
|
263 |
+
), home_url( '' ) );
|
|
|
|
|
264 |
}
|
265 |
|
266 |
+
/**
|
267 |
+
* Get Tracking page preview URL
|
268 |
+
*
|
269 |
+
*/
|
270 |
+
public function get_customer_availableforpickup_preview_url() {
|
271 |
+
return add_query_arg( array(
|
272 |
+
'wcast-availableforpickup-email-customizer-preview' => '1',
|
273 |
+
), home_url( '' ) );
|
274 |
+
}
|
275 |
|
276 |
/**
|
277 |
* Remove unrelated components
|
283 |
*/
|
284 |
public function remove_unrelated_components($components, $wp_customize) {
|
285 |
// Iterate over components
|
286 |
+
foreach ($components as $component_key => $component) {
|
|
|
287 |
// Check if current component is own component
|
288 |
if ( ! $this->is_own_component( $component ) ) {
|
289 |
unset($components[$component_key]);
|
290 |
}
|
291 |
}
|
292 |
+
|
293 |
// Return remaining components
|
294 |
return $components;
|
295 |
}
|
312 |
return true;
|
313 |
}
|
314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
/**
|
316 |
* Check if current component is own component
|
317 |
*
|
319 |
* @param string $component
|
320 |
* @return bool
|
321 |
*/
|
322 |
+
public function is_own_component( $component ) {
|
323 |
return false;
|
324 |
}
|
325 |
|
330 |
* @param string $key
|
331 |
* @return bool
|
332 |
*/
|
333 |
+
public function is_own_section( $key ) {
|
334 |
|
335 |
if ($key === 'wcast_naviation_panel' || $key === 'ast_tracking_general_section' || $key === 'custom_order_status_email' || $key === 'trackship_shipment_status_email' || $key === 'ast_tracking_page_section' ) {
|
336 |
return true;
|
364 |
* @access public
|
365 |
* @return array
|
366 |
*/
|
367 |
+
public function get_order_ids() {
|
368 |
$order_array = array();
|
369 |
$order_array['mockup'] = __( 'Mockup order', 'woo-advanced-shipment-tracking' );
|
370 |
|
includes/customizer/custom-controls.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
*/
|
6 |
if ( class_exists( 'WP_Customize_Control' ) ) {
|
@@ -34,12 +34,8 @@ if ( class_exists( 'WP_Customize_Control' ) ) {
|
|
34 |
|
35 |
/**
|
36 |
* Custom Control Base Class
|
37 |
-
*
|
38 |
-
* @author Anthony Hortin <http://maddisondesigns.com>
|
39 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
40 |
-
* @link https://github.com/maddisondesigns
|
41 |
*/
|
42 |
-
class
|
43 |
protected function get_skyrocket_resource_url() {
|
44 |
if( strpos( wp_normalize_path( __DIR__ ), wp_normalize_path( WP_PLUGIN_DIR ) ) === 0 ) {
|
45 |
// We're in a plugin directory and need to determine the url accordingly.
|
@@ -51,13 +47,9 @@ if ( class_exists( 'WP_Customize_Control' ) ) {
|
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* Slider Custom Control
|
55 |
-
*
|
56 |
-
* @author Anthony Hortin <http://maddisondesigns.com>
|
57 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
58 |
-
* @link https://github.com/maddisondesigns
|
59 |
*/
|
60 |
-
class
|
61 |
/**
|
62 |
* The type of control being rendered
|
63 |
*/
|
@@ -66,8 +58,8 @@ if ( class_exists( 'WP_Customize_Control' ) ) {
|
|
66 |
* Enqueue our scripts and styles
|
67 |
*/
|
68 |
public function enqueue() {
|
69 |
-
wp_enqueue_script( '
|
70 |
-
wp_enqueue_style( '
|
71 |
}
|
72 |
/**
|
73 |
* Render the control in the customizer
|
@@ -87,12 +79,8 @@ if ( class_exists( 'WP_Customize_Control' ) ) {
|
|
87 |
|
88 |
/**
|
89 |
* Dropdown Select2 Custom Control
|
90 |
-
*
|
91 |
-
* @author Anthony Hortin <http://maddisondesigns.com>
|
92 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
93 |
-
* @link https://github.com/maddisondesigns
|
94 |
*/
|
95 |
-
class
|
96 |
/**
|
97 |
* The type of control being rendered
|
98 |
*/
|
@@ -141,12 +129,8 @@ if ( class_exists( 'WP_Customize_Control' ) ) {
|
|
141 |
|
142 |
/**
|
143 |
* TinyMCE Custom Control
|
144 |
-
*
|
145 |
-
* @author Anthony Hortin <http://maddisondesigns.com>
|
146 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
147 |
-
* @link https://github.com/maddisondesigns
|
148 |
*/
|
149 |
-
class
|
150 |
/**
|
151 |
* The type of control being rendered
|
152 |
*/
|
@@ -155,8 +139,8 @@ if ( class_exists( 'WP_Customize_Control' ) ) {
|
|
155 |
* Enqueue our scripts and styles
|
156 |
*/
|
157 |
public function enqueue(){
|
158 |
-
wp_enqueue_script( '
|
159 |
-
wp_enqueue_style( '
|
160 |
wp_enqueue_editor();
|
161 |
}
|
162 |
/**
|
@@ -164,9 +148,9 @@ if ( class_exists( 'WP_Customize_Control' ) ) {
|
|
164 |
*/
|
165 |
public function to_json() {
|
166 |
parent::to_json();
|
167 |
-
$this->json['
|
168 |
-
$this->json['
|
169 |
-
$this->json['
|
170 |
}
|
171 |
/**
|
172 |
* Render the control in the customizer
|
1 |
<?php
|
2 |
/**
|
3 |
+
* AST Customizer Custom Controls
|
4 |
*
|
5 |
*/
|
6 |
if ( class_exists( 'WP_Customize_Control' ) ) {
|
34 |
|
35 |
/**
|
36 |
* Custom Control Base Class
|
|
|
|
|
|
|
|
|
37 |
*/
|
38 |
+
class AST_Custom_Control extends WP_Customize_Control {
|
39 |
protected function get_skyrocket_resource_url() {
|
40 |
if( strpos( wp_normalize_path( __DIR__ ), wp_normalize_path( WP_PLUGIN_DIR ) ) === 0 ) {
|
41 |
// We're in a plugin directory and need to determine the url accordingly.
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Slider Custom Control
|
|
|
|
|
|
|
|
|
51 |
*/
|
52 |
+
class AST_Slider_Custom_Control extends AST_Custom_Control {
|
53 |
/**
|
54 |
* The type of control being rendered
|
55 |
*/
|
58 |
* Enqueue our scripts and styles
|
59 |
*/
|
60 |
public function enqueue() {
|
61 |
+
wp_enqueue_script( 'ast-custom-controls-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/customizer.js', array( 'jquery', 'jquery-ui-core' ), wc_advanced_shipment_tracking()->version, true );
|
62 |
+
wp_enqueue_style( 'ast-custom-controls-css', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer.css', array(), wc_advanced_shipment_tracking()->version, 'all' );
|
63 |
}
|
64 |
/**
|
65 |
* Render the control in the customizer
|
79 |
|
80 |
/**
|
81 |
* Dropdown Select2 Custom Control
|
|
|
|
|
|
|
|
|
82 |
*/
|
83 |
+
class AST_Dropdown_Select_Custom_Control extends AST_Custom_Control {
|
84 |
/**
|
85 |
* The type of control being rendered
|
86 |
*/
|
129 |
|
130 |
/**
|
131 |
* TinyMCE Custom Control
|
|
|
|
|
|
|
|
|
132 |
*/
|
133 |
+
class AST_TinyMCE_Custom_control extends AST_Custom_Control {
|
134 |
/**
|
135 |
* The type of control being rendered
|
136 |
*/
|
139 |
* Enqueue our scripts and styles
|
140 |
*/
|
141 |
public function enqueue(){
|
142 |
+
wp_enqueue_script( 'ast-custom-controls-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/customizer.js', array( 'jquery', 'jquery-ui-core' ), wc_advanced_shipment_tracking()->version, true );
|
143 |
+
wp_enqueue_style( 'ast-custom-controls-css', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer.css', array(), wc_advanced_shipment_tracking()->version, 'all' );
|
144 |
wp_enqueue_editor();
|
145 |
}
|
146 |
/**
|
148 |
*/
|
149 |
public function to_json() {
|
150 |
parent::to_json();
|
151 |
+
$this->json['asttinymcetoolbar1'] = isset( $this->input_attrs['toolbar1'] ) ? esc_attr( $this->input_attrs['toolbar1'] ) : 'bold italic bullist numlist alignleft aligncenter alignright link';
|
152 |
+
$this->json['asttinymcetoolbar2'] = isset( $this->input_attrs['toolbar2'] ) ? esc_attr( $this->input_attrs['toolbar2'] ) : '';
|
153 |
+
$this->json['astmediabuttons'] = isset( $this->input_attrs['mediaButtons'] ) && ( $this->input_attrs['mediaButtons'] === true ) ? true : false;
|
154 |
}
|
155 |
/**
|
156 |
* Render the control in the customizer
|
includes/customizer/delivered_preview.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Exit if accessed directly
|
3 |
-
if (!defined('ABSPATH')) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
?>
|
7 |
-
<head>
|
8 |
-
<meta charset="<?php bloginfo('charset'); ?>" />
|
9 |
-
<meta name="viewport" content="width=device-width" />
|
10 |
-
<style type="text/css" id="kadence_woomail_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
11 |
-
</head>
|
12 |
-
|
13 |
-
<body>
|
14 |
-
<div id="kt_woomail_preview_wrapper" style="display: block;">
|
15 |
-
<?php wcast_initialise_customizer_email::preview_delivered_email(); ?>
|
16 |
-
</div>
|
17 |
-
|
18 |
-
<?php
|
19 |
-
do_action( 'woomail_footer' );
|
20 |
-
wp_footer(); ?>
|
21 |
-
</body>
|
22 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/customizer/preview/availableforpickup_preview.php
CHANGED
@@ -16,10 +16,8 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
</div>
|
23 |
|
24 |
<?php
|
25 |
do_action( 'woomail_footer' );
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
+
<?php $this->preview_availableforpickup_email(); ?>
|
20 |
+
</div>
|
|
|
|
|
21 |
|
22 |
<?php
|
23 |
do_action( 'woomail_footer' );
|
includes/customizer/preview/delivered_status_preview.php
CHANGED
@@ -16,10 +16,8 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
</div>
|
23 |
|
24 |
<?php
|
25 |
do_action( 'woomail_footer' );
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
+
<?php $this->preview_delivered_email(); ?>
|
20 |
+
</div>
|
|
|
|
|
21 |
|
22 |
<?php
|
23 |
do_action( 'woomail_footer' );
|
includes/customizer/preview/{delivered_preview.php → exception_preview.php}
RENAMED
@@ -16,10 +16,8 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
</div>
|
23 |
|
24 |
<?php
|
25 |
do_action( 'woomail_footer' );
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
+
<?php $this->preview_exception_email(); ?>
|
20 |
+
</div>
|
|
|
|
|
21 |
|
22 |
<?php
|
23 |
do_action( 'woomail_footer' );
|
includes/customizer/preview/failure_preview.php
CHANGED
@@ -7,8 +7,7 @@ if (!defined('ABSPATH')) {
|
|
7 |
?>
|
8 |
|
9 |
<head>
|
10 |
-
|
11 |
-
<meta charset="<?php bloginfo('charset'); ?>" />
|
12 |
<meta name="viewport" content="width=device-width" />
|
13 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
14 |
</head>
|
@@ -16,10 +15,8 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
</div>
|
23 |
|
24 |
<?php
|
25 |
do_action( 'woomail_footer' );
|
7 |
?>
|
8 |
|
9 |
<head>
|
10 |
+
<meta charset="<?php bloginfo('charset'); ?>" />
|
|
|
11 |
<meta name="viewport" content="width=device-width" />
|
12 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
13 |
</head>
|
15 |
<body class="ast_preview_body">
|
16 |
<div id="overlay"></div>
|
17 |
<div id="ast_preview_wrapper" style="display: block;">
|
18 |
+
<?php $this->preview_failure_email(); ?>
|
19 |
+
</div>
|
|
|
|
|
20 |
|
21 |
<?php
|
22 |
do_action( 'woomail_footer' );
|
includes/customizer/preview/intransit_preview.php
CHANGED
@@ -7,8 +7,7 @@ if (!defined('ABSPATH')) {
|
|
7 |
?>
|
8 |
|
9 |
<head>
|
10 |
-
|
11 |
-
<meta charset="<?php bloginfo('charset'); ?>" />
|
12 |
<meta name="viewport" content="width=device-width" />
|
13 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
14 |
</head>
|
@@ -16,10 +15,8 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
</div>
|
23 |
|
24 |
<?php
|
25 |
do_action( 'woomail_footer' );
|
7 |
?>
|
8 |
|
9 |
<head>
|
10 |
+
<meta charset="<?php bloginfo('charset'); ?>" />
|
|
|
11 |
<meta name="viewport" content="width=device-width" />
|
12 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
13 |
</head>
|
15 |
<body class="ast_preview_body">
|
16 |
<div id="overlay"></div>
|
17 |
<div id="ast_preview_wrapper" style="display: block;">
|
18 |
+
<?php $this->preview_intransit_email(); ?>
|
19 |
+
</div>
|
|
|
|
|
20 |
|
21 |
<?php
|
22 |
do_action( 'woomail_footer' );
|
includes/customizer/preview/onhold_preview.php
CHANGED
@@ -5,10 +5,8 @@ if (!defined('ABSPATH')) {
|
|
5 |
}
|
6 |
|
7 |
?>
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
<meta charset="<?php bloginfo('charset'); ?>" />
|
12 |
<meta name="viewport" content="width=device-width" />
|
13 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
14 |
</head>
|
@@ -16,15 +14,10 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
</div>
|
23 |
-
|
24 |
<?php
|
25 |
do_action( 'woomail_footer' );
|
26 |
wp_footer(); ?>
|
27 |
-
|
28 |
-
</body>
|
29 |
-
|
30 |
</html>
|
5 |
}
|
6 |
|
7 |
?>
|
8 |
+
<head>
|
9 |
+
<meta charset="<?php bloginfo('charset'); ?>" />
|
|
|
|
|
10 |
<meta name="viewport" content="width=device-width" />
|
11 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
12 |
</head>
|
14 |
<body class="ast_preview_body">
|
15 |
<div id="overlay"></div>
|
16 |
<div id="ast_preview_wrapper" style="display: block;">
|
17 |
+
<?php $this->preview_onhold_email(); ?>
|
18 |
+
</div>
|
|
|
|
|
|
|
19 |
<?php
|
20 |
do_action( 'woomail_footer' );
|
21 |
wp_footer(); ?>
|
22 |
+
</body>
|
|
|
|
|
23 |
</html>
|
includes/customizer/preview/outfordelivery_preview.php
CHANGED
@@ -7,8 +7,7 @@ if (!defined('ABSPATH')) {
|
|
7 |
?>
|
8 |
|
9 |
<head>
|
10 |
-
|
11 |
-
<meta charset="<?php bloginfo('charset'); ?>" />
|
12 |
<meta name="viewport" content="width=device-width" />
|
13 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
14 |
</head>
|
@@ -16,10 +15,8 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
</div>
|
23 |
|
24 |
<?php
|
25 |
do_action( 'woomail_footer' );
|
7 |
?>
|
8 |
|
9 |
<head>
|
10 |
+
<meta charset="<?php bloginfo('charset'); ?>" />
|
|
|
11 |
<meta name="viewport" content="width=device-width" />
|
12 |
<style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
|
13 |
</head>
|
15 |
<body class="ast_preview_body">
|
16 |
<div id="overlay"></div>
|
17 |
<div id="ast_preview_wrapper" style="display: block;">
|
18 |
+
<?php $this->preview_outfordelivery_email(); ?>
|
19 |
+
</div>
|
|
|
|
|
20 |
|
21 |
<?php
|
22 |
do_action( 'woomail_footer' );
|
includes/customizer/preview/returntosender_preview.php
CHANGED
@@ -16,9 +16,7 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
<?php wcast_returntosender_customizer_email::preview_returntosender_email(); ?>
|
21 |
-
|
22 |
</div>
|
23 |
|
24 |
<?php
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
+
<?php $this->preview_returntosender_email(); ?>
|
|
|
|
|
20 |
</div>
|
21 |
|
22 |
<?php
|
includes/customizer/preview/updated_tracking_preview.php
CHANGED
@@ -16,9 +16,7 @@ if (!defined('ABSPATH')) {
|
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
-
|
20 |
-
<?php wcast_updated_tracking_customizer_email::preview_updated_tracking_email(); ?>
|
21 |
-
|
22 |
</div>
|
23 |
|
24 |
<?php
|
16 |
<body class="ast_preview_body">
|
17 |
<div id="overlay"></div>
|
18 |
<div id="ast_preview_wrapper" style="display: block;">
|
19 |
+
<?php $this->preview_updated_tracking_email(); ?>
|
|
|
|
|
20 |
</div>
|
21 |
|
22 |
<?php
|
includes/email-manager.php
CHANGED
@@ -11,9 +11,11 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
|
|
11 |
*/
|
12 |
public function __construct() {
|
13 |
// template path
|
14 |
-
if (!defined(
|
|
|
|
|
15 |
// hook for when order status is changed
|
16 |
-
add_filter( 'woocommerce_email_classes', array( $this, 'custom_init_emails' ));
|
17 |
}
|
18 |
|
19 |
/**
|
@@ -22,16 +24,15 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
|
|
22 |
public function custom_init_emails( $emails ) {
|
23 |
|
24 |
// Include the email class file if it's not included already
|
25 |
-
|
26 |
-
|
27 |
-
if( $partial_shipped_status == true ){
|
28 |
if ( ! isset( $emails[ 'WC_Email_Customer_Partial_Shipped_Order' ] ) ) {
|
29 |
$emails[ 'WC_Email_Customer_Partial_Shipped_Order' ] = include_once( 'emails/class-shipment-partial-shipped-email.php' );
|
30 |
}
|
31 |
}
|
32 |
|
33 |
-
$updated_tracking_status = get_option(
|
34 |
-
if(
|
35 |
if ( ! isset( $emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] ) ) {
|
36 |
$emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] = include_once( 'emails/class-shipment-updated-tracking-email.php' );
|
37 |
}
|
@@ -42,10 +43,9 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
|
|
42 |
/**
|
43 |
* code for format email content
|
44 |
*/
|
45 |
-
public function email_content( $email_content, $order_id, $order ){
|
46 |
|
47 |
-
$
|
48 |
-
$order_id = $ast->get_custom_order_number( $order_id );
|
49 |
|
50 |
$customer_email = $order->get_billing_email();
|
51 |
$first_name = $order->get_billing_first_name();
|
@@ -53,26 +53,28 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
|
|
53 |
$company_name = $order->get_billing_company();
|
54 |
$user = $order->get_user();
|
55 |
|
56 |
-
if($user)
|
|
|
|
|
57 |
|
58 |
$email_content = str_replace( '{customer_email}', $customer_email, $email_content );
|
59 |
$email_content = str_replace( '{site_title}', $this->get_blogname(), $email_content );
|
60 |
$email_content = str_replace( '{customer_first_name}', $first_name, $email_content );
|
61 |
$email_content = str_replace( '{customer_last_name}', $last_name, $email_content );
|
62 |
|
63 |
-
if(isset($company_name)){
|
64 |
$email_content = str_replace( '{customer_company_name}', $company_name, $email_content );
|
65 |
-
} else{
|
66 |
$email_content = str_replace( '{customer_company_name}','', $email_content );
|
67 |
}
|
68 |
|
69 |
-
if(isset($username)){
|
70 |
$email_content = str_replace( '{customer_username}', $username, $email_content );
|
71 |
-
} else{
|
72 |
$email_content = str_replace( '{customer_username}', '', $email_content );
|
73 |
}
|
74 |
|
75 |
-
$email_content = str_replace( '{order_number}', $
|
76 |
|
77 |
return $email_content;
|
78 |
}
|
@@ -86,8 +88,7 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
|
|
86 |
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
87 |
}
|
88 |
|
89 |
-
}
|
90 |
-
new WC_Advanced_Shipment_Tracking_Email_Manager();
|
91 |
|
92 |
/**
|
93 |
* Returns an instance of zorem_woocommerce_advanced_shipment_tracking.
|
11 |
*/
|
12 |
public function __construct() {
|
13 |
// template path
|
14 |
+
if (!defined( 'AST_TEMPLATE_PATH' ) ) {
|
15 |
+
define( 'AST_TEMPLATE_PATH', SHIPMENT_TRACKING_PATH . '/templates/' );
|
16 |
+
}
|
17 |
// hook for when order status is changed
|
18 |
+
add_filter( 'woocommerce_email_classes', array( $this, 'custom_init_emails' ) );
|
19 |
}
|
20 |
|
21 |
/**
|
24 |
public function custom_init_emails( $emails ) {
|
25 |
|
26 |
// Include the email class file if it's not included already
|
27 |
+
$partial_shipped_status = get_option( 'wc_ast_status_partial_shipped', 0 );
|
28 |
+
if( true == $partial_shipped_status ) {
|
|
|
29 |
if ( ! isset( $emails[ 'WC_Email_Customer_Partial_Shipped_Order' ] ) ) {
|
30 |
$emails[ 'WC_Email_Customer_Partial_Shipped_Order' ] = include_once( 'emails/class-shipment-partial-shipped-email.php' );
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
$updated_tracking_status = get_option( 'wc_ast_status_updated_tracking', 0 );
|
35 |
+
if( true == $updated_tracking_status ) {
|
36 |
if ( ! isset( $emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] ) ) {
|
37 |
$emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] = include_once( 'emails/class-shipment-updated-tracking-email.php' );
|
38 |
}
|
43 |
/**
|
44 |
* code for format email content
|
45 |
*/
|
46 |
+
public function email_content( $email_content, $order_id, $order ) {
|
47 |
|
48 |
+
$order_number = $order->get_order_number();
|
|
|
49 |
|
50 |
$customer_email = $order->get_billing_email();
|
51 |
$first_name = $order->get_billing_first_name();
|
53 |
$company_name = $order->get_billing_company();
|
54 |
$user = $order->get_user();
|
55 |
|
56 |
+
if ( $user ) {
|
57 |
+
$username = $user->user_login;
|
58 |
+
}
|
59 |
|
60 |
$email_content = str_replace( '{customer_email}', $customer_email, $email_content );
|
61 |
$email_content = str_replace( '{site_title}', $this->get_blogname(), $email_content );
|
62 |
$email_content = str_replace( '{customer_first_name}', $first_name, $email_content );
|
63 |
$email_content = str_replace( '{customer_last_name}', $last_name, $email_content );
|
64 |
|
65 |
+
if ( isset( $company_name ) ) {
|
66 |
$email_content = str_replace( '{customer_company_name}', $company_name, $email_content );
|
67 |
+
} else {
|
68 |
$email_content = str_replace( '{customer_company_name}','', $email_content );
|
69 |
}
|
70 |
|
71 |
+
if ( isset( $username ) ) {
|
72 |
$email_content = str_replace( '{customer_username}', $username, $email_content );
|
73 |
+
} else {
|
74 |
$email_content = str_replace( '{customer_username}', '', $email_content );
|
75 |
}
|
76 |
|
77 |
+
$email_content = str_replace( '{order_number}', $order_number, $email_content );
|
78 |
|
79 |
return $email_content;
|
80 |
}
|
88 |
return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
89 |
}
|
90 |
|
91 |
+
}
|
|
|
92 |
|
93 |
/**
|
94 |
* Returns an instance of zorem_woocommerce_advanced_shipment_tracking.
|
includes/emails/class-shipment-partial-shipped-email.php
CHANGED
@@ -100,8 +100,7 @@ if ( ! class_exists( 'WC_Email_Customer_Partial_Shipped_Order', false ) ) :
|
|
100 |
public function get_content_html() {
|
101 |
$template = $this->get_template( 'template_html' );
|
102 |
$local_file = $this->get_theme_template_file( $template );
|
103 |
-
if ( file_exists( $local_file ) && is_writable( $local_file )){
|
104 |
-
//echo $local_file;exit;
|
105 |
return wc_get_template_html(
|
106 |
$this->template_html,
|
107 |
array(
|
@@ -113,6 +112,20 @@ if ( ! class_exists( 'WC_Email_Customer_Partial_Shipped_Order', false ) ) :
|
|
113 |
'email' => $this,
|
114 |
)
|
115 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
} else{
|
117 |
return wc_get_template_html(
|
118 |
'emails/customer-partial-shipped-order.php',
|
100 |
public function get_content_html() {
|
101 |
$template = $this->get_template( 'template_html' );
|
102 |
$local_file = $this->get_theme_template_file( $template );
|
103 |
+
if ( file_exists( $local_file ) && is_writable( $local_file )){
|
|
|
104 |
return wc_get_template_html(
|
105 |
$this->template_html,
|
106 |
array(
|
112 |
'email' => $this,
|
113 |
)
|
114 |
);
|
115 |
+
} else if( class_exists('ast_pro') ){
|
116 |
+
return wc_get_template_html(
|
117 |
+
'emails/customer-partial-shipped-order.php',
|
118 |
+
array(
|
119 |
+
'order' => $this->object,
|
120 |
+
'email_heading' => $this->get_heading(),
|
121 |
+
'additional_content' => $this->get_additional_content(),
|
122 |
+
'sent_to_admin' => false,
|
123 |
+
'plain_text' => false,
|
124 |
+
'email' => $this,
|
125 |
+
),
|
126 |
+
'woocommerce-advanced-shipment-tracking/',
|
127 |
+
ast_pro()->get_plugin_path() . '/templates/'
|
128 |
+
);
|
129 |
} else{
|
130 |
return wc_get_template_html(
|
131 |
'emails/customer-partial-shipped-order.php',
|
includes/tracking-info.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
* @param int $status_shipped 0=no,1=shipped,2=partial shipped(if partial shipped order status is enabled)
|
13 |
*/
|
14 |
|
15 |
-
function ast_insert_tracking_number($order_id, $tracking_number, $tracking_provider, $date_shipped = null, $status_shipped = 0){
|
16 |
$args = array(
|
17 |
'tracking_provider' => $tracking_provider,
|
18 |
'tracking_number' => $tracking_number,
|
@@ -36,7 +36,7 @@ function ast_insert_tracking_number($order_id, $tracking_number, $tracking_provi
|
|
36 |
* @param int $status_shipped 0=no,1=shipped,2=partial shipped(if partial shipped order status is enabled)
|
37 |
*/
|
38 |
|
39 |
-
function ast_add_tracking_number($order_id, $tracking_number, $tracking_provider, $date_shipped = null, $status_shipped = 0){
|
40 |
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
41 |
$args = array(
|
42 |
'tracking_provider' => $tracking_provider,
|
@@ -53,11 +53,10 @@ function ast_add_tracking_number($order_id, $tracking_number, $tracking_provider
|
|
53 |
* @param int $order_id The order id of the order you want to
|
54 |
* get tracking info.
|
55 |
*/
|
56 |
-
if (!function_exists('ast_get_tracking_items')){
|
57 |
-
function ast_get_tracking_items($order_id){
|
58 |
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
59 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
60 |
return $tracking_items;
|
61 |
}
|
62 |
}
|
63 |
-
?>
|
12 |
* @param int $status_shipped 0=no,1=shipped,2=partial shipped(if partial shipped order status is enabled)
|
13 |
*/
|
14 |
|
15 |
+
function ast_insert_tracking_number( $order_id, $tracking_number, $tracking_provider, $date_shipped = null, $status_shipped = 0 ) {
|
16 |
$args = array(
|
17 |
'tracking_provider' => $tracking_provider,
|
18 |
'tracking_number' => $tracking_number,
|
36 |
* @param int $status_shipped 0=no,1=shipped,2=partial shipped(if partial shipped order status is enabled)
|
37 |
*/
|
38 |
|
39 |
+
function ast_add_tracking_number( $order_id, $tracking_number, $tracking_provider, $date_shipped = null, $status_shipped = 0 ) {
|
40 |
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
41 |
$args = array(
|
42 |
'tracking_provider' => $tracking_provider,
|
53 |
* @param int $order_id The order id of the order you want to
|
54 |
* get tracking info.
|
55 |
*/
|
56 |
+
if ( !function_exists( 'ast_get_tracking_items' ) ) {
|
57 |
+
function ast_get_tracking_items( $order_id ) {
|
58 |
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
59 |
$tracking_items = $ast->get_tracking_items( $order_id, true );
|
60 |
return $tracking_items;
|
61 |
}
|
62 |
}
|
|
includes/trackship-email-manager.php
CHANGED
@@ -15,272 +15,155 @@ class WC_TrackShip_Email_Manager {
|
|
15 |
/**
|
16 |
* code for send shipment status email
|
17 |
*/
|
18 |
-
public function shippment_status_email_trigger( $order_id, $order, $old_status, $new_status , $tracking_item ){
|
19 |
|
20 |
-
$status = str_replace("_",""
|
21 |
-
$status_class = 'wcast_'
|
22 |
-
$
|
23 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
24 |
|
25 |
-
$
|
|
|
|
|
|
|
26 |
|
27 |
-
$
|
|
|
28 |
|
29 |
-
$email_to = $ast->get_option_value_from_array('wcast_'
|
|
|
30 |
|
31 |
-
$
|
|
|
32 |
|
33 |
-
$
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
$recipient = $this->email_to($email,$order,$order_id);
|
52 |
-
|
53 |
-
$email_content = $this->email_content($email_content,$order_id, $order);
|
54 |
-
|
55 |
-
$mailer = WC()->mailer();
|
56 |
-
|
57 |
-
$email_heading = $this->email_heading($email_heading,$order_id,$order);
|
58 |
-
|
59 |
-
$message = $this->append_analytics_link($email_content,$status);
|
60 |
-
|
61 |
-
$wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
62 |
-
$tracking_items = $wast->get_tracking_items( $order_id, true );
|
63 |
-
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
64 |
-
|
65 |
-
foreach($tracking_items as $key => $item){
|
66 |
-
if($item['tracking_number'] != $tracking_item['tracking_number']){
|
67 |
-
unset($tracking_items[$key]);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
ob_start();
|
72 |
-
$local_template = get_stylesheet_directory().'/woocommerce/emails/tracking-info.php';
|
73 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
74 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
75 |
-
'tracking_items' => $tracking_items,
|
76 |
-
'order_id' => $order_id,
|
77 |
-
'show_shipment_status' => true,
|
78 |
-
'new_status' => $new_status,
|
79 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
80 |
-
} else{
|
81 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
82 |
-
'tracking_items' => $tracking_items,
|
83 |
-
'order_id' => $order_id,
|
84 |
-
'show_shipment_status' => true,
|
85 |
-
'new_status' => $new_status,
|
86 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
87 |
-
}
|
88 |
-
$message .= ob_get_clean();
|
89 |
-
|
90 |
-
if($wcast_show_order_details == 1){
|
91 |
-
ob_start();
|
92 |
-
wc_get_template(
|
93 |
-
'emails/wcast-email-order-details.php', array(
|
94 |
-
'order' => $order,
|
95 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
96 |
-
'sent_to_admin' => $sent_to_admin,
|
97 |
-
'plain_text' => $plain_text,
|
98 |
-
'email' => '',
|
99 |
-
),
|
100 |
-
'woocommerce-advanced-shipment-tracking/',
|
101 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
102 |
-
);
|
103 |
-
$message .= ob_get_clean();
|
104 |
-
}
|
105 |
-
|
106 |
-
if($wcast_show_shipping_address == 1){
|
107 |
-
ob_start();
|
108 |
-
wc_get_template(
|
109 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
110 |
-
'order' => $order,
|
111 |
-
'sent_to_admin' => $sent_to_admin,
|
112 |
-
),
|
113 |
-
'woocommerce-advanced-shipment-tracking/',
|
114 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
115 |
-
);
|
116 |
-
$message .= ob_get_clean();
|
117 |
-
}
|
118 |
-
|
119 |
-
// create a new email
|
120 |
-
$email = new WC_Email();
|
121 |
-
|
122 |
-
// wrap the content with the email template and then add styles
|
123 |
-
$message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
124 |
-
$headers = "Content-Type: text/html\r\n";
|
125 |
-
add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
|
126 |
-
add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
|
127 |
-
|
128 |
-
$email_send = wp_mail( $recipient, $subject, $message, $email->get_headers() );
|
129 |
-
$logger = wc_get_logger();
|
130 |
-
$context = array( 'source' => 'trackship_shipment_status_email_log' );
|
131 |
-
$logger->error( "Order_Id: ".$order_id." Shipment_Status: ".$new_status." Email_Sent: " .$email_send, $context );
|
132 |
-
}
|
133 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
* code for send delivered shipment status email
|
138 |
*/
|
139 |
-
public function delivered_shippment_status_email_trigger($order_id, $order, $old_status, $new_status, $tracking_item){
|
140 |
|
141 |
-
$
|
142 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
143 |
|
144 |
-
$
|
|
|
|
|
|
|
145 |
|
146 |
-
$
|
|
|
147 |
|
148 |
-
$email_to = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_email_to'
|
|
|
149 |
|
150 |
-
$
|
|
|
|
|
|
|
|
|
151 |
|
152 |
-
$
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
if($wcast_show_tracking_details == 1){
|
193 |
-
ob_start();
|
194 |
-
$local_template = get_stylesheet_directory().'/woocommerce/emails/tracking-info.php';
|
195 |
-
if ( file_exists( $local_template ) && is_writable( $local_template )){
|
196 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
197 |
-
'tracking_items' => $tracking_items,
|
198 |
-
'order_id' => $order_id,
|
199 |
-
'show_shipment_status' => true,
|
200 |
-
'new_status' => $new_status,
|
201 |
-
), 'woocommerce-advanced-shipment-tracking/', get_stylesheet_directory() . '/woocommerce/' );
|
202 |
-
} else{
|
203 |
-
wc_get_template( 'emails/tracking-info.php', array(
|
204 |
-
'tracking_items' => $tracking_items,
|
205 |
-
'order_id' => $order_id,
|
206 |
-
'show_shipment_status' => true,
|
207 |
-
'new_status' => $new_status,
|
208 |
-
), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
|
209 |
-
}
|
210 |
-
$message .= ob_get_clean();
|
211 |
-
}
|
212 |
-
|
213 |
-
if($wcast_show_order_details == 1){
|
214 |
-
|
215 |
-
ob_start();
|
216 |
-
wc_get_template(
|
217 |
-
'emails/wcast-email-order-details.php', array(
|
218 |
-
'order' => $order,
|
219 |
-
'hide_shipping_item_price' => $hide_shipping_item_price,
|
220 |
-
'sent_to_admin' => $sent_to_admin,
|
221 |
-
'plain_text' => $plain_text,
|
222 |
-
'email' => '',
|
223 |
-
),
|
224 |
-
'woocommerce-advanced-shipment-tracking/',
|
225 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
226 |
-
);
|
227 |
-
$message .= ob_get_clean();
|
228 |
-
}
|
229 |
-
|
230 |
-
if($wcast_show_shipping_address == 1){
|
231 |
-
ob_start();
|
232 |
-
wc_get_template(
|
233 |
-
'emails/wcast-shipping-email-addresses.php', array(
|
234 |
-
'order' => $order,
|
235 |
-
'sent_to_admin' => $sent_to_admin,
|
236 |
-
),
|
237 |
-
'woocommerce-advanced-shipment-tracking/',
|
238 |
-
wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
|
239 |
-
);
|
240 |
-
$message .= ob_get_clean();
|
241 |
-
}
|
242 |
-
|
243 |
-
// create a new email
|
244 |
-
$email = new WC_Email();
|
245 |
-
|
246 |
-
// wrap the content with the email template and then add styles
|
247 |
-
$message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
248 |
-
$headers = "Content-Type: text/html\r\n";
|
249 |
-
add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
|
250 |
-
add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
|
251 |
-
|
252 |
-
$email_send = wp_mail( $recipient, $subject, $message, $email->get_headers() );
|
253 |
-
|
254 |
-
$logger = wc_get_logger();
|
255 |
-
$context = array( 'source' => 'trackship_shipment_status_email_log' );
|
256 |
-
$logger->error( "Order_Id: ".$order_id." Shipment_Status: ".$new_status." Email_Sent: " .$email_send, $context );
|
257 |
-
}
|
258 |
}
|
|
|
259 |
}
|
260 |
|
261 |
/**
|
262 |
* code for format email subject
|
263 |
*/
|
264 |
-
public function email_subject( $string, $order_id, $order ){
|
265 |
-
|
266 |
-
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
267 |
-
$order_id = $ast->get_custom_order_number( $order_id );
|
268 |
|
|
|
269 |
$customer_email = $order->get_billing_email();
|
270 |
$first_name = $order->get_billing_first_name();
|
271 |
$last_name = $order->get_billing_last_name();
|
272 |
$user = $order->get_user();
|
273 |
|
274 |
-
if($user)
|
|
|
|
|
275 |
|
276 |
-
$string = str_replace( '{order_number}', $
|
277 |
$string = str_replace( '{customer_email}', $customer_email, $string );
|
278 |
$string = str_replace( '{customer_first_name}', $first_name, $string );
|
279 |
$string = str_replace( '{customer_last_name}', $last_name, $string );
|
280 |
|
281 |
-
if(isset($username)){
|
282 |
$string = str_replace( '{customer_username}', $username, $string );
|
283 |
-
} else{
|
284 |
$string = str_replace( '{customer_username}', '', $string );
|
285 |
}
|
286 |
|
@@ -291,26 +174,26 @@ class WC_TrackShip_Email_Manager {
|
|
291 |
/**
|
292 |
* code for format email heading
|
293 |
*/
|
294 |
-
public function email_heading( $string, $order_id, $order ){
|
295 |
-
|
296 |
-
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
297 |
-
$order_id = $ast->get_custom_order_number( $order_id );
|
298 |
|
|
|
299 |
$customer_email = $order->get_billing_email();
|
300 |
$first_name = $order->get_billing_first_name();
|
301 |
$last_name = $order->get_billing_last_name();
|
302 |
$user = $order->get_user();
|
303 |
|
304 |
-
if($user)
|
|
|
|
|
305 |
|
306 |
-
$string = str_replace( '{order_number}', $
|
307 |
$string = str_replace( '{customer_email}', $customer_email, $string );
|
308 |
$string = str_replace( '{customer_first_name}', $first_name, $string );
|
309 |
$string = str_replace( '{customer_last_name}', $last_name, $string );
|
310 |
|
311 |
-
if(isset($username)){
|
312 |
$string = str_replace( '{customer_username}', $username, $string );
|
313 |
-
} else{
|
314 |
$string = str_replace( '{customer_username}', '', $string );
|
315 |
}
|
316 |
|
@@ -321,7 +204,7 @@ class WC_TrackShip_Email_Manager {
|
|
321 |
/**
|
322 |
* code for format recipients
|
323 |
*/
|
324 |
-
public function email_to( $string, $order, $order_id ){
|
325 |
$customer_email = $order->get_billing_email();
|
326 |
$admin_email = get_option('admin_email');
|
327 |
$string = str_replace( '{admin_email}', $admin_email, $string );
|
@@ -332,44 +215,48 @@ class WC_TrackShip_Email_Manager {
|
|
332 |
/**
|
333 |
* code for format email content
|
334 |
*/
|
335 |
-
public function email_content($email_content, $order_id, $order){
|
336 |
-
|
337 |
-
$ast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
338 |
-
$order_id = $ast->get_custom_order_number( $order_id );
|
339 |
|
|
|
340 |
$customer_email = $order->get_billing_email();
|
341 |
$first_name = $order->get_billing_first_name();
|
342 |
$last_name = $order->get_billing_last_name();
|
343 |
$company_name = $order->get_billing_company();
|
344 |
$user = $order->get_user();
|
345 |
|
346 |
-
if($user)
|
|
|
|
|
347 |
|
348 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
349 |
-
$api_enabled = get_option(
|
350 |
|
351 |
-
if($wc_ast_api_key && $api_enabled
|
|
|
|
|
352 |
|
353 |
$email_content = str_replace( '{customer_email}', $customer_email, $email_content );
|
354 |
$email_content = str_replace( '{site_title}', $this->get_blogname(), $email_content );
|
355 |
$email_content = str_replace( '{customer_first_name}', $first_name, $email_content );
|
356 |
$email_content = str_replace( '{customer_last_name}', $last_name, $email_content );
|
357 |
|
358 |
-
if(isset($company_name)){
|
359 |
$email_content = str_replace( '{customer_company_name}', $company_name, $email_content );
|
360 |
-
} else{
|
361 |
$email_content = str_replace( '{customer_company_name}','', $email_content );
|
362 |
}
|
363 |
|
364 |
-
if(isset($username)){
|
365 |
$email_content = str_replace( '{customer_username}', $username, $email_content );
|
366 |
-
} else{
|
367 |
$email_content = str_replace( '{customer_username}', '', $email_content );
|
368 |
}
|
369 |
|
370 |
-
$email_content = str_replace( '{order_number}', $
|
371 |
|
372 |
-
if($wc_ast_api_key && $api_enabled)
|
|
|
|
|
373 |
|
374 |
return $email_content;
|
375 |
}
|
@@ -377,17 +264,17 @@ class WC_TrackShip_Email_Manager {
|
|
377 |
/**
|
378 |
* code for append analytics link
|
379 |
*/
|
380 |
-
public function append_analytics_link($message
|
381 |
|
382 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
383 |
|
384 |
-
if(
|
385 |
-
$analytics_link = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_delivered_status_analytics_link','');
|
386 |
-
} else{
|
387 |
-
$analytics_link = $ast->get_option_value_from_array('wcast_'
|
388 |
}
|
389 |
|
390 |
-
if($analytics_link){
|
391 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
392 |
$message = preg_replace_callback($regex, function($match) use ($status){
|
393 |
$url = $match[2];
|
@@ -404,7 +291,7 @@ class WC_TrackShip_Email_Manager {
|
|
404 |
/**
|
405 |
* code for get estimate delivery date
|
406 |
*/
|
407 |
-
public function get_est_delivery_date($order_id, $order){
|
408 |
|
409 |
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
410 |
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
|
@@ -414,16 +301,17 @@ class WC_TrackShip_Email_Manager {
|
|
414 |
}
|
415 |
|
416 |
$html = '';
|
417 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
418 |
-
$shipment_status = get_post_meta( $order_id,
|
419 |
-
|
420 |
-
|
|
|
421 |
$tracking_number = $item['tracking_number'];
|
422 |
-
if(isset($shipment_status[$key]['est_delivery_date']) && $shipment_status[$key]['est_delivery_date']
|
423 |
$est_delivery_date = $shipment_status[$key]['est_delivery_date'];
|
424 |
$unixTimestamp = strtotime($est_delivery_date);
|
425 |
$day = date("l", $unixTimestamp);
|
426 |
-
$html .= '<div>Estimated Delivery Date for Tracking Number - '
|
427 |
}
|
428 |
}
|
429 |
}
|
@@ -459,8 +347,7 @@ class WC_TrackShip_Email_Manager {
|
|
459 |
return sanitize_email( $from_address );
|
460 |
}
|
461 |
|
462 |
-
}
|
463 |
-
new WC_TrackShip_Email_Manager();
|
464 |
|
465 |
/**
|
466 |
* Returns an instance of zorem_woocommerce_advanced_shipment_tracking.
|
15 |
/**
|
16 |
* code for send shipment status email
|
17 |
*/
|
18 |
+
public function shippment_status_email_trigger( $order_id, $order, $old_status, $new_status , $tracking_item, $shipment_status ) {
|
19 |
|
20 |
+
$status = str_replace( "_", "", $new_status );
|
21 |
+
$status_class = 'wcast_' . $status . '_customizer_email';
|
22 |
+
$status_customizer = new $status_class();
|
23 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
24 |
|
25 |
+
$enable = $ast->get_checkbox_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_enable_' . $status . '_email', '' );
|
26 |
+
if( !$enable ) {
|
27 |
+
return;
|
28 |
+
}
|
29 |
|
30 |
+
$email_subject = $ast->get_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_email_subject', $status_customizer->defaults[ 'wcast_' . $status . '_email_subject' ] );
|
31 |
+
$subject = $this->email_subject( $email_subject, $order_id, $order );
|
32 |
|
33 |
+
$email_to = $ast->get_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_email_to', $status_customizer->defaults[ 'wcast_' . $status . '_email_to' ] );
|
34 |
+
$email_to = explode( ",", $email_to );
|
35 |
|
36 |
+
$email_heading = $ast->get_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_email_heading', $status_customizer->defaults[ 'wcast_' . $status . '_email_heading' ] );
|
37 |
+
$email_content = $ast->get_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_email_content', $status_customizer->defaults[ 'wcast_' . $status . '_email_content' ] );
|
38 |
|
39 |
+
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_show_order_details', $status_customizer->defaults[ 'wcast_' . $status . '_show_order_details' ] );
|
40 |
|
41 |
+
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_hide_shipping_item_price', $status_customizer->defaults[ 'wcast_' . $status . '_hide_shipping_item_price']);
|
42 |
+
|
43 |
+
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_show_shipping_address', '' );
|
44 |
+
|
45 |
+
$email_content = $this->email_content( $email_content, $order_id, $order );
|
46 |
+
$email_heading = $this->email_heading( $email_heading, $order_id, $order );
|
47 |
+
|
48 |
+
$message = $this->append_analytics_link( $email_content, $status );
|
49 |
+
$message .= $ast->tracking_info_template( $order_id, array( $tracking_item ), $new_status );
|
50 |
+
|
51 |
+
if ( $wcast_show_order_details ) {
|
52 |
+
$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
53 |
+
}
|
54 |
+
|
55 |
+
if( $wcast_show_shipping_address ) {
|
56 |
+
$message .= $ast->order_shipping_details_template( $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
+
|
59 |
+
// create a new email
|
60 |
+
$email = new WC_Email();
|
61 |
+
$mailer = WC()->mailer();
|
62 |
+
|
63 |
+
// wrap the content with the email template and then add styles
|
64 |
+
$message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
65 |
+
add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
|
66 |
+
add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
|
67 |
+
|
68 |
+
foreach ( $email_to as $recipient_email ) {
|
69 |
+
$recipient = $this->email_to( $recipient_email, $order, $order_id );
|
70 |
+
$email_send = wp_mail( $recipient, $subject, $message, $email->get_headers() );
|
71 |
+
$logger = wc_get_logger();
|
72 |
+
$context = array( 'source' => 'trackship_shipment_status_email_log' );
|
73 |
+
$logger->error( "Order_Id: " . $order_id . " Shipment_Status: " . $new_status . " Email_Sent: " . $email_send, $context );
|
74 |
+
}
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
* code for send delivered shipment status email
|
79 |
*/
|
80 |
+
public function delivered_shippment_status_email_trigger( $order_id, $order, $old_status, $new_status, $tracking_item, $shipment_status ) {
|
81 |
|
82 |
+
$delivered_customizer = new wcast_delivered_customizer_email();
|
83 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
84 |
|
85 |
+
$enable = $ast->get_checkbox_option_value_from_array('wcast_delivered_email_settings','wcast_enable_delivered_status_email',$delivered_customizer->defaults['wcast_enable_delivered_status_email']);
|
86 |
+
if( !$enable ) {
|
87 |
+
return;
|
88 |
+
}
|
89 |
|
90 |
+
$email_subject = $ast->get_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_email_subject', $delivered_customizer->defaults[ 'wcast_delivered_status_email_subject' ] );
|
91 |
+
$subject = $this->email_subject( $email_subject, $order_id, $order );
|
92 |
|
93 |
+
$email_to = $ast->get_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_email_to', $delivered_customizer->defaults[ 'wcast_delivered_status_email_to' ] );
|
94 |
+
$email_to = explode( ",", $email_to );
|
95 |
|
96 |
+
$email_heading = $ast->get_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_email_heading', $delivered_customizer->defaults[ 'wcast_delivered_status_email_heading' ] );
|
97 |
+
$email_heading = $this->email_heading( $email_heading, $order_id, $order );
|
98 |
+
|
99 |
+
$email_content = $ast->get_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_email_content', $delivered_customizer->defaults[ 'wcast_delivered_status_email_content' ] );
|
100 |
+
$email_content = $this->email_content( $email_content, $order_id, $order );
|
101 |
|
102 |
+
$wcast_show_tracking_details = $ast->get_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_show_tracking_details', $delivered_customizer->defaults[ 'wcast_delivered_status_show_tracking_details' ] );
|
103 |
|
104 |
+
$wcast_show_order_details = $ast->get_checkbox_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_show_order_details', $delivered_customizer->defaults[ 'wcast_delivered_status_show_order_details' ] );
|
105 |
+
|
106 |
+
$wcast_show_shipping_address = $ast->get_checkbox_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_show_shipping_address', $delivered_customizer->defaults[ 'wcast_delivered_status_show_shipping_address' ] );
|
107 |
+
|
108 |
+
$hide_shipping_item_price = $ast->get_checkbox_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_hide_shipping_item_price', $delivered_customizer->defaults[ 'wcast_delivered_status_hide_shipping_item_price' ] );
|
109 |
+
|
110 |
+
$status = 'delivered_status';
|
111 |
+
$message = $this->append_analytics_link( $email_content, $status );
|
112 |
+
|
113 |
+
if ( $wcast_show_tracking_details ) {
|
114 |
+
$message .= $ast->tracking_info_template( $order_id, array( $tracking_item ), $new_status );
|
115 |
+
}
|
116 |
+
|
117 |
+
if ( $wcast_show_order_details ) {
|
118 |
+
$message .= $ast->order_details_template( $order, $hide_shipping_item_price );
|
119 |
+
}
|
120 |
+
|
121 |
+
if ( $wcast_show_shipping_address ) {
|
122 |
+
$message .= $ast->order_shipping_details_template( $order );
|
123 |
+
}
|
124 |
+
|
125 |
+
// create a new email
|
126 |
+
$email = new WC_Email();
|
127 |
+
$mailer = WC()->mailer();
|
128 |
+
|
129 |
+
// wrap the content with the email template and then add styles
|
130 |
+
$message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
|
131 |
+
add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
|
132 |
+
add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
|
133 |
+
|
134 |
+
foreach ( $email_to as $recipient_email ) {
|
135 |
+
$recipient = $this->email_to( $recipient_email, $order, $order_id );
|
136 |
+
$email_send = wp_mail( $recipient, $subject, $message, $email->get_headers() );
|
137 |
+
$logger = wc_get_logger();
|
138 |
+
$context = array( 'source' => 'trackship_shipment_status_email_log' );
|
139 |
+
$logger->error( "Order_Id: " . $order_id . " Shipment_Status: " . $new_status . " Email_Sent: " . $email_send, $context );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
+
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
* code for format email subject
|
146 |
*/
|
147 |
+
public function email_subject( $string, $order_id, $order ) {
|
|
|
|
|
|
|
148 |
|
149 |
+
$order_number = $order->get_order_number();
|
150 |
$customer_email = $order->get_billing_email();
|
151 |
$first_name = $order->get_billing_first_name();
|
152 |
$last_name = $order->get_billing_last_name();
|
153 |
$user = $order->get_user();
|
154 |
|
155 |
+
if ( $user ) {
|
156 |
+
$username = $user->user_login;
|
157 |
+
}
|
158 |
|
159 |
+
$string = str_replace( '{order_number}', $order_number, $string );
|
160 |
$string = str_replace( '{customer_email}', $customer_email, $string );
|
161 |
$string = str_replace( '{customer_first_name}', $first_name, $string );
|
162 |
$string = str_replace( '{customer_last_name}', $last_name, $string );
|
163 |
|
164 |
+
if ( isset( $username ) ) {
|
165 |
$string = str_replace( '{customer_username}', $username, $string );
|
166 |
+
} else {
|
167 |
$string = str_replace( '{customer_username}', '', $string );
|
168 |
}
|
169 |
|
174 |
/**
|
175 |
* code for format email heading
|
176 |
*/
|
177 |
+
public function email_heading( $string, $order_id, $order ) {
|
|
|
|
|
|
|
178 |
|
179 |
+
$order_number = $order->get_order_number();
|
180 |
$customer_email = $order->get_billing_email();
|
181 |
$first_name = $order->get_billing_first_name();
|
182 |
$last_name = $order->get_billing_last_name();
|
183 |
$user = $order->get_user();
|
184 |
|
185 |
+
if ( $user ) {
|
186 |
+
$username = $user->user_login;
|
187 |
+
}
|
188 |
|
189 |
+
$string = str_replace( '{order_number}', $order_number, $string );
|
190 |
$string = str_replace( '{customer_email}', $customer_email, $string );
|
191 |
$string = str_replace( '{customer_first_name}', $first_name, $string );
|
192 |
$string = str_replace( '{customer_last_name}', $last_name, $string );
|
193 |
|
194 |
+
if ( isset( $username ) ) {
|
195 |
$string = str_replace( '{customer_username}', $username, $string );
|
196 |
+
} else {
|
197 |
$string = str_replace( '{customer_username}', '', $string );
|
198 |
}
|
199 |
|
204 |
/**
|
205 |
* code for format recipients
|
206 |
*/
|
207 |
+
public function email_to( $string, $order, $order_id ) {
|
208 |
$customer_email = $order->get_billing_email();
|
209 |
$admin_email = get_option('admin_email');
|
210 |
$string = str_replace( '{admin_email}', $admin_email, $string );
|
215 |
/**
|
216 |
* code for format email content
|
217 |
*/
|
218 |
+
public function email_content( $email_content, $order_id, $order ) {
|
|
|
|
|
|
|
219 |
|
220 |
+
$order_number = $order->get_order_number();
|
221 |
$customer_email = $order->get_billing_email();
|
222 |
$first_name = $order->get_billing_first_name();
|
223 |
$last_name = $order->get_billing_last_name();
|
224 |
$company_name = $order->get_billing_company();
|
225 |
$user = $order->get_user();
|
226 |
|
227 |
+
if ( $user ) {
|
228 |
+
$username = $user->user_login;
|
229 |
+
}
|
230 |
|
231 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
232 |
+
$api_enabled = get_option( 'wc_ast_api_enabled', 0 );
|
233 |
|
234 |
+
if ( $wc_ast_api_key && $api_enabled ) {
|
235 |
+
$est_delivery_date = $this->get_est_delivery_date( $order->get_id(), $order );
|
236 |
+
}
|
237 |
|
238 |
$email_content = str_replace( '{customer_email}', $customer_email, $email_content );
|
239 |
$email_content = str_replace( '{site_title}', $this->get_blogname(), $email_content );
|
240 |
$email_content = str_replace( '{customer_first_name}', $first_name, $email_content );
|
241 |
$email_content = str_replace( '{customer_last_name}', $last_name, $email_content );
|
242 |
|
243 |
+
if ( isset( $company_name ) ) {
|
244 |
$email_content = str_replace( '{customer_company_name}', $company_name, $email_content );
|
245 |
+
} else {
|
246 |
$email_content = str_replace( '{customer_company_name}','', $email_content );
|
247 |
}
|
248 |
|
249 |
+
if ( isset( $username ) ) {
|
250 |
$email_content = str_replace( '{customer_username}', $username, $email_content );
|
251 |
+
} else {
|
252 |
$email_content = str_replace( '{customer_username}', '', $email_content );
|
253 |
}
|
254 |
|
255 |
+
$email_content = str_replace( '{order_number}', $order_number, $email_content );
|
256 |
|
257 |
+
if ( $wc_ast_api_key && $api_enabled ) {
|
258 |
+
$email_content = str_replace( '{est_delivery_date}', $est_delivery_date, $email_content );
|
259 |
+
}
|
260 |
|
261 |
return $email_content;
|
262 |
}
|
264 |
/**
|
265 |
* code for append analytics link
|
266 |
*/
|
267 |
+
public function append_analytics_link( $message, $status ) {
|
268 |
|
269 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
270 |
|
271 |
+
if ( 'delivered_status' == $status ) {
|
272 |
+
$analytics_link = $ast->get_option_value_from_array( 'wcast_delivered_email_settings', 'wcast_delivered_status_analytics_link', '' );
|
273 |
+
} else {
|
274 |
+
$analytics_link = $ast->get_option_value_from_array( 'wcast_' . $status . '_email_settings', 'wcast_' . $status . '_analytics_link', '' );
|
275 |
}
|
276 |
|
277 |
+
if ( $analytics_link ) {
|
278 |
$regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
|
279 |
$message = preg_replace_callback($regex, function($match) use ($status){
|
280 |
$url = $match[2];
|
291 |
/**
|
292 |
* code for get estimate delivery date
|
293 |
*/
|
294 |
+
public function get_est_delivery_date( $order_id, $order ) {
|
295 |
|
296 |
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
297 |
$tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
|
301 |
}
|
302 |
|
303 |
$html = '';
|
304 |
+
$wc_ast_api_key = get_option( 'wc_ast_api_key' );
|
305 |
+
$shipment_status = get_post_meta( $order_id, 'shipment_status', true);
|
306 |
+
|
307 |
+
if ( $tracking_items ) {
|
308 |
+
foreach ( $tracking_items as $key => $item ) {
|
309 |
$tracking_number = $item['tracking_number'];
|
310 |
+
if ( isset( $shipment_status[ $key ][ 'est_delivery_date' ] ) && '' != $shipment_status[ $key ][ 'est_delivery_date' ] ) {
|
311 |
$est_delivery_date = $shipment_status[$key]['est_delivery_date'];
|
312 |
$unixTimestamp = strtotime($est_delivery_date);
|
313 |
$day = date("l", $unixTimestamp);
|
314 |
+
$html .= '<div>Estimated Delivery Date for Tracking Number - ' . $tracking_number . '</div><h3 style="margin:0 0 10px;">' . $day . ', '.date("M d", strtotime($est_delivery_date)).'</h3>';
|
315 |
}
|
316 |
}
|
317 |
}
|
347 |
return sanitize_email( $from_address );
|
348 |
}
|
349 |
|
350 |
+
}
|
|
|
351 |
|
352 |
/**
|
353 |
* Returns an instance of zorem_woocommerce_advanced_shipment_tracking.
|
includes/views/admin_options_addons.php
CHANGED
@@ -71,38 +71,11 @@ $ast_paid_addons = array(
|
|
71 |
'price' => 49,
|
72 |
),
|
73 |
);
|
74 |
-
$ast_addons = array(
|
75 |
-
1 => array(
|
76 |
-
'title' => 'WC Shipping Tracking Add-on',
|
77 |
-
'description' => 'Add Advanced Shipment Tracking for WooCommerce Compatibility with WooCommerce Services plugin.',
|
78 |
-
'url' => 'https://www.zorem.com/product/wc-shipping-tracking-add-on/',
|
79 |
-
'image' => 'wc-addon-banner.jpg',
|
80 |
-
'file' => 'ast-compatibility-with-wc-shipstation/ast-compatibility-with-wc-shipstation.php',
|
81 |
-
'price' => 49,
|
82 |
-
),
|
83 |
-
2 => array(
|
84 |
-
'title' => 'ShipStation Tracking Add-on',
|
85 |
-
'description' => 'Add Advanced Shipment Tracking for WooCommerce Compatibility with WooCommerce ShipStation Integration plugin.',
|
86 |
-
'url' => 'https://www.zorem.com/product/shipstation-tracking-add-on/',
|
87 |
-
'image' => 'shipstations-addon-banner.jpg',
|
88 |
-
'file' => 'ast-compatibility-with-wc-shipstation/ast-compatibility-with-wc-shipstation.php',
|
89 |
-
'price' => 49,
|
90 |
-
),
|
91 |
-
3 => array(
|
92 |
-
'title' => 'ReadyToShip Tracking Add-on',
|
93 |
-
'description' => 'This plugin extends the API to work with Advanced Shipment Tracking for WooCommerce(AST) module, allowing for tracking numbers to be added and retrieved via the API',
|
94 |
-
'url' => 'https://www.zorem.com/product/readytoship-tracking-add-on/',
|
95 |
-
'image' => 'readytoship-addon-banner.jpg',
|
96 |
-
'file' => 'ready-to-ship-ast-Integration/ready-to-ship-ast-Integration.php',
|
97 |
-
'price' => 49,
|
98 |
-
),
|
99 |
-
);
|
100 |
-
|
101 |
|
102 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
103 |
?>
|
104 |
<section id="content6" class="tab_section">
|
105 |
-
<div class="
|
106 |
|
107 |
<?php
|
108 |
$show_addons_tab = apply_filters( 'ast_show_addons_tab', false );
|
@@ -118,115 +91,59 @@ $wc_ast_api_key = get_option('wc_ast_api_key');
|
|
118 |
} elseif ( class_exists( 'paypal_tracking_add_on' ) ) {
|
119 |
$show_addons_tab = true;
|
120 |
}
|
121 |
-
$addons = isset( $_GET['addons'] ) ? sanitize_text_field($_GET['addons']) : 'addons';
|
122 |
-
if ( $show_addons_tab) { ?>
|
123 |
-
<input id="tab_addons" type="radio" name="inner_tabs" class="inner_tab_input" data-addons="addons" <?php if($addons == 'addons'){ echo 'checked'; } ?>>
|
124 |
-
<label for="tab_addons" class="inner_tab_label"><?php _e( 'Add-ons', 'woo-advanced-shipment-tracking' ); ?></label>
|
125 |
-
|
126 |
-
<input id="tab_license" type="radio" name="inner_tabs" class="inner_tab_input" data-addons="license" <?php if($addons == 'license'){ echo 'checked'; } ?>>
|
127 |
-
<label for="tab_license" class="inner_tab_label"><?php _e( 'License', 'woo-advanced-shipment-tracking' ); ?></label>
|
128 |
-
<?php } ?>
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
</div>
|
139 |
-
<div class="as-col-6">
|
140 |
-
<div class="ts_col_inner">
|
141 |
-
<div class="ts_addon_logo_section">
|
142 |
-
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-logo.png">
|
143 |
-
</div>
|
144 |
-
<h1 class="ts_landing_header">Your Post-Shipping & Delivery Autopilot</h1>
|
145 |
-
<p class="ts_landing_description">Trackship is a Multi-Carrier Shipment Tracking API that seamlessly integrates into your WooCommerce store and auto-tracks your shipments, automates your orders workflow, reduces the time spent on customer service and lets you provide a superior post-purchase experience to your customers.</p>
|
146 |
-
<?php if($wc_ast_api_key){ ?>
|
147 |
-
<a href="https://trackship.info/my-account/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" class="button-primary btn_green2 btn_large" target="_blank" ><?php _e( 'Account Dashboard', 'woo-advanced-shipment-tracking' ); ?></a>
|
148 |
-
<?php } else{ ?>
|
149 |
-
<a href="https://trackship.info/?utm_source=wpadmin&utm_campaign=tspage" target="_blank" class="button-primary btn_green2 btn_large"><span><?php _e('Start your free trial', 'woo-advanced-shipment-tracking'); ?></span></a>
|
150 |
-
<?php } ?>
|
151 |
-
</div>
|
152 |
-
</div>
|
153 |
</div>
|
154 |
-
</div>
|
155 |
-
<div class="plugins_section free_plugin_section">
|
156 |
-
<?php foreach($ast_paid_addons as $plugin){ ?>
|
157 |
-
<div class="single_plugin as-col-6">
|
158 |
-
<div class="free_plugin_inner">
|
159 |
-
<div class="paid_plugin_image">
|
160 |
-
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/<?php echo $plugin['image']; ?>">
|
161 |
-
</div>
|
162 |
-
<div class="paid_plugin_description">
|
163 |
-
<h3 class="plugin_title"><?php echo $plugin['title']; ?></h3>
|
164 |
-
<p><?php echo $plugin['description']; ?></p>
|
165 |
-
<?php
|
166 |
-
if ( is_plugin_active( $plugin['file'] ) ) { ?>
|
167 |
-
<button type="button" class="button button button-primary btn_green2">Active</button>
|
168 |
-
<?php } else{ ?>
|
169 |
-
<a href="<?php echo $plugin['url']; ?>" class="button button-primary btn_ast2" target="blank"><?php _e('More Info', 'woo-advanced-shipment-tracking'); ?></a>
|
170 |
-
<?php } ?>
|
171 |
-
</div>
|
172 |
-
</div>
|
173 |
-
</div>
|
174 |
-
<?php } ?>
|
175 |
</div>
|
176 |
-
|
177 |
-
|
178 |
-
<?php foreach($more_plugins as $plugin){ ?>
|
179 |
-
<div class="single_plugin as-col-4">
|
180 |
-
<div class="free_plugin_inner">
|
181 |
-
<div class="paid_plugin_image">
|
182 |
-
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/<?php echo $plugin['image']; ?>">
|
183 |
-
</div>
|
184 |
-
<div class="paid_plugin_description">
|
185 |
-
<h3 class="plugin_title"><?php echo $plugin['title']; ?></h3>
|
186 |
-
<p><?php echo $plugin['description']; ?></p>
|
187 |
-
<?php
|
188 |
-
if ( is_plugin_active( $plugin['file'] ) ) { ?>
|
189 |
-
<button type="button" class="button button button-primary btn_green2">Active</button>
|
190 |
-
<?php } else{ ?>
|
191 |
-
<a href="<?php echo $plugin['url']; ?>" class="button button-primary btn_ast2" target="blank"><?php _e('More Info', 'woo-advanced-shipment-tracking'); ?></a>
|
192 |
-
<?php } ?>
|
193 |
-
</div>
|
194 |
-
</div>
|
195 |
-
</div>
|
196 |
-
<?php } ?>
|
197 |
-
</div>
|
198 |
-
|
199 |
-
<!--div class="plugins_section zorem_plugin_section">
|
200 |
-
<div class="addons_page_header">
|
201 |
-
<h2 class="addons_page_title">WooCommerce plugins by zorem</h2>
|
202 |
-
<p>Improve your store, automate your workflow and save time managing your store</p>
|
203 |
-
</div>
|
204 |
-
<div class="zorem_plugin_container">
|
205 |
-
<?php foreach($more_plugins as $plugin){ ?>
|
206 |
-
<div class="zorem_single_plugin">
|
207 |
-
<div class="free_plugin_inner">
|
208 |
-
<div class="plugin_image">
|
209 |
-
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/<?php echo $plugin['image']; ?>">
|
210 |
-
</div>
|
211 |
-
<div class="plugin_description">
|
212 |
-
<h3 class="plugin_title"><?php echo $plugin['title']; ?></h3>
|
213 |
-
<p><?php echo $plugin['description']; ?></p>
|
214 |
-
<?php
|
215 |
-
if ( is_plugin_active( $plugin['file'] ) ) { ?>
|
216 |
-
<button type="button" class="button button button-primary btn_green2">Active</button>
|
217 |
-
<?php } else{ ?>
|
218 |
-
<a href="<?php echo $plugin['url']; ?>" class="button button-primary btn_ast2" target="blank"><?php _e('More Info', 'woo-advanced-shipment-tracking'); ?></a>
|
219 |
-
<?php } ?>
|
220 |
-
</div>
|
221 |
-
</div>
|
222 |
-
</div>
|
223 |
-
<?php } ?>
|
224 |
-
</div>
|
225 |
-
</div-->
|
226 |
-
</section>
|
227 |
|
228 |
-
<
|
229 |
-
<?php
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
</div>
|
232 |
</section>
|
71 |
'price' => 49,
|
72 |
),
|
73 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
$wc_ast_api_key = get_option('wc_ast_api_key');
|
76 |
?>
|
77 |
<section id="content6" class="tab_section">
|
78 |
+
<div class="addons_page_dtable" style="">
|
79 |
|
80 |
<?php
|
81 |
$show_addons_tab = apply_filters( 'ast_show_addons_tab', false );
|
91 |
} elseif ( class_exists( 'paypal_tracking_add_on' ) ) {
|
92 |
$show_addons_tab = true;
|
93 |
}
|
94 |
+
$addons = isset( $_GET['addons'] ) ? sanitize_text_field($_GET['addons']) : 'addons'; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
<?php do_action('ast_addon_license_form'); ?>
|
97 |
+
<?php if(!class_exists('ast_pro')){ ?>
|
98 |
+
<div class="section-content trackship_addon_section">
|
99 |
+
<div class="ast-row">
|
100 |
+
<div class="as-col-6">
|
101 |
+
<div class="ts_col_inner">
|
102 |
+
<h1 class="ts_landing_header">Advanced Shipment Tracking PRO</h1>
|
103 |
+
<ul class="ast_pro_features_list">
|
104 |
+
<li>Premium Support</li>
|
105 |
+
<li>Tracking per item</li>
|
106 |
+
<li>Fluid Responsive tracking widget</li>
|
107 |
+
<li>Custom order status "Shipped"</li>
|
108 |
+
<li>Custom email templates</li>
|
109 |
+
<li>PayPal tracking integration</li>
|
110 |
+
<li>Unfulfilled orders filter</li>
|
111 |
+
<li>Auto-detect shipping providers</li>
|
112 |
+
<li>Paste tracking numbers</li>
|
113 |
+
<li>Integrations with ShipStation WC Shipping and more..</li>
|
114 |
+
</ul>
|
115 |
+
<a href="#" class="button-primary btn_ast2 btn_large">COMING SOON</a>
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
<div class="as-col-6">
|
119 |
+
<div class="ts_col_inner ast_ts_landing_banner">
|
120 |
+
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/ast-pro-banner.png">
|
121 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
</div>
|
124 |
+
</div>
|
125 |
+
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
+
<div class="plugins_section free_plugin_section">
|
128 |
+
<?php foreach($more_plugins as $plugin){ ?>
|
129 |
+
<div class="single_plugin as-col-4">
|
130 |
+
<div class="free_plugin_inner">
|
131 |
+
<div class="paid_plugin_image">
|
132 |
+
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/<?php echo $plugin['image']; ?>">
|
133 |
+
</div>
|
134 |
+
<div class="paid_plugin_description">
|
135 |
+
<h3 class="plugin_title"><?php echo $plugin['title']; ?></h3>
|
136 |
+
<p><?php echo $plugin['description']; ?></p>
|
137 |
+
<?php
|
138 |
+
if ( is_plugin_active( $plugin['file'] ) ) { ?>
|
139 |
+
<button type="button" class="button button button-primary btn_green2">Active</button>
|
140 |
+
<?php } else{ ?>
|
141 |
+
<a href="<?php echo $plugin['url']; ?>" class="button button-primary btn_ast2" target="blank"><?php _e('More Info', 'woo-advanced-shipment-tracking'); ?></a>
|
142 |
+
<?php } ?>
|
143 |
+
</div>
|
144 |
+
</div>
|
145 |
+
</div>
|
146 |
+
<?php } ?>
|
147 |
+
</div>
|
148 |
</div>
|
149 |
</section>
|
includes/views/admin_options_osm.php
CHANGED
@@ -1,104 +1,69 @@
|
|
1 |
-
<
|
2 |
-
<
|
3 |
-
<
|
4 |
-
<
|
5 |
-
<
|
6 |
-
<
|
7 |
-
<
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
<
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
<
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
} ?>
|
71 |
-
</span>
|
72 |
-
</td>
|
73 |
-
<td class="forminp">
|
74 |
-
<?php
|
75 |
-
$wcast_enable_updated_tracking_email = get_option('woocommerce_customer_updated_tracking_order_settings');
|
76 |
-
|
77 |
-
$updated_tracking_checked = '';
|
78 |
-
|
79 |
-
if(isset( $wcast_enable_updated_tracking_email['enabled'] )){
|
80 |
-
if( $wcast_enable_updated_tracking_email['enabled'] == 'yes' || $wcast_enable_updated_tracking_email['enabled'] == 1 ){
|
81 |
-
$updated_tracking_checked = 'checked';
|
82 |
-
}
|
83 |
-
} ?>
|
84 |
-
<fieldset>
|
85 |
-
<input class="input-text regular-input color_input" type="text" name="wc_ast_status_updated_tracking_label_color" id="wc_ast_status_updated_tracking_label_color" style="" value="<?php echo get_option('wc_ast_status_updated_tracking_label_color','#23a2dd')?>" placeholder="">
|
86 |
-
<select class="select custom_order_color_select" id="wc_ast_status_updated_tracking_label_font_color" name="wc_ast_status_updated_tracking_label_font_color">
|
87 |
-
<option value="#fff" <?php if(get_option('wc_ast_status_updated_tracking_label_font_color','#fff') == '#fff'){ echo 'selected'; }?>><?php _e( 'Light Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
88 |
-
<option value="#000" <?php if(get_option('wc_ast_status_updated_tracking_label_font_color','#fff') == '#000'){ echo 'selected'; }?>><?php _e( 'Dark Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
89 |
-
</select>
|
90 |
-
<label class="send_email_label">
|
91 |
-
<input type="hidden" name="wcast_enable_updated_tracking_email" value="0"/>
|
92 |
-
<input type="checkbox" name="wcast_enable_updated_tracking_email" id="wcast_enable_updated_tracking_email" class="enable_order_status_email_input" <?php echo $updated_tracking_checked; ?> value="1"><?php _e( 'Send Email', 'woo-advanced-shipment-tracking' ); ?>
|
93 |
-
</label>
|
94 |
-
<a class='settings_edit' href="<?php echo wcast_updated_tracking_customizer_email::get_customizer_url('custom_order_status_email','updated_tracking'); ?>"><?php _e( 'edit email', 'woocommerce' ) ?></a>
|
95 |
-
</fieldset>
|
96 |
-
</td>
|
97 |
-
</tr>
|
98 |
-
<?php do_action("ast_orders_status_column_end"); ?>
|
99 |
-
</tbody>
|
100 |
-
</table>
|
101 |
-
<?php wp_nonce_field( 'wc_ast_order_status_form', 'wc_ast_order_status_form_nonce' );?>
|
102 |
-
<input type="hidden" name="action" value="wc_ast_custom_order_status_form_update">
|
103 |
-
</div>
|
104 |
-
</form>
|
1 |
+
<div class="tabs_inner_section" id="content_osm_settings">
|
2 |
+
<form method="post" id="wc_ast_order_status_form" action="" enctype="multipart/form-data">
|
3 |
+
<div class="custom_order_status_section">
|
4 |
+
<table class="form-table order-status-table">
|
5 |
+
<tbody>
|
6 |
+
<tr valign="top">
|
7 |
+
<td class="forminp">
|
8 |
+
<input type="hidden" name="wc_ast_status_shipped" value="0"/>
|
9 |
+
<input class="ast-tgl ast-tgl-flat" id="wc_ast_status_shipped" name="wc_ast_status_shipped" type="checkbox" <?php if(get_option('wc_ast_status_shipped')){echo 'checked'; } ?> value="1"/>
|
10 |
+
<label class="ast-tgl-btn" for="wc_ast_status_shipped"></label>
|
11 |
+
</td>
|
12 |
+
<td colspan="2" class="status_shipped_label">
|
13 |
+
<?php _e( 'Rename the “Completed” Order status label to “Shipped”', 'woo-advanced-shipment-tracking' ); ?>
|
14 |
+
</td>
|
15 |
+
</tr>
|
16 |
+
|
17 |
+
<?php $osm_data = $this->get_osm_data();
|
18 |
+
foreach( $osm_data as $status => $data ){ ?>
|
19 |
+
<tr valign="top" class="<?php echo $status;?>_row <?php if(!get_option($data['id'])){echo 'disable_row'; } ?>">
|
20 |
+
<td class="forminp">
|
21 |
+
<input type="hidden" name="<?php echo $data['id'];?>" value="0"/>
|
22 |
+
<input class="ast-tgl ast-tgl-flat order_status_toggle" id="<?php echo $data['id'];?>" name="<?php echo $data['id'];?>" type="checkbox" <?php if(get_option($data['id'])){echo 'checked'; } ?> value="1"/>
|
23 |
+
<label class="ast-tgl-btn" for="<?php echo $data['id'];?>"></label>
|
24 |
+
</td>
|
25 |
+
<td class="forminp status-label-column">
|
26 |
+
<span class="order-label <?php echo $data['label_class'];?>">
|
27 |
+
<?php
|
28 |
+
if(get_option($data['id'])){
|
29 |
+
_e( wc_get_order_status_name( $data['slug'] ), 'woo-advanced-shipment-tracking' );
|
30 |
+
} else{
|
31 |
+
echo $data['label'];
|
32 |
+
} ?>
|
33 |
+
</span>
|
34 |
+
</td>
|
35 |
+
<td class="forminp">
|
36 |
+
<?php
|
37 |
+
$ast_enable_email = get_option($data['option_id']);
|
38 |
+
|
39 |
+
$checked = '';
|
40 |
+
|
41 |
+
if(isset( $ast_enable_email['enabled'] )){
|
42 |
+
if( $ast_enable_email['enabled'] == 'yes' || $ast_enable_email['enabled'] == 1 ){
|
43 |
+
$checked = 'checked';
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
?>
|
48 |
+
<fieldset>
|
49 |
+
<input class="input-text regular-input color_input" type="text" name="<?php echo $data['label_color_field']; ?>" id="<?php echo $data['label_color_field']; ?>" style="" value="<?php echo get_option($data['label_color_field'],'#1e73be')?>" placeholder="">
|
50 |
+
<select class="select custom_order_color_select" id="<?php echo $data['font_color_field']; ?>" name="<?php echo $data['font_color_field']; ?>">
|
51 |
+
<option value="#fff" <?php if(get_option($data['font_color_field'],'#fff') == '#fff'){ echo 'selected'; }?>><?php _e( 'Light Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
52 |
+
<option value="#000" <?php if(get_option($data['font_color_field'],'#fff') == '#000'){ echo 'selected'; }?>><?php _e( 'Dark Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
53 |
+
</select>
|
54 |
+
<label class="send_email_label">
|
55 |
+
<input type="hidden" name="<?php echo $data['email_field']; ?>" value="0"/>
|
56 |
+
<input type="checkbox" name="<?php echo $data['email_field']; ?>" id="<?php echo $data['email_field']; ?>"class="enable_order_status_email_input" <?php echo $checked; ?> value="1"><?php _e( 'Send Email', 'woo-advanced-shipment-tracking' ); ?></label>
|
57 |
+
<a class='settings_edit' href="<?php echo $data['edit_email']; ?>"><?php _e( 'edit email', 'woocommerce' ) ?></a>
|
58 |
+
</fieldset>
|
59 |
+
</td>
|
60 |
+
</tr>
|
61 |
+
<?php }
|
62 |
+
do_action("ast_orders_status_column_end"); ?>
|
63 |
+
</tbody>
|
64 |
+
</table>
|
65 |
+
<?php wp_nonce_field( 'wc_ast_order_status_form', 'wc_ast_order_status_form_nonce' );?>
|
66 |
+
<input type="hidden" name="action" value="wc_ast_custom_order_status_form_update">
|
67 |
+
</div>
|
68 |
+
</form>
|
69 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/views/admin_options_settings.php
CHANGED
@@ -5,61 +5,27 @@
|
|
5 |
?>
|
6 |
<section id="content2" class="tab_section">
|
7 |
<div class="tab_inner_container center">
|
8 |
-
<form method="post" id="wc_ast_settings_form" action="" enctype="multipart/form-data">
|
9 |
-
<?php #nonce?>
|
10 |
-
<div class="outer_form_table">
|
11 |
-
<table class="form-table heading-table">
|
12 |
-
<tbody>
|
13 |
-
<tr valign="top">
|
14 |
-
<td>
|
15 |
-
<h3 style=""><?php _e( 'General Settings', 'woo-advanced-shipment-tracking' ); ?></h3>
|
16 |
-
</td>
|
17 |
-
<td>
|
18 |
-
<div class="settings_ul_submit">
|
19 |
-
<div class="spinner"></div>
|
20 |
-
<button name="save" class="button-primary woocommerce-save-button btn_ast2" type="submit" value="Save changes"><?php _e( 'Save Changes', 'woo-advanced-shipment-tracking' ); ?></button>
|
21 |
-
<?php wp_nonce_field( 'wc_ast_settings_form', 'wc_ast_settings_form_nonce' );?>
|
22 |
-
<input type="hidden" name="action" value="wc_ast_settings_form_update">
|
23 |
-
</div>
|
24 |
-
</td>
|
25 |
-
</tr>
|
26 |
-
</tbody>
|
27 |
-
</table>
|
28 |
-
<?php $this->get_html_ul( $this->get_settings_data() );?>
|
29 |
-
</div>
|
30 |
-
</form>
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
<div class="outer_form_table">
|
35 |
-
<table class="form-table heading-table">
|
36 |
-
<tbody>
|
37 |
-
<tr valign="top">
|
38 |
-
<td>
|
39 |
-
<h3 style=""><?php _e( 'Tracking information display', 'woo-advanced-shipment-tracking' ); ?></h3>
|
40 |
-
</td>
|
41 |
-
</tr>
|
42 |
-
</tbody>
|
43 |
-
</table>
|
44 |
-
<ul class="settings_ul">
|
45 |
-
<li>
|
46 |
-
<label class="launch_customizer_label"><?php _e( 'Customize how the Tracking information display on the order emails and my-account', 'woo-advanced-shipment-tracking' ); ?></label>
|
47 |
-
<a href="<?php echo wcast_initialise_customizer_settings::get_customizer_url('ast_tracking_general_section','settings') ?>" class="button-primary btn_ast_transparent launch_customizer_btn"><?php _e( 'Customize', 'woo-advanced-shipment-tracking' ); ?></a>
|
48 |
-
</li>
|
49 |
-
</ul>
|
50 |
-
</div>
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
63 |
</div>
|
|
|
|
|
64 |
</div>
|
65 |
</section>
|
5 |
?>
|
6 |
<section id="content2" class="tab_section">
|
7 |
<div class="tab_inner_container center">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
<div class="tabs_outer_form_table">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
<?php $this->get_html_menu_tab( $this->get_ast_tab_general_settings_data(), 'inner_tab_input'); ?>
|
12 |
+
|
13 |
+
<div class="tabs_inner_section" id="content_general_settings">
|
14 |
+
<form method="post" id="wc_ast_settings_form" action="" enctype="multipart/form-data">
|
15 |
+
<?php $this->get_html_ul( $this->get_settings_data() );?>
|
16 |
+
<div class="tabs_submit">
|
17 |
+
<div class="spinner"></div>
|
18 |
+
<button name="save" class="button-primary woocommerce-save-button btn_ast2" type="submit" value="Save changes"><?php _e( 'Save Changes', 'woo-advanced-shipment-tracking' ); ?></button>
|
19 |
+
<?php wp_nonce_field( 'wc_ast_settings_form', 'wc_ast_settings_form_nonce' );?>
|
20 |
+
<input type="hidden" name="action" value="wc_ast_settings_form_update">
|
21 |
+
</div>
|
22 |
+
</form>
|
23 |
+
</div>
|
24 |
+
<?php require_once( 'admin_options_osm.php' );
|
25 |
+
do_action('ast_general_settings_panel');
|
26 |
+
?>
|
27 |
</div>
|
28 |
+
|
29 |
+
<?php do_action('ast_generat_settings_end'); ?>
|
30 |
</div>
|
31 |
</section>
|
includes/views/admin_options_shipping_provider.php
CHANGED
@@ -92,13 +92,13 @@ if(isset($_GET['open']) && $_GET['open'] == 'synch_providers'){ ?>
|
|
92 |
</div>
|
93 |
<div class="popup_body">
|
94 |
<form id="edit_provider_form" method="POST" class="edit_provider_form">
|
95 |
-
<div class="
|
96 |
<label><?php _e( 'Provider Name', 'woo-advanced-shipment-tracking' ); ?></label>
|
97 |
-
<input type="text" name="shipping_provider" value="" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>">
|
98 |
</div>
|
99 |
-
<div class="
|
100 |
<label><?php _e( 'Custom display name', 'woo-advanced-shipment-tracking' ); ?> <span class="woocommerce-help-tip tipTip" title="<?php _e( "The custom display name will show in the tracking info section on the customer order emails, my-account, and TrackShip's tracking page and email notifications", 'woo-advanced-shipment-tracking' ); ?>"></span> </label>
|
101 |
-
<input type="text" name="shipping_display_name" value="" placeholder="<?php _e( 'White Label Provider Name', 'woo-advanced-shipment-tracking' ); ?>">
|
102 |
</div>
|
103 |
<div class="form-field api_provider_name_container">
|
104 |
<label><?php _e( 'Custom API name', 'woo-advanced-shipment-tracking' ); ?> <span class="woocommerce-help-tip tipTip" title="<?php _e( "Add API name aliases to map Shipping providers names with the provider names that are updated in the shipment tracking API by external shipping services", 'woo-advanced-shipment-tracking' ); ?>"></span></label>
|
@@ -107,9 +107,9 @@ if(isset($_GET['open']) && $_GET['open'] == 'synch_providers'){ ?>
|
|
107 |
<?php do_action('add_more_api_provider'); ?>
|
108 |
</div>
|
109 |
</div>
|
110 |
-
<div class="
|
111 |
<label><?php _e( 'Country', 'woo-advanced-shipment-tracking' ); ?></label>
|
112 |
-
<select class="select wcast_shipping_country" name="shipping_country">
|
113 |
<option value=""><?php _e( 'Shipping Country', 'woo-advanced-shipment-tracking' ); ?></option>
|
114 |
<option value="Global"><?php _e( 'Global', 'woo-advanced-shipment-tracking' ); ?></option>
|
115 |
<?php foreach($countries as $key=>$val){ ?>
|
@@ -123,9 +123,9 @@ if(isset($_GET['open']) && $_GET['open'] == 'synch_providers'){ ?>
|
|
123 |
<input type='hidden' name='thumb_id' class='image_id thumb_id' placeholder="Image" value=''>
|
124 |
<input type="button" class="button upload_image_button" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" />
|
125 |
</div>
|
126 |
-
<div class="
|
127 |
<label><?php _e( 'Custom URL', 'woo-advanced-shipment-tracking' ); ?></label>
|
128 |
-
<input type="text" name="tracking_url" class="" placeholder="Tracking URL">
|
129 |
</div>
|
130 |
<div class="form-field custom_provider_instruction">
|
131 |
<p><?php _e( 'You can use the variables %number%, %postal_code% and %country_code% in the URL, for more info, check our ', 'woo-advanced-shipment-tracking' ); ?><?php echo sprintf(__('<a href="%s" target="blank">documentation</a>', 'woo-advanced-shipment-tracking'), 'http://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/setting-shipping-providers/#adding-custom-shipping-provider'); ?></p>
|
92 |
</div>
|
93 |
<div class="popup_body">
|
94 |
<form id="edit_provider_form" method="POST" class="edit_provider_form">
|
95 |
+
<div class="form-field form-50">
|
96 |
<label><?php _e( 'Provider Name', 'woo-advanced-shipment-tracking' ); ?></label>
|
97 |
+
<input type="text" name="shipping_provider" class="shipping_provider" value="" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>">
|
98 |
</div>
|
99 |
+
<div class="form-field form-50 margin-0">
|
100 |
<label><?php _e( 'Custom display name', 'woo-advanced-shipment-tracking' ); ?> <span class="woocommerce-help-tip tipTip" title="<?php _e( "The custom display name will show in the tracking info section on the customer order emails, my-account, and TrackShip's tracking page and email notifications", 'woo-advanced-shipment-tracking' ); ?>"></span> </label>
|
101 |
+
<input type="text" name="shipping_display_name" class="shipping_display_name" value="" placeholder="<?php _e( 'White Label Provider Name', 'woo-advanced-shipment-tracking' ); ?>">
|
102 |
</div>
|
103 |
<div class="form-field api_provider_name_container">
|
104 |
<label><?php _e( 'Custom API name', 'woo-advanced-shipment-tracking' ); ?> <span class="woocommerce-help-tip tipTip" title="<?php _e( "Add API name aliases to map Shipping providers names with the provider names that are updated in the shipment tracking API by external shipping services", 'woo-advanced-shipment-tracking' ); ?>"></span></label>
|
107 |
<?php do_action('add_more_api_provider'); ?>
|
108 |
</div>
|
109 |
</div>
|
110 |
+
<div class="form-field form-50">
|
111 |
<label><?php _e( 'Country', 'woo-advanced-shipment-tracking' ); ?></label>
|
112 |
+
<select class="select wcast_shipping_country shipping_country" name="shipping_country">
|
113 |
<option value=""><?php _e( 'Shipping Country', 'woo-advanced-shipment-tracking' ); ?></option>
|
114 |
<option value="Global"><?php _e( 'Global', 'woo-advanced-shipment-tracking' ); ?></option>
|
115 |
<?php foreach($countries as $key=>$val){ ?>
|
123 |
<input type='hidden' name='thumb_id' class='image_id thumb_id' placeholder="Image" value=''>
|
124 |
<input type="button" class="button upload_image_button" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" />
|
125 |
</div>
|
126 |
+
<div class="form-field">
|
127 |
<label><?php _e( 'Custom URL', 'woo-advanced-shipment-tracking' ); ?></label>
|
128 |
+
<input type="text" name="tracking_url" class="tracking_url" placeholder="Tracking URL">
|
129 |
</div>
|
130 |
<div class="form-field custom_provider_instruction">
|
131 |
<p><?php _e( 'You can use the variables %number%, %postal_code% and %country_code% in the URL, for more info, check our ', 'woo-advanced-shipment-tracking' ); ?><?php echo sprintf(__('<a href="%s" target="blank">documentation</a>', 'woo-advanced-shipment-tracking'), 'http://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/setting-shipping-providers/#adding-custom-shipping-provider'); ?></p>
|
includes/views/admin_options_trackship_integration.php
CHANGED
@@ -8,15 +8,16 @@ wp_enqueue_script( 'trackship_script' );
|
|
8 |
<div class="">
|
9 |
<div class="ts_col_inner">
|
10 |
<h1 class="ts_landing_header">Your Post-Shipping & Delivery Autopilot</h1>
|
11 |
-
<p class="ts_landing_description">Trackship is a Multi-Carrier Shipment Tracking API that seamlessly integrates into your WooCommerce store and auto-tracks your shipments, automates your orders workflow, reduces the time spent on customer service and lets you provide a superior post-purchase experience to your customers.</p>
|
|
|
12 |
</div>
|
13 |
</div>
|
|
|
14 |
<div class="">
|
15 |
<div class="ts_col_inner ts_landing_banner">
|
16 |
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/ts-header-banner.png">
|
17 |
<span class="dashicons dashicons-video-alt3 open_ts_video"></span>
|
18 |
-
</div>
|
19 |
-
<a href="https://trackship.info/?utm_source=wpadmin&utm_campaign=tspage" target="_blank" class="button-primary btn_green2 btn_large"><span><?php _e('Start for Free', 'woo-advanced-shipment-tracking'); ?></span><span class="dashicons dashicons-arrow-right-alt2"></span></a>
|
20 |
</div>
|
21 |
</div>
|
22 |
<div id="" class="popupwrapper ts_video_popup" style="display:none;">
|
8 |
<div class="">
|
9 |
<div class="ts_col_inner">
|
10 |
<h1 class="ts_landing_header">Your Post-Shipping & Delivery Autopilot</h1>
|
11 |
+
<p class="ts_landing_description">Trackship is a Multi-Carrier Shipment Tracking API that seamlessly integrates into your WooCommerce store and auto-tracks your shipments, automates your orders workflow, reduces the time spent on customer service and lets you provide a superior post-purchase experience to your customers.</p>
|
12 |
+
<h3>Start for Free. 50 Free trackers for new accounts!</h3>
|
13 |
</div>
|
14 |
</div>
|
15 |
+
<a href="https://trackship.info/?utm_source=wpadmin&utm_campaign=tspage" target="_blank" class="button-primary btn_green2 btn_large"><span><?php _e('Connect your store', 'woo-advanced-shipment-tracking'); ?></span><span class="dashicons dashicons-arrow-right-alt2"></span></a>
|
16 |
<div class="">
|
17 |
<div class="ts_col_inner ts_landing_banner">
|
18 |
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/ts-header-banner.png">
|
19 |
<span class="dashicons dashicons-video-alt3 open_ts_video"></span>
|
20 |
+
</div>
|
|
|
21 |
</div>
|
22 |
</div>
|
23 |
<div id="" class="popupwrapper ts_video_popup" style="display:none;">
|
includes/views/admin_status_notifications.php
CHANGED
@@ -1,26 +1,14 @@
|
|
1 |
-
<section id="content_status_notifications" class="
|
2 |
<div class="tab_inner_container">
|
3 |
<div class="outer_form_table ts_notifications_outer_table">
|
4 |
<?php
|
5 |
-
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
6 |
-
|
7 |
-
$wcast_enable_intransit_email = $ast->get_option_value_from_array('wcast_intransit_email_settings','wcast_enable_intransit_email','');
|
8 |
-
|
9 |
-
$wcast_enable_onhold_email = $ast->get_option_value_from_array('wcast_onhold_email_settings','wcast_enable_onhold_email','');
|
10 |
-
|
11 |
-
$wcast_enable_outfordelivery_email = $ast->get_option_value_from_array('wcast_outfordelivery_email_settings','wcast_enable_outfordelivery_email','');
|
12 |
-
|
13 |
-
$wcast_enable_failure_email = $ast->get_option_value_from_array('wcast_failure_email_settings','wcast_enable_failure_email','');
|
14 |
-
|
15 |
-
$wcast_enable_delivered_status_email = $ast->get_option_value_from_array('wcast_delivered_email_settings','wcast_enable_delivered_status_email','');
|
16 |
-
|
17 |
-
$wcast_enable_returntosender_email = $ast->get_option_value_from_array('wcast_returntosender_email_settings','wcast_enable_returntosender_email','');
|
18 |
-
|
19 |
-
$wcast_enable_availableforpickup_email = $ast->get_option_value_from_array('wcast_availableforpickup_email_settings','wcast_enable_availableforpickup_email','');
|
20 |
|
21 |
$wcast_enable_late_shipments_admin_email = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_enable_late_shipments_admin_email','');
|
22 |
|
23 |
$type = isset( $_GET['type'] ) ? sanitize_text_field($_GET['type']) : 'email';
|
|
|
|
|
24 |
?>
|
25 |
|
26 |
<input id="tab_email_notifications" type="radio" name="ts_notification_tabs" class="inner_tab_input" data-type="email" <?php if($type == 'email'){ echo 'checked'; } ?>>
|
@@ -29,130 +17,61 @@
|
|
29 |
<input id="tab_sms_notifications" type="radio" name="ts_notification_tabs" class="inner_tab_input" data-type="sms" <?php if($type == 'sms'){ echo 'checked'; } ?>>
|
30 |
<label for="tab_sms_notifications" class="inner_tab_label ts_tabs_label"><?php _e( 'SMS Notifications', 'woo-advanced-shipment-tracking' ); ?></label>
|
31 |
|
32 |
-
<section class="inner_tab_section shipment-status-email-section">
|
33 |
-
<
|
34 |
-
<tbody>
|
35 |
-
<tr class="<?php if($wcast_enable_intransit_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
36 |
-
<td class="forminp status-label-column">
|
37 |
-
<span class="shipment_status_toggle">
|
38 |
-
<input type="hidden" name="wcast_enable_intransit_email" value="0"/>
|
39 |
-
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_intransit_email" name="wcast_enable_intransit_email" data-settings="wcast_intransit_email_settings" type="checkbox" <?php if($wcast_enable_intransit_email == 1) { echo 'checked'; } ?> value="yes"/>
|
40 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_intransit_email"></label>
|
41 |
-
</span>
|
42 |
-
<button class="button button-primary shipment-status-label in-transit"><?php _e('In Transit', 'woo-advanced-shipment-tracking'); ?></button>
|
43 |
-
</td>
|
44 |
-
<td class="forminp">
|
45 |
-
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo wcast_intransit_customizer_email::get_customizer_url('trackship_shipment_status_email','in_transit','trackship') ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
46 |
-
</td>
|
47 |
-
</tr>
|
48 |
-
<tr class="<?php if($wcast_enable_onhold_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
49 |
-
<td class="forminp status-label-column">
|
50 |
-
<span class="shipment_status_toggle">
|
51 |
-
<input type="hidden" name="wcast_enable_onhold_email" value="0"/>
|
52 |
-
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_onhold_email" name="wcast_enable_onhold_email" data-settings="wcast_onhold_email_settings" type="checkbox" <?php if($wcast_enable_onhold_email == 1) { echo 'checked'; } ?> value="yes"/>
|
53 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_onhold_email"></label>
|
54 |
-
</span>
|
55 |
-
<button class="button button-primary shipment-status-label on-hold"><?php _e('On Hold', 'woo-advanced-shipment-tracking'); ?></button>
|
56 |
-
</td>
|
57 |
-
<td class="forminp">
|
58 |
-
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo wcast_onhold_customizer_email::get_customizer_url('trackship_shipment_status_email','on_hold','trackship') ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
59 |
-
</td>
|
60 |
-
</tr>
|
61 |
-
<tr class="<?php if($wcast_enable_returntosender_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
62 |
-
<td class="forminp status-label-column">
|
63 |
-
<span class="shipment_status_toggle">
|
64 |
-
<input type="hidden" name="wcast_enable_returntosender_email" value="0"/>
|
65 |
-
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_returntosender_email" name="wcast_enable_returntosender_email" data-settings="wcast_returntosender_email_settings" type="checkbox" <?php if($wcast_enable_returntosender_email == 1) { echo 'checked'; } ?> value="yes"/>
|
66 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_returntosender_email"></label>
|
67 |
-
</span>
|
68 |
-
<button class="button button-primary shipment-status-label return-to-sender"><?php _e('Return To Sender', 'woo-advanced-shipment-tracking'); ?></button>
|
69 |
-
</td>
|
70 |
-
<td class="forminp">
|
71 |
-
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo wcast_returntosender_customizer_email::get_customizer_url('trackship_shipment_status_email','return_to_sender','trackship') ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
72 |
-
</td>
|
73 |
-
</tr>
|
74 |
-
<tr class="<?php if($wcast_enable_availableforpickup_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
75 |
-
<td class="forminp status-label-column">
|
76 |
-
<span class="shipment_status_toggle">
|
77 |
-
<input type="hidden" name="wcast_enable_availableforpickup_email" value="0"/>
|
78 |
-
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_availableforpickup_email" name="wcast_enable_availableforpickup_email" data-settings="wcast_availableforpickup_email_settings" type="checkbox" <?php if($wcast_enable_availableforpickup_email == 1) { echo 'checked'; } ?> value="yes"/>
|
79 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_availableforpickup_email"></label>
|
80 |
-
</span>
|
81 |
-
<button class="button button-primary shipment-status-label available-for-pickup"><?php _e('Available For Pickup', 'woo-advanced-shipment-tracking'); ?></button>
|
82 |
-
</td>
|
83 |
-
<td class="forminp">
|
84 |
-
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo wcast_availableforpickup_customizer_email::get_customizer_url('trackship_shipment_status_email','available_for_pickup','trackship') ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
85 |
-
</td>
|
86 |
-
</tr>
|
87 |
-
<tr class="<?php if($wcast_enable_outfordelivery_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
88 |
-
<td class="forminp status-label-column">
|
89 |
-
<span class="shipment_status_toggle">
|
90 |
-
<input type="hidden" name="wcast_enable_outfordelivery_email" value="0"/>
|
91 |
-
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_outfordelivery_email" name="wcast_enable_outfordelivery_email" data-settings="wcast_outfordelivery_email_settings" type="checkbox" <?php if($wcast_enable_outfordelivery_email == 1) { echo 'checked'; } ?> value="yes"/>
|
92 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_outfordelivery_email"></label>
|
93 |
-
</span>
|
94 |
-
<button class="button button-primary shipment-status-label out-for-delivery"><?php _e('Out For Delivery', 'woo-advanced-shipment-tracking'); ?></button>
|
95 |
-
</td>
|
96 |
-
<td class="forminp">
|
97 |
-
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo wcast_outfordelivery_customizer_email::get_customizer_url('trackship_shipment_status_email','out_for_delivery','trackship') ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
98 |
-
</td>
|
99 |
-
</tr>
|
100 |
-
<tr class="<?php if( $wcast_enable_delivered_status_email == 1 ){ echo 'enable'; } else{ echo 'disable'; }?>">
|
101 |
-
<td class="forminp status-label-column">
|
102 |
-
<span class="shipment_status_toggle">
|
103 |
-
<input type="hidden" name="wcast_enable_delivered_status_email" value="0"/>
|
104 |
-
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_delivered_status_email" name="wcast_enable_delivered_status_email" data-settings="wcast_delivered_email_settings" type="checkbox" <?php if( $wcast_enable_delivered_status_email == 1 ) { echo 'checked'; } ?> value="yes"/>
|
105 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_delivered_status_email"></label>
|
106 |
-
</span>
|
107 |
-
<button class="button button-primary shipment-status-label delivered-status"><?php _e('Delivered', 'woo-advanced-shipment-tracking'); ?></button>
|
108 |
-
</td>
|
109 |
-
<td class="forminp">
|
110 |
-
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo wcast_delivered_customizer_email::get_customizer_url('trackship_shipment_status_email','delivered','trackship') ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
111 |
-
</td>
|
112 |
-
</tr>
|
113 |
-
<tr class="<?php if($wcast_enable_failure_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
114 |
-
<td class="forminp status-label-column">
|
115 |
-
<span class="shipment_status_toggle">
|
116 |
-
<input type="hidden" name="wcast_enable_failure_email" value="0"/>
|
117 |
-
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_failure_email" name="wcast_enable_failure_email" data-settings="wcast_failure_email_settings" type="checkbox" <?php if($wcast_enable_failure_email == 1) { echo 'checked'; } ?> value="yes"/>
|
118 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_failure_email"></label>
|
119 |
-
</span>
|
120 |
-
<button class="button button-primary shipment-status-label failed-attempt"><?php _e('Failed Attempt', 'woo-advanced-shipment-tracking'); ?></button>
|
121 |
-
</td>
|
122 |
-
<td class="forminp">
|
123 |
-
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo wcast_failure_customizer_email::get_customizer_url('trackship_shipment_status_email','failure','trackship') ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
124 |
-
</td>
|
125 |
-
</tr>
|
126 |
-
</tbody>
|
127 |
-
</table>
|
128 |
-
<?php do_action( 'after_shipment_status_email_notifications' ); ?>
|
129 |
-
<form method="post" id="trackship_late_shipments_form" action="" enctype="multipart/form-data">
|
130 |
-
<table class="form-table heading-table">
|
131 |
-
<tbody>
|
132 |
-
<tr valign="top">
|
133 |
-
<td>
|
134 |
-
<h3 style=""><?php _e( 'Admin Notifications', 'woo-advanced-shipment-tracking' ); ?></h3>
|
135 |
-
</td>
|
136 |
-
</tr>
|
137 |
-
</tbody>
|
138 |
-
</table>
|
139 |
<table class="form-table shipment-status-email-table">
|
140 |
<tbody>
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
<
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
154 |
</tbody>
|
155 |
-
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
<?php
|
157 |
$late_shipments_email_settings = get_option('late_shipments_email_settings');
|
158 |
$wcast_late_shipments_days = isset( $late_shipments_email_settings['wcast_late_shipments_days'] ) ? $late_shipments_email_settings['wcast_late_shipments_days'] : '';
|
@@ -161,86 +80,87 @@
|
|
161 |
$wcast_late_shipments_email_content = isset( $late_shipments_email_settings['wcast_late_shipments_email_content'] ) ? $late_shipments_email_settings['wcast_late_shipments_email_content'] : '';
|
162 |
$wcast_late_shipments_trigger_alert = isset( $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] ) ? $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] : '';
|
163 |
$wcast_late_shipments_daily_digest_time = isset( $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] ) ? $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] : ''; ?>
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
|
|
244 |
</form>
|
245 |
</section>
|
246 |
<section class="inner_tab_section shipment-status-sms-section">
|
1 |
+
<section id="content_status_notifications" class="tab_section">
|
2 |
<div class="tab_inner_container">
|
3 |
<div class="outer_form_table ts_notifications_outer_table">
|
4 |
<?php
|
5 |
+
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
$wcast_enable_late_shipments_admin_email = $ast->get_option_value_from_array('late_shipments_email_settings','wcast_enable_late_shipments_admin_email','');
|
8 |
|
9 |
$type = isset( $_GET['type'] ) ? sanitize_text_field($_GET['type']) : 'email';
|
10 |
+
|
11 |
+
$ts_notifications = $this->trackship_shipment_status_notifications_data();
|
12 |
?>
|
13 |
|
14 |
<input id="tab_email_notifications" type="radio" name="ts_notification_tabs" class="inner_tab_input" data-type="email" <?php if($type == 'email'){ echo 'checked'; } ?>>
|
17 |
<input id="tab_sms_notifications" type="radio" name="ts_notification_tabs" class="inner_tab_input" data-type="sms" <?php if($type == 'sms'){ echo 'checked'; } ?>>
|
18 |
<label for="tab_sms_notifications" class="inner_tab_label ts_tabs_label"><?php _e( 'SMS Notifications', 'woo-advanced-shipment-tracking' ); ?></label>
|
19 |
|
20 |
+
<section class="inner_tab_section shipment-status-email-section">
|
21 |
+
<div class="custom_order_status_section">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
<table class="form-table shipment-status-email-table">
|
23 |
<tbody>
|
24 |
+
<?php foreach( $ts_notifications as $key => $val ){
|
25 |
+
$ast_enable_email = $ast->get_option_value_from_array( $val['option_name'],$val['enable_status_name'],''); ?>
|
26 |
+
<tr class="<?php if($ast_enable_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
27 |
+
<td class="forminp status-label-column">
|
28 |
+
<span class="shipment_status_toggle">
|
29 |
+
<input type="hidden" name="<?php echo $val['enable_status_name']; ?>" value="0"/>
|
30 |
+
<input class="ast-tgl ast-tgl-flat" id="<?php echo $val['enable_status_name']; ?>" name="<?php echo $val['enable_status_name']; ?>" data-settings="<?php echo $val['option_name']; ?>" type="checkbox" <?php if($ast_enable_email == 1) { echo 'checked'; } ?> value="yes"/>
|
31 |
+
<label class="ast-tgl-btn ast-tgl-btn-green" for="<?php echo $val['enable_status_name']; ?>"></label>
|
32 |
+
</span>
|
33 |
+
<button class="button button-primary shipment-status-label <?php echo $val['slug']; ?>"><?php echo $val['title']; ?></button>
|
34 |
+
</td>
|
35 |
+
<td class="forminp">
|
36 |
+
<a class="button-primary btn_ts_transparent edit_customizer_a" href="<?php echo $val['customizer_url']; ?>"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
37 |
+
</td>
|
38 |
+
</tr>
|
39 |
+
<?php } ?>
|
40 |
</tbody>
|
41 |
+
</table>
|
42 |
+
</div>
|
43 |
+
|
44 |
+
<?php do_action( 'after_shipment_status_email_notifications' ); ?>
|
45 |
+
|
46 |
+
<form method="post" id="trackship_late_shipments_form" action="" enctype="multipart/form-data">
|
47 |
+
<div class="custom_order_status_section">
|
48 |
+
<table class="form-table heading-table">
|
49 |
+
<tbody>
|
50 |
+
<tr valign="top">
|
51 |
+
<td>
|
52 |
+
<h3 style=""><?php _e( 'Admin Notifications', 'woo-advanced-shipment-tracking' ); ?></h3>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
</tbody>
|
56 |
+
</table>
|
57 |
+
<table class="form-table shipment-status-email-table">
|
58 |
+
<tbody>
|
59 |
+
<tr class="<?php if($wcast_enable_late_shipments_admin_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
|
60 |
+
<td class="forminp status-label-column">
|
61 |
+
<span class="shipment_status_toggle">
|
62 |
+
<input type="hidden" name="wcast_enable_late_shipments_admin_email" value="0"/>
|
63 |
+
<input class="ast-tgl ast-tgl-flat" id="wcast_enable_late_shipments_admin_email" name="wcast_enable_late_shipments_admin_email" data-settings="late_shipments_email_settings" type="checkbox" <?php if($wcast_enable_late_shipments_admin_email == 1) { echo 'checked'; } ?> value="1"/>
|
64 |
+
<label class="ast-tgl-btn ast-tgl-btn-green" for="wcast_enable_late_shipments_admin_email"></label>
|
65 |
+
</span>
|
66 |
+
<button type="button" class="button button-primary shipment-status-label late-shipments"><?php _e('Late Shipments', 'woo-advanced-shipment-tracking'); ?></button>
|
67 |
+
</td>
|
68 |
+
<td class="forminp">
|
69 |
+
<a class="edit_customizer_a late_shipments_a button-primary btn_ts_transparent" href="javascript:void(0);"><?php _e('Customize', 'woo-advanced-shipment-tracking'); ?></a>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
</tbody>
|
73 |
+
</table>
|
74 |
+
</div>
|
75 |
<?php
|
76 |
$late_shipments_email_settings = get_option('late_shipments_email_settings');
|
77 |
$wcast_late_shipments_days = isset( $late_shipments_email_settings['wcast_late_shipments_days'] ) ? $late_shipments_email_settings['wcast_late_shipments_days'] : '';
|
80 |
$wcast_late_shipments_email_content = isset( $late_shipments_email_settings['wcast_late_shipments_email_content'] ) ? $late_shipments_email_settings['wcast_late_shipments_email_content'] : '';
|
81 |
$wcast_late_shipments_trigger_alert = isset( $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] ) ? $late_shipments_email_settings['wcast_late_shipments_trigger_alert'] : '';
|
82 |
$wcast_late_shipments_daily_digest_time = isset( $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] ) ? $late_shipments_email_settings['wcast_late_shipments_daily_digest_time'] : ''; ?>
|
83 |
+
<div class="custom_order_status_section">
|
84 |
+
<table class="form-table late-shipments-email-content-table hide_table">
|
85 |
+
<tr class="">
|
86 |
+
<th scope="row" class="titledesc">
|
87 |
+
<label for=""><?php _e('Late Shipment Days', 'woo-advanced-shipment-tracking'); ?></label>
|
88 |
+
</th>
|
89 |
+
<td class="forminp">
|
90 |
+
<fieldset>
|
91 |
+
<input class="input-text" type="number" name="wcast_late_shipments_days" id="wcast_late_shipments_days" min="1" value="<?php echo $wcast_late_shipments_days; ?>">
|
92 |
+
</fieldset>
|
93 |
+
</td>
|
94 |
+
</tr>
|
95 |
+
<tr class="">
|
96 |
+
<th scope="row" class="titledesc">
|
97 |
+
<label for=""><?php _e('Recipient(s)', 'woocommerce'); ?></label>
|
98 |
+
</th>
|
99 |
+
<td class="forminp">
|
100 |
+
<fieldset>
|
101 |
+
<input class="input-text regular-input " type="text" name="wcast_late_shipments_email_to" id="wcast_late_shipments_email_to" placeholder="<?php _e('E.g. {admin_email}, admin@example.org', 'woo-advanced-shipment-tracking'); ?>" value="<?php echo $wcast_late_shipments_email_to; ?>">
|
102 |
+
</fieldset>
|
103 |
+
</td>
|
104 |
+
</tr>
|
105 |
+
<tr class="">
|
106 |
+
<th scope="row" class="titledesc">
|
107 |
+
<label for=""><?php _e('Subject', 'woocommerce'); ?></label>
|
108 |
+
</th>
|
109 |
+
<td class="forminp">
|
110 |
+
<fieldset>
|
111 |
+
<input class="input-text regular-input " type="text" name="wcast_late_shipments_email_subject" id="wcast_late_shipments_email_subject" placeholder="<?php _e('Late shipment for order #{order_number}', 'woo-advanced-shipment-tracking'); ?>" value="<?php echo $wcast_late_shipments_email_subject; ?>">
|
112 |
+
</fieldset>
|
113 |
+
</td>
|
114 |
+
</tr>
|
115 |
+
<tr class="">
|
116 |
+
<th scope="row" class="titledesc">
|
117 |
+
<label for=""><?php _e('Email content', 'woo-advanced-shipment-tracking'); ?></label>
|
118 |
+
</th>
|
119 |
+
<td class="forminp">
|
120 |
+
<fieldset>
|
121 |
+
<textarea name="wcast_late_shipments_email_content" id="wcast_late_shipments_email_content" placeholder="<?php _e('This order was shipped {shipment_length} days ago, the shipment status is {shipment_status} and its est. delivery date is {est_delivery_date}.', 'woo-advanced-shipment-tracking'); ?>"><?php echo $wcast_late_shipments_email_content; ?></textarea>
|
122 |
+
</fieldset>
|
123 |
+
<span><?php _e('Available variables:', 'woo-advanced-shipment-tracking'); ?> {site_title} {admin_email} {customer_first_name} {customer_last_name} {customer_company_name} {customer_username} {order_number} {shipment_length} {shipment_status} {est_delivery_date}</span>
|
124 |
+
</td>
|
125 |
+
</tr>
|
126 |
+
<?php
|
127 |
+
$send_time_array = array();
|
128 |
+
for ( $hour = 0; $hour < 24; $hour++ ) {
|
129 |
+
for ( $min = 0; $min < 60; $min = $min + 30 ) {
|
130 |
+
$this_time = date( 'H:i', strtotime( "$hour:$min" ) );
|
131 |
+
$send_time_array[ $this_time ] = $this_time;
|
132 |
+
}
|
133 |
+
} ?>
|
134 |
+
<tr class="">
|
135 |
+
<th scope="row" class="titledesc">
|
136 |
+
<label for=""><?php _e('Trigger Alert', 'woo-advanced-shipment-tracking'); ?></label>
|
137 |
+
</th>
|
138 |
+
<td class="forminp">
|
139 |
+
<label class="" for="trigger_alert_as_it_happens">
|
140 |
+
<input type="radio" id="trigger_alert_as_it_happens" name="wcast_late_shipments_trigger_alert" value="as_it_happens" <?php if($wcast_late_shipments_trigger_alert == 'as_it_happens')echo 'checked'; ?>>
|
141 |
+
<span class=""><?php _e('As it Happens', 'woo-advanced-shipment-tracking'); ?></span>
|
142 |
+
</label>
|
143 |
+
<label class="" for="trigger_alert_daily_digest_on">
|
144 |
+
<input type="radio" id="trigger_alert_daily_digest_on" name="wcast_late_shipments_trigger_alert" value="daily_digest_on" <?php if($wcast_late_shipments_trigger_alert == 'daily_digest_on')echo 'checked'; ?>>
|
145 |
+
<span class=""><?php _e('Daily Digest on', 'woo-advanced-shipment-tracking'); ?></span>
|
146 |
+
</label>
|
147 |
+
<select class="select daily_digest_time" name="wcast_late_shipments_daily_digest_time">
|
148 |
+
<?php foreach((array)$send_time_array as $key1 => $val1 ){ ?>
|
149 |
+
<option <?php if($wcast_late_shipments_daily_digest_time == $key1)echo 'selected'; ?> value="<?php echo $key1?>" ><?php echo $val1; ?></option>
|
150 |
+
<?php } ?>
|
151 |
+
</select>
|
152 |
+
</td>
|
153 |
+
</tr>
|
154 |
+
<tr>
|
155 |
+
<td colspan="2">
|
156 |
+
<button name="save" class="button-primary woocommerce-save-button btn_green2 btn_large" type="submit" value="Save changes"><?php _e( 'Save Changes', 'woo-advanced-shipment-tracking' ); ?></button>
|
157 |
+
<div class="spinner"></div>
|
158 |
+
<?php wp_nonce_field( 'ts_late_shipments_email_form', 'ts_late_shipments_email_form_nonce' );?>
|
159 |
+
<input type="hidden" name="action" value="ts_late_shipments_email_form_update">
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
</table>
|
163 |
+
</div>
|
164 |
</form>
|
165 |
</section>
|
166 |
<section class="inner_tab_section shipment-status-sms-section">
|
includes/views/admin_tracking_page_settings.php
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
<section id="content_tracking_page" class="inner_tab_section">
|
2 |
-
<div class="tab_inner_container">
|
3 |
-
<form method="post" id="trackship_tracking_page_form" action="" enctype="multipart/form-data">
|
4 |
-
<div class="outer_form_table border_0">
|
5 |
-
<table class="form-table tracking_page_heading">
|
6 |
-
<tbody>
|
7 |
-
<tr valign="top">
|
8 |
-
<td>
|
9 |
-
<h3 style=""><?php _e( 'Tracking Page', 'woo-advanced-shipment-tracking' ); ?></h3>
|
10 |
-
<label class="setting_ul_checkbox_label"><?php _e( 'Enable a tracking page on your store', 'woo-advanced-shipment-tracking' ); ?></label>
|
11 |
-
</td>
|
12 |
-
<td>
|
13 |
-
<span class="tracking_page_toggle checkbox_span">
|
14 |
-
<input type="hidden" name="wc_ast_use_tracking_page" value="0"/>
|
15 |
-
<input class="ast-tgl ast-tgl-flat" id="wc_ast_use_tracking_page" name="wc_ast_use_tracking_page" type="checkbox" <?php if(get_option('wc_ast_use_tracking_page') == 1){ echo 'checked'; } ?> value="1"/>
|
16 |
-
<label class="ast-tgl-btn" for="wc_ast_use_tracking_page"></label>
|
17 |
-
</span>
|
18 |
-
</td>
|
19 |
-
</tr>
|
20 |
-
</tbody>
|
21 |
-
</table>
|
22 |
-
|
23 |
-
<table class="form-table tracking_page_design_table">
|
24 |
-
<tbody>
|
25 |
-
<tr>
|
26 |
-
<th>
|
27 |
-
<label><?php _e( 'Select Tracking Page', 'woo-advanced-shipment-tracking' ); ?></label>
|
28 |
-
</th>
|
29 |
-
<td>
|
30 |
-
<?php $page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' ); ?>
|
31 |
-
<select class="select select2" id="wc_ast_trackship_page_id" name="wc_ast_trackship_page_id">
|
32 |
-
<?php
|
33 |
-
foreach($page_list as $page_id => $page_name){ ?>
|
34 |
-
<option <?php if(get_option('wc_ast_trackship_page_id') == $page_id){ echo 'selected'; }?> value="<?php echo $page_id; ?>"><?php echo $page_name; ?></option>
|
35 |
-
<?php } ?>
|
36 |
-
<option <?php if(get_option('wc_ast_trackship_page_id') == 'other'){ echo 'selected'; }?> value="other"><?php _e( 'Other', 'woo-advanced-shipment-tracking' ); ?></option>
|
37 |
-
</select>
|
38 |
-
<fieldset style="<?php if(get_option('wc_ast_trackship_page_id') != 'other'){ echo 'display:none;'; }?>" class="trackship_other_page_fieldset">
|
39 |
-
<input type="text" name="wc_ast_trackship_other_page" style="width: 100%;" value="<?php echo get_option('wc_ast_trackship_other_page'); ?>">
|
40 |
-
</fieldset>
|
41 |
-
<p class="tracking_page_desc"><?php _e( 'Note - If you select a different page than the Shipment Tracking page, add the [wcast-track-order] shortcode to the selected page content.', 'woo-advanced-shipment-tracking' ); ?> <a href="https://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/integration/" target="blank"><?php _e( 'more info', 'woo-advanced-shipment-tracking' ); ?></a></p>
|
42 |
-
</td>
|
43 |
-
</tr>
|
44 |
-
<tr>
|
45 |
-
<th>
|
46 |
-
<label><?php _e( 'Tracking Widget Layout', 'woo-advanced-shipment-tracking' ); ?></label>
|
47 |
-
</th>
|
48 |
-
<td>
|
49 |
-
<span class="select_t_layout_section">
|
50 |
-
<input type="radio" name="wc_ast_select_tracking_page_layout" id="t_layout_1" value="t_layout_1" class="radio-img" <?php if(get_option('wc_ast_select_tracking_page_layout','t_layout_1') == 't_layout_1'){ echo 'checked'; } ?>/>
|
51 |
-
<label for="t_layout_1">
|
52 |
-
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/t_layout_1.jpg?version=<?php echo wc_advanced_shipment_tracking()->version?>"/>
|
53 |
-
</label>
|
54 |
-
</span>
|
55 |
-
<span class="select_t_layout_section">
|
56 |
-
<input type="radio" name="wc_ast_select_tracking_page_layout" id="t_layout_2" value="t_layout_2" <?php if(get_option('wc_ast_select_tracking_page_layout','t_layout_1') == 't_layout_2'){ echo 'checked'; } ?> class="radio-img" />
|
57 |
-
<label for="t_layout_2">
|
58 |
-
<img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/t_layout_2.jpg?version=<?php echo wc_advanced_shipment_tracking()->version?>"/>
|
59 |
-
</label>
|
60 |
-
</span>
|
61 |
-
</td>
|
62 |
-
</tr>
|
63 |
-
<tr>
|
64 |
-
<th>
|
65 |
-
<label><?php _e( 'Tracking Widget Options', 'woo-advanced-shipment-tracking' ); ?></label>
|
66 |
-
</th>
|
67 |
-
<td class="tracking_page_display_options_td">
|
68 |
-
<label>
|
69 |
-
<input type="hidden" name="wc_ast_link_to_shipping_provider" value="0"/>
|
70 |
-
<input type="checkbox" name="wc_ast_link_to_shipping_provider" value="1" id="wc_ast_link_to_shipping_provider" <?php if(get_option('wc_ast_link_to_shipping_provider') == 1){ echo 'checked'; } ?>>
|
71 |
-
<?php _e( 'Add a link to the Shipping provider page', 'woo-advanced-shipment-tracking' ); ?>
|
72 |
-
</label>
|
73 |
-
<label>
|
74 |
-
<input type="hidden" name="wc_ast_hide_tracking_provider_image" value="0"/>
|
75 |
-
<input type="checkbox" name="wc_ast_hide_tracking_provider_image" value="1" id="wc_ast_hide_tracking_provider_image" <?php if(get_option('wc_ast_hide_tracking_provider_image') == 1){ echo 'checked'; } ?>>
|
76 |
-
<?php _e( 'Hide Shipping Provider Image', 'woo-advanced-shipment-tracking' ); ?>
|
77 |
-
</label>
|
78 |
-
<label>
|
79 |
-
<input type="hidden" name="wc_ast_hide_tracking_events" value="0"/>
|
80 |
-
<input type="checkbox" name="wc_ast_hide_tracking_events" value="1" id="wc_ast_hide_tracking_events" <?php if(get_option('wc_ast_hide_tracking_events') == 1){ echo 'checked'; } ?>>
|
81 |
-
<?php _e( 'Hide tracking event details', 'woo-advanced-shipment-tracking' ); ?>
|
82 |
-
</label>
|
83 |
-
<label>
|
84 |
-
<input type="hidden" name="wc_ast_remove_trackship_branding" value="0"/>
|
85 |
-
<input type="checkbox" name="wc_ast_remove_trackship_branding" value="1" id="wc_ast_remove_trackship_branding" <?php if(get_option('wc_ast_remove_trackship_branding') == 1){ echo 'checked'; } ?>>
|
86 |
-
<?php _e( 'Remove TrackShip branding', 'woo-advanced-shipment-tracking' ); ?>
|
87 |
-
</label>
|
88 |
-
</td>
|
89 |
-
</tr>
|
90 |
-
<tr>
|
91 |
-
<th>
|
92 |
-
<label><?php _e( 'Tracking Widget Border Color', 'woo-advanced-shipment-tracking' ); ?></label>
|
93 |
-
</th>
|
94 |
-
<td>
|
95 |
-
<input class="input-text regular-input" type="text" name="wc_ast_select_border_color" id="wc_ast_select_border_color" style="" value="<?php echo get_option('wc_ast_select_border_color')?>" >
|
96 |
-
</td>
|
97 |
-
</tr>
|
98 |
-
</tbody>
|
99 |
-
</table>
|
100 |
-
<table class="form-table tracking_page_save_table">
|
101 |
-
<tbody>
|
102 |
-
<tr valign="top">
|
103 |
-
<td class="" colspan="2">
|
104 |
-
<button name="save" class="button-primary woocommerce-save-button btn_green2 btn_large" type="submit" value="Save changes"><?php _e( 'Save Changes', 'woo-advanced-shipment-tracking' ); ?></button>
|
105 |
-
<button name="save" class="button-primary btn_ts_outline btn_large tracking_page_preview" type="button"><?php _e( 'Preview', 'woo-advanced-shipment-tracking' ); ?></button>
|
106 |
-
<div class="spinner"></div>
|
107 |
-
<?php wp_nonce_field( 'trackship_tracking_page_form', 'trackship_tracking_page_form_nonce' );?>
|
108 |
-
<input type="hidden" name="action" value="trackship_tracking_page_form_update">
|
109 |
-
</td>
|
110 |
-
</tr>
|
111 |
-
</tbody>
|
112 |
-
</table>
|
113 |
-
</div>
|
114 |
-
<div id="" class="popupwrapper tracking_page_preview_popup" style="display:none;">
|
115 |
-
<div class="popup_header">
|
116 |
-
<h3><?php _e( 'Tracking Widget Preview', 'woo-advanced-shipment-tracking' ); ?></h3>
|
117 |
-
<span class="dashicons dashicons-no-alt popup_close_icon"></span>
|
118 |
-
</div>
|
119 |
-
<div class="popuprow">
|
120 |
-
<div class="popup_body">
|
121 |
-
<iframe id="tracking_preview_iframe" class="tracking_preview_iframe" src="<?php echo get_home_url(); ?>?action=preview_tracking_page" class="tracking-preview-link"></iframe>
|
122 |
-
</div>
|
123 |
-
</div>
|
124 |
-
<div class="popupclose"></div>
|
125 |
-
</div>
|
126 |
-
</form>
|
127 |
-
</div>
|
128 |
-
<?php //include 'trackship_sidebar.php'; ?>
|
129 |
-
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/views/admin_trackship_dashboard.php
CHANGED
@@ -1,45 +1,149 @@
|
|
1 |
<section id="content_trackship_dashboard" class="tab_section">
|
2 |
-
<div class="tab_inner_container">
|
3 |
-
<?php
|
4 |
-
$wc_ast_api_key = get_option('wc_ast_api_key');
|
5 |
-
if($wc_ast_api_key){
|
6 |
-
$trackship = WC_Advanced_Shipment_Tracking_Trackship::get_instance();
|
7 |
-
$admin = WC_Advanced_Shipment_Tracking_Admin::get_instance();
|
8 |
-
$completed_order_with_tracking = $trackship->completed_order_with_tracking();
|
9 |
-
$completed_order_with_zero_balance = $trackship->completed_order_with_zero_balance();
|
10 |
-
$completed_order_with_do_connection = $trackship->completed_order_with_do_connection();
|
11 |
-
|
12 |
-
|
13 |
-
$url = 'https://my.trackship.info/wp-json/tracking/get_user_plan';
|
14 |
-
$args['body'] = array(
|
15 |
-
'user_key' => $wc_ast_api_key,
|
16 |
-
);
|
17 |
-
$response = wp_remote_post( $url, $args );
|
18 |
-
if ( !is_wp_error( $response ) )$plan_data = json_decode($response['body']);
|
19 |
-
|
20 |
if($completed_order_with_tracking > 0 || $completed_order_with_zero_balance > 0 || $completed_order_with_do_connection > 0){
|
21 |
$total_orders = $completed_order_with_tracking + $completed_order_with_zero_balance + $completed_order_with_do_connection; ?>
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
</div>
|
25 |
-
<?php }
|
26 |
-
$subtab = isset( $_GET['subtab'] ) ? sanitize_text_field($_GET['subtab']) : 'ts-settings'; ?>
|
27 |
|
28 |
-
<
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
<
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
<
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
</section>
|
1 |
<section id="content_trackship_dashboard" class="tab_section">
|
2 |
+
<div class="tab_inner_container">
|
3 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
if($completed_order_with_tracking > 0 || $completed_order_with_zero_balance > 0 || $completed_order_with_do_connection > 0){
|
5 |
$total_orders = $completed_order_with_tracking + $completed_order_with_zero_balance + $completed_order_with_do_connection; ?>
|
6 |
+
<div class="trackship-notice">
|
7 |
+
<p><?php echo sprintf(__('We detected %s Shipped orders from the last 30 days that were not sent to TrackShip, you can bulk send them to TrackShip', 'woo-advanced-shipment-tracking'),$total_orders ); ?></p>
|
8 |
+
<button class="button-primary btn_green2 bulk_shipment_status_button"><?php _e( 'Get Shipment Status', 'woo-advanced-shipment-tracking' ); ?></button>
|
9 |
+
</div>
|
10 |
+
<div class="trackship-notice bulk_shipment_status_success" style="display:none;">
|
11 |
+
<p><?php echo __('Tracking info sent to Trackship for all Orders.', 'woo-advanced-shipment-tracking'); ?></p>
|
12 |
+
</div>
|
13 |
+
<?php } ?>
|
14 |
+
<div class="trackship_status_section first">
|
15 |
+
<div class="outer_form_table">
|
16 |
+
<table class="form-table heading-table">
|
17 |
+
<tbody>
|
18 |
+
<tr valign="top">
|
19 |
+
<td><h3 style=""><?php _e( 'TrackShip Connection Status', 'woo-advanced-shipment-tracking' ); ?></h3></td>
|
20 |
+
</tr>
|
21 |
+
</tbody>
|
22 |
+
</table>
|
23 |
+
<table class="form-table trackship_status_table">
|
24 |
+
<tbody>
|
25 |
+
<tr valign="top">
|
26 |
+
<td scope="row" class="titledesc"><label><strong><?php _e( 'Connection Status', 'woo-advanced-shipment-tracking' ); ?></strong></label></td>
|
27 |
+
<td class="forminp">
|
28 |
+
<a href="https://trackship.info/my-account/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" target="_blank" class="button-primary btn_green2 btn_icon api_connected"><span class="dashicons dashicons-yes"></span><?php _e( 'Connected', 'woo-advanced-shipment-tracking' ); ?></a>
|
29 |
+
</td>
|
30 |
+
</tr>
|
31 |
+
</tbody>
|
32 |
+
</table>
|
33 |
+
</div>
|
34 |
</div>
|
|
|
|
|
35 |
|
36 |
+
<div class="trackship_status_section last">
|
37 |
+
<div class="outer_form_table">
|
38 |
+
<table class="form-table heading-table">
|
39 |
+
<tbody>
|
40 |
+
<tr valign="top">
|
41 |
+
<td><h3 style=""><?php _e( 'TrackShip Account', 'woo-advanced-shipment-tracking' ); ?></h3></td>
|
42 |
+
</tr>
|
43 |
+
</tbody>
|
44 |
+
</table>
|
45 |
+
<table class="form-table trackship_status_table">
|
46 |
+
<tbody>
|
47 |
+
<tr valign="top">
|
48 |
+
<td scope="row" class="titledesc">
|
49 |
+
<label><?php _e( 'Subscription: ', 'woo-advanced-shipment-tracking' ); ?></label><strong><?php if(isset($plan_data->subscription_plan)){ echo $plan_data->subscription_plan; } ?></strong></br>
|
50 |
+
<label><?php _e( 'Trackers Balance: ', 'woo-advanced-shipment-tracking' ); ?></label><strong><?php echo get_option('trackers_balance'); ?></strong>
|
51 |
+
</td>
|
52 |
+
<td class="forminp">
|
53 |
+
<a href="https://trackship.info/my-account/?utm_source=wpadmin&utm_medium=ts_settings&utm_campaign=dashboard" class="button-primary btn_ts_transparent" target="blank"><?php _e( 'TrackShip Dashboard', 'woo-advanced-shipment-tracking' ); ?></a>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
</tbody>
|
57 |
+
</table>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
|
61 |
+
<div class="clearfix"></div>
|
62 |
+
</div>
|
63 |
+
<div class="tab_inner_container">
|
64 |
+
<form method="post" id="wc_ast_trackship_form" action="" enctype="multipart/form-data">
|
65 |
+
<div class="outer_form_table">
|
66 |
+
<table class="form-table heading-table">
|
67 |
+
<tbody>
|
68 |
+
<tr valign="top">
|
69 |
+
<td>
|
70 |
+
<h3 style=""><?php _e( 'General Settings', 'woo-advanced-shipment-tracking' ); ?></h3>
|
71 |
+
<?php wp_nonce_field( 'wc_ast_trackship_form', 'wc_ast_trackship_form_nonce' );?>
|
72 |
+
<input type="hidden" name="action" value="wc_ast_trackship_form_update">
|
73 |
+
</td>
|
74 |
+
</tr>
|
75 |
+
</tbody>
|
76 |
+
</table>
|
77 |
+
<?php $ast_admin->get_html_ul( $this->get_trackship_general_data() ); ?>
|
78 |
+
</div>
|
79 |
+
</form>
|
80 |
|
81 |
+
<form method="post" id="wc_ast_trackship_automation_form" action="" enctype="multipart/form-data">
|
82 |
+
<div class="outer_form_table">
|
83 |
+
<table class="form-table heading-table">
|
84 |
+
<tbody>
|
85 |
+
<tr valign="top">
|
86 |
+
<td>
|
87 |
+
<h3 style=""><?php _e( 'Automation', 'woo-advanced-shipment-tracking' ); ?></h3>
|
88 |
+
<?php wp_nonce_field( 'wc_ast_trackship_automation_form', 'wc_ast_trackship_automation_form_nonce' );?>
|
89 |
+
<input type="hidden" name="action" value="wc_ast_trackship_automation_form_update">
|
90 |
+
</td>
|
91 |
+
</tr>
|
92 |
+
</tbody>
|
93 |
+
</table>
|
94 |
+
<div class="custom_order_status_section">
|
95 |
+
<table class="form-table order-status-table">
|
96 |
+
<tbody>
|
97 |
+
<tr valign="top" class="delivered_row <?php if(!get_option('wc_ast_status_delivered')){echo 'disable_row'; } ?>">
|
98 |
+
<td class="forminp">
|
99 |
+
<input type="hidden" name="wc_ast_status_delivered" value="0"/>
|
100 |
+
<input class="ast-tgl ast-tgl-flat ts_order_status_toggle" id="wc_ast_status_delivered" name="wc_ast_status_delivered" type="checkbox" <?php if(get_option('wc_ast_status_delivered')){echo 'checked'; } ?> value="1"/>
|
101 |
+
<label class="ast-tgl-btn ast-tgl-btn-green" for="wc_ast_status_delivered"></label>
|
102 |
+
</td>
|
103 |
+
<td class="forminp status-label-column">
|
104 |
+
<span class="order-label wc-delivered">
|
105 |
+
<?php
|
106 |
+
if(get_option('wc_ast_status_delivered')){
|
107 |
+
_e( wc_get_order_status_name( 'delivered' ), 'woo-advanced-shipment-tracking' );
|
108 |
+
} else{
|
109 |
+
_e( 'Delivered', 'woo-advanced-shipment-tracking' );
|
110 |
+
} ?>
|
111 |
+
</span>
|
112 |
+
</td>
|
113 |
+
<td class="forminp">
|
114 |
+
<fieldset>
|
115 |
+
<input class="input-text regular-input color_input" type="text" name="wc_ast_status_label_color" id="wc_ast_status_label_color" style="" value="<?php echo get_option('wc_ast_status_label_color','#59c889')?>" placeholder="">
|
116 |
+
<select class="select ts_custom_order_color_select" id="wc_ast_status_label_font_color" name="wc_ast_status_label_font_color">
|
117 |
+
<option value="#fff" <?php if(get_option('wc_ast_status_label_font_color','#fff') == '#fff'){ echo 'selected'; }?>><?php _e( 'Light Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
118 |
+
<option value="#000" <?php if(get_option('wc_ast_status_label_font_color','#fff') == '#000'){ echo 'selected'; }?>><?php _e( 'Dark Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
119 |
+
</select>
|
120 |
+
</fieldset>
|
121 |
+
</td>
|
122 |
+
</tr>
|
123 |
+
</tbody>
|
124 |
+
</table>
|
125 |
+
</div>
|
126 |
+
</div>
|
127 |
+
</form>
|
128 |
+
</div>
|
129 |
+
|
130 |
+
<div class="tab_inner_container">
|
131 |
+
<form method="post" id="trackship_tracking_page_form" action="" enctype="multipart/form-data">
|
132 |
+
<div class="outer_form_table">
|
133 |
+
<table class="form-table heading-table">
|
134 |
+
<tbody>
|
135 |
+
<tr valign="top">
|
136 |
+
<td>
|
137 |
+
<h3 style=""><?php _e( 'Tracking Page', 'woo-advanced-shipment-tracking' ); ?></h3>
|
138 |
+
<?php wp_nonce_field( 'trackship_tracking_page_form', 'trackship_tracking_page_form_nonce' );?>
|
139 |
+
<input type="hidden" name="action" value="trackship_tracking_page_form_update">
|
140 |
+
</td>
|
141 |
+
</tr>
|
142 |
+
</tbody>
|
143 |
+
</table>
|
144 |
+
<?php $ast_admin->get_html_ul( $this->get_tracking_page_data() ); ?>
|
145 |
+
</div>
|
146 |
+
</form>
|
147 |
+
</div>
|
148 |
+
|
149 |
</section>
|
includes/views/front/preview_tracking_page.php
CHANGED
@@ -56,7 +56,7 @@
|
|
56 |
|
57 |
<h1 class="shipment_status_heading out_for_delivery">Out For Delivery</h1>
|
58 |
|
59 |
-
<span class="
|
60 |
</div>
|
61 |
|
62 |
|
@@ -128,7 +128,7 @@
|
|
128 |
<?php } ?>
|
129 |
|
130 |
</div>
|
131 |
-
<div class="trackship_branding" style="
|
132 |
<p>Shipment Tracking info by <a href="https://trackship.info" title="TrackShip" target="blank"><img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-logo.png"></a></p>
|
133 |
</div>
|
134 |
</div>
|
56 |
|
57 |
<h1 class="shipment_status_heading out_for_delivery">Out For Delivery</h1>
|
58 |
|
59 |
+
<span class="est_delivery_date">Est. Delivery Date: <strong>Thursday, Oct 01</strong></span>
|
60 |
</div>
|
61 |
|
62 |
|
128 |
<?php } ?>
|
129 |
|
130 |
</div>
|
131 |
+
<div class="trackship_branding" style="">
|
132 |
<p>Shipment Tracking info by <a href="https://trackship.info" title="TrackShip" target="blank"><img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-logo.png"></a></p>
|
133 |
</div>
|
134 |
</div>
|
includes/views/front/tracking_page_header.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<div class="tracking-header">
|
2 |
-
<?php echo do_action("trackship_tracking_header_before",$order_id, $tracker, $
|
3 |
<div class="provider_image_div" style="<?php if($hide_tracking_provider_image == 1) { echo 'display:none'; }; ?>">
|
4 |
-
<img class="provider_image" src="<?php echo $
|
5 |
</div>
|
6 |
<div class="tracking_number_div">
|
7 |
<ul>
|
8 |
<li>
|
9 |
-
<?php echo apply_filters( 'ast_provider_title', esc_html( $
|
10 |
-
<?php if($wc_ast_link_to_shipping_provider == 1
|
11 |
-
<a href="<?php echo $
|
12 |
<?php } else{ ?>
|
13 |
-
<strong><?php echo $tracking_number; ?></strong>
|
14 |
<?php } ?>
|
15 |
</li>
|
16 |
</ul>
|
@@ -18,11 +18,11 @@
|
|
18 |
<h1 class="shipment_status_heading <?php echo $tracker->ep_status; ?>">
|
19 |
<?php echo apply_filters("trackship_status_filter",$tracker->ep_status);?>
|
20 |
</h1>
|
21 |
-
<span class="
|
22 |
<?php _e( 'Est. Delivery Date', 'woo-advanced-shipment-tracking' ); ?>: <strong>
|
23 |
<?php
|
24 |
if($tracker->est_delivery_date){
|
25 |
-
echo
|
26 |
} else{
|
27 |
echo 'N/A';
|
28 |
} ?></strong>
|
1 |
<div class="tracking-header">
|
2 |
+
<?php echo do_action("trackship_tracking_header_before",$order_id, $tracker, $item['formatted_tracking_provider'], $item['tracking_number']);?>
|
3 |
<div class="provider_image_div" style="<?php if($hide_tracking_provider_image == 1) { echo 'display:none'; }; ?>">
|
4 |
+
<img class="provider_image" src="<?php echo $item['tracking_provider_image']; ?>">
|
5 |
</div>
|
6 |
<div class="tracking_number_div">
|
7 |
<ul>
|
8 |
<li>
|
9 |
+
<?php echo apply_filters( 'ast_provider_title', esc_html( $item['formatted_tracking_provider'] )); ?>:</span>
|
10 |
+
<?php if ( $wc_ast_link_to_shipping_provider == 1 ) { ?>
|
11 |
+
<a href="<?php echo $item['formatted_tracking_link']; ?>" target="blank"><strong><?php echo $item['tracking_number']; ?></strong></a>
|
12 |
<?php } else{ ?>
|
13 |
+
<strong><?php echo $item['tracking_number']; ?></strong>
|
14 |
<?php } ?>
|
15 |
</li>
|
16 |
</ul>
|
18 |
<h1 class="shipment_status_heading <?php echo $tracker->ep_status; ?>">
|
19 |
<?php echo apply_filters("trackship_status_filter",$tracker->ep_status);?>
|
20 |
</h1>
|
21 |
+
<span class="est_delivery_date">
|
22 |
<?php _e( 'Est. Delivery Date', 'woo-advanced-shipment-tracking' ); ?>: <strong>
|
23 |
<?php
|
24 |
if($tracker->est_delivery_date){
|
25 |
+
echo date('l, M d', strtotime($tracker->est_delivery_date));
|
26 |
} else{
|
27 |
echo 'N/A';
|
28 |
} ?></strong>
|
includes/views/trackship_settings.php
DELETED
@@ -1,126 +0,0 @@
|
|
1 |
-
<section id="content_trackship_settings" class="inner_tab_section">
|
2 |
-
<div class="tab_inner_container">
|
3 |
-
|
4 |
-
<div class="trackship_status_section first">
|
5 |
-
<div class="outer_form_table">
|
6 |
-
<table class="form-table heading-table">
|
7 |
-
<tbody>
|
8 |
-
<tr valign="top">
|
9 |
-
<td><h3 style=""><?php _e( 'TrackShip Connection Status', 'woo-advanced-shipment-tracking' ); ?></h3></td>
|
10 |
-
</tr>
|
11 |
-
</tbody>
|
12 |
-
</table>
|
13 |
-
<table class="form-table trackship_status_table">
|
14 |
-
<tbody>
|
15 |
-
<tr valign="top">
|
16 |
-
<td scope="row" class="titledesc"><label><strong><?php _e( 'Connection Status', 'woo-advanced-shipment-tracking' ); ?></strong></label></td>
|
17 |
-
<td class="forminp">
|
18 |
-
<a href="https://trackship.info/my-account/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" target="_blank" class="button-primary btn_green2 btn_icon api_connected"><span class="dashicons dashicons-yes"></span><?php _e( 'Connected', 'woo-advanced-shipment-tracking' ); ?></a>
|
19 |
-
</td>
|
20 |
-
</tr>
|
21 |
-
</tbody>
|
22 |
-
</table>
|
23 |
-
</div>
|
24 |
-
</div>
|
25 |
-
|
26 |
-
<div class="trackship_status_section last">
|
27 |
-
<div class="outer_form_table">
|
28 |
-
<table class="form-table heading-table">
|
29 |
-
<tbody>
|
30 |
-
<tr valign="top">
|
31 |
-
<td><h3 style=""><?php _e( 'TrackShip Account', 'woo-advanced-shipment-tracking' ); ?></h3></td>
|
32 |
-
</tr>
|
33 |
-
</tbody>
|
34 |
-
</table>
|
35 |
-
<table class="form-table trackship_status_table">
|
36 |
-
<tbody>
|
37 |
-
<tr valign="top">
|
38 |
-
<td scope="row" class="titledesc">
|
39 |
-
<label><?php _e( 'Subscription: ', 'woo-advanced-shipment-tracking' ); ?></label><strong><?php if(isset($plan_data->subscription_plan)){ echo $plan_data->subscription_plan; } ?></strong></br>
|
40 |
-
<label><?php _e( 'Trackers Balance: ', 'woo-advanced-shipment-tracking' ); ?></label><strong><?php echo get_option('trackers_balance'); ?></strong>
|
41 |
-
</td>
|
42 |
-
<td class="forminp">
|
43 |
-
<a href="https://trackship.info/my-account/?utm_source=wpadmin&utm_medium=ts_settings&utm_campaign=dashboard" class="button-primary btn_ts_transparent" target="blank"><?php _e( 'TrackShip Dashboard', 'woo-advanced-shipment-tracking' ); ?></a>
|
44 |
-
</td>
|
45 |
-
</tr>
|
46 |
-
</tbody>
|
47 |
-
</table>
|
48 |
-
</div>
|
49 |
-
</div>
|
50 |
-
|
51 |
-
<div class="clearfix"></div>
|
52 |
-
|
53 |
-
<form method="post" id="wc_ast_trackship_form" action="" enctype="multipart/form-data">
|
54 |
-
<div class="outer_form_table">
|
55 |
-
<table class="form-table heading-table">
|
56 |
-
<tbody>
|
57 |
-
<tr valign="top">
|
58 |
-
<td>
|
59 |
-
<h3 style=""><?php _e( 'General Settings', 'woo-advanced-shipment-tracking' ); ?></h3>
|
60 |
-
<?php wp_nonce_field( 'wc_ast_trackship_form', 'wc_ast_trackship_form_nonce' );?>
|
61 |
-
<input type="hidden" name="action" value="wc_ast_trackship_form_update">
|
62 |
-
</td>
|
63 |
-
</tr>
|
64 |
-
</tbody>
|
65 |
-
</table>
|
66 |
-
<?php $admin->get_html_ul( $trackship->get_trackship_general_data() ); ?>
|
67 |
-
</div>
|
68 |
-
</form>
|
69 |
-
|
70 |
-
<form method="post" id="wc_ast_trackship_automation_form" action="" enctype="multipart/form-data">
|
71 |
-
<div class="outer_form_table">
|
72 |
-
<table class="form-table heading-table">
|
73 |
-
<tbody>
|
74 |
-
<tr valign="top">
|
75 |
-
<td>
|
76 |
-
<h3 style=""><?php _e( 'Automation', 'woo-advanced-shipment-tracking' ); ?></h3>
|
77 |
-
<?php wp_nonce_field( 'wc_ast_trackship_automation_form', 'wc_ast_trackship_automation_form_nonce' );?>
|
78 |
-
<input type="hidden" name="action" value="wc_ast_trackship_automation_form_update">
|
79 |
-
</td>
|
80 |
-
</tr>
|
81 |
-
</tbody>
|
82 |
-
</table>
|
83 |
-
<table class="form-table order-status-table">
|
84 |
-
<tbody>
|
85 |
-
<tr valign="top" class="delivered_row <?php if(!get_option('wc_ast_status_delivered')){echo 'disable_row'; } ?>">
|
86 |
-
<td class="forminp">
|
87 |
-
<input type="hidden" name="wc_ast_status_delivered" value="0"/>
|
88 |
-
<input class="ast-tgl ast-tgl-flat ts_order_status_toggle" id="wc_ast_status_delivered" name="wc_ast_status_delivered" type="checkbox" <?php if(get_option('wc_ast_status_delivered')){echo 'checked'; } ?> value="1"/>
|
89 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wc_ast_status_delivered"></label>
|
90 |
-
</td>
|
91 |
-
<td class="forminp status-label-column">
|
92 |
-
<span class="order-label wc-delivered">
|
93 |
-
<?php
|
94 |
-
if(get_option('wc_ast_status_delivered')){
|
95 |
-
_e( wc_get_order_status_name( 'delivered' ), 'woo-advanced-shipment-tracking' );
|
96 |
-
} else{
|
97 |
-
_e( 'Delivered', 'woo-advanced-shipment-tracking' );
|
98 |
-
} ?>
|
99 |
-
</span>
|
100 |
-
</td>
|
101 |
-
<td class="forminp">
|
102 |
-
<fieldset>
|
103 |
-
<input class="input-text regular-input color_input" type="text" name="wc_ast_status_label_color" id="wc_ast_status_label_color" style="" value="<?php echo get_option('wc_ast_status_label_color','#59c889')?>" placeholder="">
|
104 |
-
<select class="select ts_custom_order_color_select" id="wc_ast_status_label_font_color" name="wc_ast_status_label_font_color">
|
105 |
-
<option value="#fff" <?php if(get_option('wc_ast_status_label_font_color','#fff') == '#fff'){ echo 'selected'; }?>><?php _e( 'Light Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
106 |
-
<option value="#000" <?php if(get_option('wc_ast_status_label_font_color','#fff') == '#000'){ echo 'selected'; }?>><?php _e( 'Dark Font', 'woo-advanced-shipment-tracking' ); ?></option>
|
107 |
-
</select>
|
108 |
-
</fieldset>
|
109 |
-
</td>
|
110 |
-
</tr>
|
111 |
-
<tr valign="top" class="status_change_to_delivered_tr" style="<?php if(!get_option('wc_ast_status_delivered')){ echo 'display:none;';}?>">
|
112 |
-
<td class="forminp">
|
113 |
-
<input type="hidden" name="wc_ast_status_change_to_delivered" value="0"/>
|
114 |
-
<input class="ast-tgl ast-tgl-flat" id="wc_ast_status_change_to_delivered" name="wc_ast_status_change_to_delivered" type="checkbox" <?php if(get_option('wc_ast_status_change_to_delivered')){echo 'checked'; } ?> value="1"/>
|
115 |
-
<label class="ast-tgl-btn ast-tgl-btn-green" for="wc_ast_status_change_to_delivered"></label>
|
116 |
-
</td>
|
117 |
-
<td colspan="2" style="text-align: left;">
|
118 |
-
<?php _e( 'Automatically update the order status to Delivered when all shipments are Delivered', 'woo-advanced-shipment-tracking' ); ?>
|
119 |
-
</td>
|
120 |
-
</tr>
|
121 |
-
</tbody>
|
122 |
-
</table>
|
123 |
-
</div>
|
124 |
-
</form>
|
125 |
-
</div>
|
126 |
-
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: zorem
|
3 |
Tags: WooCommerce, delivery, shipping, shipment tracking, tracking
|
4 |
Requires at least: 5.3
|
5 |
-
Tested up to: 5.
|
6 |
Requires PHP: 7.0
|
7 |
Stable tag: 4.0.1
|
8 |
License: GPLv2
|
@@ -142,6 +142,13 @@ Yes, if you use external shipping services that work with the WooCommerce REST A
|
|
142 |
|
143 |
== Changelog ==
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
= 3.2.1.5 =
|
146 |
* Enhancement - Updated settings page option design from multiple checkbox to multiple select2
|
147 |
* Dev - On first installation make 15 shipping provider active by default
|
2 |
Contributors: zorem
|
3 |
Tags: WooCommerce, delivery, shipping, shipment tracking, tracking
|
4 |
Requires at least: 5.3
|
5 |
+
Tested up to: 5.7
|
6 |
Requires PHP: 7.0
|
7 |
Stable tag: 4.0.1
|
8 |
License: GPLv2
|
142 |
|
143 |
== Changelog ==
|
144 |
|
145 |
+
= 3.2.2 =
|
146 |
+
* Enhancement - Updated Settings page design
|
147 |
+
* Enhancement - Moved TrackShip menu to a new page under WooCommerce and updated its design
|
148 |
+
* Dev - Added compatibility with WordPress 5.7 and WooCommerce 5.1.0
|
149 |
+
* Fix - Fixed Trackship Late Shipments variable issue
|
150 |
+
* Fix - Fixed compatibility with PHP 8
|
151 |
+
|
152 |
= 3.2.1.5 =
|
153 |
* Enhancement - Updated settings page option design from multiple checkbox to multiple select2
|
154 |
* Dev - On first installation make 15 shipping provider active by default
|
templates/emails/customer-delivered-order.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Customer delivered order email
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-completed-order.php.
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
exit;
|
12 |
-
}
|
13 |
-
|
14 |
-
/*
|
15 |
-
* @hooked WC_Emails::email_header() Output the email header
|
16 |
-
*/
|
17 |
-
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
|
18 |
-
|
19 |
-
<?php /* translators: %s: Customer first name */ ?>
|
20 |
-
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
|
21 |
-
<?php /* translators: %s: Site title */ ?>
|
22 |
-
<p><?php printf( esc_html__( 'Your %s order has been marked delivered on our side.', 'woocommerce' ), esc_html( wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) ); ?></p>
|
23 |
-
<?php
|
24 |
-
|
25 |
-
/*
|
26 |
-
* @hooked WC_Emails::order_details() Shows the order details table.
|
27 |
-
* @hooked WC_Structured_Data::generate_order_data() Generates structured data.
|
28 |
-
* @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
|
29 |
-
* @since 2.5.0
|
30 |
-
*/
|
31 |
-
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
|
32 |
-
|
33 |
-
/*
|
34 |
-
* @hooked WC_Emails::order_meta() Shows order meta data.
|
35 |
-
*/
|
36 |
-
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
|
37 |
-
|
38 |
-
/*
|
39 |
-
* @hooked WC_Emails::customer_details() Shows customer details
|
40 |
-
* @hooked WC_Emails::email_address() Shows email address
|
41 |
-
*/
|
42 |
-
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
|
43 |
-
|
44 |
-
?>
|
45 |
-
<p>
|
46 |
-
<?php esc_html_e( 'Thanks for shopping with us.', 'woocommerce' ); ?>
|
47 |
-
</p>
|
48 |
-
<?php
|
49 |
-
|
50 |
-
/*
|
51 |
-
* @hooked WC_Emails::email_footer() Output the email footer
|
52 |
-
*/
|
53 |
-
do_action( 'woocommerce_email_footer', $email );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/emails/customer-partial-shipped-order.php
CHANGED
@@ -18,32 +18,12 @@
|
|
18 |
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
exit;
|
20 |
}
|
21 |
-
$
|
22 |
-
|
23 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
24 |
-
$email_content = $ast->get_option_value_from_array('woocommerce_customer_partial_shipped_order_settings','wcast_partial_shipped_email_content',$wcast_partial_shipped_customizer_settings->defaults['wcast_partial_shipped_email_content']);
|
25 |
|
26 |
-
$email_content =
|
27 |
-
$email_content =
|
28 |
-
$email_content = str_replace( '{customer_first_name}', $order->get_billing_first_name(), $email_content );
|
29 |
-
$email_content = str_replace( '{customer_last_name}', $order->get_billing_last_name(), $email_content );
|
30 |
|
31 |
-
if($order->get_billing_company()){
|
32 |
-
$email_content = str_replace( '{customer_company_name}', $order->get_billing_company(), $email_content );
|
33 |
-
} else{
|
34 |
-
$email_content = str_replace( '{customer_company_name}','', $email_content );
|
35 |
-
}
|
36 |
-
|
37 |
-
$user = $order->get_user();
|
38 |
-
if($user){
|
39 |
-
$username = $user->user_login;
|
40 |
-
}
|
41 |
-
if(isset($username)){
|
42 |
-
$email_content = str_replace( '{customer_username}', $username, $email_content );
|
43 |
-
} else{
|
44 |
-
$email_content = str_replace( '{customer_username}', '', $email_content );
|
45 |
-
}
|
46 |
-
$email_content = str_replace( '{order_number}', $order->get_id(), $email_content );
|
47 |
/*
|
48 |
* @hooked WC_Emails::email_header() Output the email header
|
49 |
*/
|
18 |
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
exit;
|
20 |
}
|
21 |
+
$ps_settings = new wcast_partial_shipped_customizer_email();
|
|
|
22 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
|
|
23 |
|
24 |
+
$email_content = $ast->get_option_value_from_array('woocommerce_customer_partial_shipped_order_settings','wcast_partial_shipped_email_content',$ps_settings->defaults['wcast_partial_shipped_email_content']);
|
25 |
+
$email_content = wc_advanced_shipment_tracking_email_class()->email_content( $email_content, $order->get_id(), $order );
|
|
|
|
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
/*
|
28 |
* @hooked WC_Emails::email_header() Output the email header
|
29 |
*/
|
templates/emails/customer-updated-tracking-order.php
CHANGED
@@ -18,32 +18,12 @@
|
|
18 |
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
exit;
|
20 |
}
|
21 |
-
$
|
22 |
-
|
23 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
24 |
-
$email_content = $ast->get_option_value_from_array('woocommerce_customer_updated_tracking_order_settings','wcast_updated_tracking_email_content',$wcast_updated_tracking_customizer_settings->defaults['wcast_updated_tracking_email_content']);
|
25 |
|
26 |
-
$email_content =
|
27 |
-
$email_content =
|
28 |
-
$email_content = str_replace( '{customer_first_name}', $order->get_billing_first_name(), $email_content );
|
29 |
-
$email_content = str_replace( '{customer_last_name}', $order->get_billing_last_name(), $email_content );
|
30 |
|
31 |
-
if($order->get_billing_company()){
|
32 |
-
$email_content = str_replace( '{customer_company_name}', $order->get_billing_company(), $email_content );
|
33 |
-
} else{
|
34 |
-
$email_content = str_replace( '{customer_company_name}','', $email_content );
|
35 |
-
}
|
36 |
-
|
37 |
-
$user = $order->get_user();
|
38 |
-
if($user){
|
39 |
-
$username = $user->user_login;
|
40 |
-
}
|
41 |
-
if(isset($username)){
|
42 |
-
$email_content = str_replace( '{customer_username}', $username, $email_content );
|
43 |
-
} else{
|
44 |
-
$email_content = str_replace( '{customer_username}', '', $email_content );
|
45 |
-
}
|
46 |
-
$email_content = str_replace( '{order_number}', $order->get_id(), $email_content );
|
47 |
/*
|
48 |
* @hooked WC_Emails::email_header() Output the email header
|
49 |
*/
|
18 |
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
exit;
|
20 |
}
|
21 |
+
$ut_settings = new wcast_updated_tracking_customizer_email();
|
|
|
22 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
|
|
23 |
|
24 |
+
$email_content = $ast->get_option_value_from_array('woocommerce_customer_updated_tracking_order_settings','wcast_updated_tracking_email_content',$ut_settings->defaults['wcast_updated_tracking_email_content']);
|
25 |
+
$email_content = wc_advanced_shipment_tracking_email_class()->email_content( $email_content, $order->get_id(), $order );
|
|
|
|
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
/*
|
28 |
* @hooked WC_Emails::email_header() Output the email header
|
29 |
*/
|
templates/emails/plain/tracking-info.php
CHANGED
@@ -36,10 +36,9 @@ if ( $tracking_items ) {
|
|
36 |
}
|
37 |
|
38 |
foreach ( $tracking_items as $tracking_item ) {
|
39 |
-
$url = str_replace( '%number%', $tracking_item['tracking_number'], $tracking_item['formatted_tracking_link'] );
|
40 |
echo __( $provider_header_text, 'woo-advanced-shipment-tracking' ) . ": " . apply_filters( 'ast_provider_title', esc_html( $tracking_item['formatted_tracking_provider'] ) ) . "\n";
|
41 |
echo __( $tracking_number_header_text, 'woo-advanced-shipment-tracking' ) . ": " . esc_html( $tracking_item['tracking_number'] ) . "\n";
|
42 |
-
echo __( $track_header_text, 'woo-advanced-shipment-tracking' ) . ": " . esc_url( $
|
43 |
}
|
44 |
|
45 |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
|
36 |
}
|
37 |
|
38 |
foreach ( $tracking_items as $tracking_item ) {
|
|
|
39 |
echo __( $provider_header_text, 'woo-advanced-shipment-tracking' ) . ": " . apply_filters( 'ast_provider_title', esc_html( $tracking_item['formatted_tracking_provider'] ) ) . "\n";
|
40 |
echo __( $tracking_number_header_text, 'woo-advanced-shipment-tracking' ) . ": " . esc_html( $tracking_item['tracking_number'] ) . "\n";
|
41 |
+
echo __( $track_header_text, 'woo-advanced-shipment-tracking' ) . ": " . esc_url( $tracking_item['ast_tracking_link'] ) . "\n\n";
|
42 |
}
|
43 |
|
44 |
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
|
templates/emails/tracking-info.php
CHANGED
@@ -13,33 +13,16 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
13 |
* @version 1.6.4
|
14 |
*/
|
15 |
if ( $tracking_items ) :
|
16 |
-
$
|
17 |
-
$table_header_font_size = '';
|
18 |
-
$table_header_font_color = '';
|
19 |
-
$table_content_font_size = '';
|
20 |
-
$table_content_font_color = '';
|
21 |
-
$email_border_color = '';
|
22 |
-
$email_border_size = '';
|
23 |
-
$shipment_tracking_header_text = '';
|
24 |
-
$email_table_backgroud_color = '';
|
25 |
-
$tracking_link_font_color = '';
|
26 |
-
$tracking_link_bg_color = '';
|
27 |
-
$table_content_line_height = '';
|
28 |
-
$table_content_font_weight = '';
|
29 |
-
$header_content_text_align = '';
|
30 |
-
$table_padding = '12';
|
31 |
-
|
32 |
-
$tracking_info_settings = get_option('tracking_info_settings');
|
33 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
34 |
|
35 |
-
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$
|
36 |
|
37 |
$show_provider_th = 1;
|
38 |
$colspan = 1;
|
39 |
-
$display_thumbnail = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_image',$wcast_customizer_settings->defaults['display_shipment_provider_image']);
|
40 |
-
|
41 |
-
$display_shipping_provider_name = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_name',$wcast_customizer_settings->defaults['display_shipment_provider_name']);
|
42 |
|
|
|
|
|
43 |
$tracking_number_link = $ast->get_checkbox_option_value_from_array('tracking_info_settings','tracking_number_link','');
|
44 |
|
45 |
if($display_shipping_provider_name == 1 && $display_thumbnail == 1){
|
@@ -61,250 +44,200 @@ if ( $tracking_items ) :
|
|
61 |
if(is_rtl()){
|
62 |
$header_content_text_align = 'right';
|
63 |
} else{
|
64 |
-
$header_content_text_align = $ast->get_option_value_from_array('tracking_info_settings','header_content_text_align',$
|
65 |
}
|
66 |
|
67 |
$table_padding = 10;
|
68 |
|
69 |
-
$email_border_color = $ast->get_option_value_from_array('tracking_info_settings','table_border_color',$
|
70 |
-
|
71 |
-
$email_border_size = $ast->get_option_value_from_array('tracking_info_settings','table_border_size',$wcast_customizer_settings->defaults['table_border_size']);
|
72 |
-
|
73 |
$hide_trackig_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_trackig_header','');
|
74 |
-
|
75 |
$shipment_tracking_header = $ast->get_option_value_from_array('tracking_info_settings','header_text_change','Tracking Information');
|
76 |
-
|
77 |
$shipment_tracking_header_text = $ast->get_option_value_from_array('tracking_info_settings','additional_header_text','');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
$
|
80 |
-
|
81 |
-
$table_content_line_height = $ast->get_option_value_from_array('tracking_info_settings','table_content_line_height',$wcast_customizer_settings->defaults['table_content_line_height']);
|
82 |
-
|
83 |
-
$table_content_font_weight = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_weight',$wcast_customizer_settings->defaults['table_content_font_weight']);
|
84 |
-
|
85 |
-
$table_header_bg_color = $ast->get_option_value_from_array('tracking_info_settings','table_header_bg_color',$wcast_customizer_settings->defaults['table_header_bg_color']);
|
86 |
-
|
87 |
-
$table_header_font_size = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_size',$wcast_customizer_settings->defaults['table_header_font_size']);
|
88 |
-
|
89 |
-
$table_header_font_weight = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_weight',$wcast_customizer_settings->defaults['table_header_font_weight']);
|
90 |
-
|
91 |
-
$table_header_font_color = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_color',$wcast_customizer_settings->defaults['table_header_font_color']);
|
92 |
-
|
93 |
-
$table_content_font_size = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_size',$wcast_customizer_settings->defaults['table_content_font_size']);
|
94 |
-
|
95 |
-
$table_content_font_color = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_color',$wcast_customizer_settings->defaults['table_content_font_color']);
|
96 |
-
|
97 |
-
$tracking_link_font_color = $ast->get_option_value_from_array('tracking_info_settings','tracking_link_font_color',$wcast_customizer_settings->defaults['tracking_link_font_color']);
|
98 |
-
|
99 |
-
$tracking_link_bg_color = $ast->get_option_value_from_array('tracking_info_settings','tracking_link_bg_color',$wcast_customizer_settings->defaults['tracking_link_bg_color']);
|
100 |
|
101 |
$th_column_style = "background:".$table_header_bg_color.";text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px;font-weight:".$table_header_font_weight."; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: ".$table_padding."px;";
|
102 |
-
|
103 |
$td_column_style = "text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px;font-weight:".$table_content_font_weight."; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: ".$table_padding."px;min-width: auto;";
|
104 |
-
|
105 |
$tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";padding: 10px;text-decoration: none;";
|
106 |
-
|
107 |
$tracking_link_style2 = "color: ".$tracking_link_font_color.";padding: 10px;text-decoration: none;";
|
108 |
|
109 |
-
$hide_table_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_table_header','');
|
110 |
-
|
111 |
-
$remove_date_from_tracking_info = $ast->get_checkbox_option_value_from_array('tracking_info_settings','remove_date_from_tracking',$wcast_customizer_settings->defaults['remove_date_from_tracking']);
|
112 |
-
|
113 |
-
$show_track_label = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_track_label',$wcast_customizer_settings->defaults['show_track_label']);
|
114 |
-
|
115 |
-
$provider_header_text = $ast->get_option_value_from_array('tracking_info_settings','provider_header_text',$wcast_customizer_settings->defaults['provider_header_text']);
|
116 |
-
|
117 |
-
$tracking_number_header_text = $ast->get_option_value_from_array('tracking_info_settings','tracking_number_header_text',$wcast_customizer_settings->defaults['tracking_number_header_text']);
|
118 |
-
|
119 |
-
$shipped_date_header_text = $ast->get_option_value_from_array('tracking_info_settings','shipped_date_header_text',$wcast_customizer_settings->defaults['shipped_date_header_text']);
|
120 |
-
|
121 |
-
$track_header_text = $ast->get_option_value_from_array('tracking_info_settings','track_header_text',$wcast_customizer_settings->defaults['track_header_text']);
|
122 |
-
|
123 |
-
$simple_layout_content = $ast->get_option_value_from_array('tracking_info_settings','simple_layout_content',$wcast_customizer_settings->defaults['simple_layout_content']);
|
124 |
-
|
125 |
-
$simple_provider_font_size = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_size',$wcast_customizer_settings->defaults['simple_provider_font_size']);
|
126 |
-
|
127 |
-
$simple_provider_font_color = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_color',$wcast_customizer_settings->defaults['simple_provider_font_color']);
|
128 |
-
|
129 |
-
$show_provider_border = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_provider_border',$wcast_customizer_settings->defaults['show_provider_border']);
|
130 |
-
|
131 |
-
$provider_border_color = $ast->get_option_value_from_array('tracking_info_settings','provider_border_color',$wcast_customizer_settings->defaults['provider_border_color']);
|
132 |
-
|
133 |
-
if(isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview']){
|
134 |
-
$preview = true;
|
135 |
-
} else{
|
136 |
-
$preview = false;
|
137 |
-
}
|
138 |
-
$text_align = is_rtl() ? 'right' : 'left';
|
139 |
-
|
140 |
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
141 |
-
|
142 |
-
?>
|
143 |
-
|
|
|
|
|
144 |
<?php } else{ ?>
|
145 |
-
<h2 class="header_text" style="text-align:<?php echo $text_align; ?>;<?php if($hide_trackig_header){ echo 'display:none;'; } ?>"
|
|
|
|
|
146 |
<?php } ?>
|
|
|
147 |
<p class="addition_header"><?php echo $shipment_tracking_header_text; ?></p>
|
148 |
|
149 |
<?php if( $select_tracking_template == 'simple_list' ){ ?>
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
$date_shipped = date("Y-m-d");
|
154 |
-
if(isset($tracking_item['date_shipped'])){
|
155 |
-
$date_shipped = $tracking_item['date_shipped'];
|
156 |
-
}
|
157 |
-
|
158 |
-
global $wpdb;
|
159 |
-
|
160 |
-
$tracking_provider = isset( $tracking_item['tracking_provider'] ) ? $tracking_item['tracking_provider'] : $tracking_item['custom_tracking_provider'];
|
161 |
-
|
162 |
-
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
163 |
-
|
164 |
-
$results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woo_shippment_provider WHERE ts_slug = %s", $tracking_provider ) );
|
165 |
-
|
166 |
-
$provider_name = apply_filters('get_ast_provider_name', $tracking_provider, $results);
|
167 |
-
|
168 |
-
$url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']);
|
169 |
-
$simple_layout_content_updated = '';
|
170 |
-
?>
|
171 |
-
<li class="tracking_list_li">
|
172 |
-
<div class="tracking_list_div" style="font-size:<?php echo $simple_provider_font_size; ?>px;color:<?php echo $simple_provider_font_color; ?>;border-bottom:<?php echo $show_provider_border; ?>px solid <?php echo $provider_border_color; ?>">
|
173 |
-
<?php
|
174 |
-
$formatted_tracking_provider = apply_filters( 'ast_provider_title', esc_html( $provider_name ));
|
175 |
-
|
176 |
-
$simple_layout_content_updated = str_replace('{ship_date}',date_i18n( get_option( 'date_format' ), $date_shipped ),$simple_layout_content);
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
<?php } else if( $select_tracking_template == 'default_table' ){ ?>
|
192 |
<table class="td tracking_table" cellspacing="0" cellpadding="6" style="width: 100%;border-collapse: collapse;background:<?php echo $email_table_backgroud_color; ?>" border="1">
|
193 |
-
<?php if($preview){ ?>
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
<th class="
|
205 |
-
|
206 |
-
if($remove_date_from_tracking_info
|
|
|
|
|
207 |
<th class="date-shipped" style="<?php echo $th_column_style; ?>"><span class="nobr"><?php _e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
208 |
<?php }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
} ?>
|
210 |
-
|
211 |
-
|
212 |
-
if($preview){ ?>
|
213 |
-
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><span class="track_label <?php if($show_track_label != 1){ echo 'hide'; } ?>"><?php _e( $track_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
214 |
-
<?php } else{ ?>
|
215 |
-
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php if($show_track_label == 1){ _e( $track_header_text, 'woo-advanced-shipment-tracking' ); } ?></th>
|
216 |
-
<?php } } ?>
|
217 |
-
</tr>
|
218 |
-
</thead>
|
219 |
<?php } else{ ?>
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
<th class="
|
231 |
-
|
|
|
|
|
232 |
if($remove_date_from_tracking_info != 1){ ?>
|
233 |
<th class="date-shipped" style="<?php echo $th_column_style; ?>"><span class="nobr"><?php esc_html_e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
} ?>
|
236 |
-
|
237 |
-
|
238 |
-
if($preview){ ?>
|
239 |
-
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><span class="track_label <?php if($show_track_label != 1){ echo 'hide'; } ?>"><?php _e( $track_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
240 |
-
<?php } else{ ?>
|
241 |
-
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php if($show_track_label == 1){ _e( $track_header_text, 'woo-advanced-shipment-tracking' ); } ?></th>
|
242 |
-
<?php } } ?>
|
243 |
-
</tr>
|
244 |
-
</thead>
|
245 |
<?php } ?>
|
246 |
|
247 |
<tbody style="line-height:<?php echo $table_content_line_height; ?>px;"><?php
|
248 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
249 |
-
$date_shipped = date("Y-m-d");
|
250 |
-
if(isset($tracking_item['date_shipped'])){
|
251 |
-
$date_shipped = $tracking_item['date_shipped'];
|
252 |
-
}
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
$tracking_provider = isset( $tracking_item['tracking_provider'] ) ? $tracking_item['tracking_provider'] : $tracking_item['custom_tracking_provider'];
|
257 |
-
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
258 |
-
|
259 |
-
$results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woo_shippment_provider WHERE ts_slug = %s", $tracking_provider ) );
|
260 |
-
|
261 |
-
$provider_name = apply_filters('get_ast_provider_name', $tracking_provider, $results);
|
262 |
?>
|
263 |
<tr class="tracking" style="background-color:<?php echo $email_table_backgroud_color; ?>">
|
|
|
264 |
<?php if($display_thumbnail == 1){ ?>
|
265 |
<td class="tracking-provider" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>;width: 50px;">
|
266 |
-
<img style="width: 50px;vertical-align: middle;" src="<?php echo
|
267 |
</td>
|
268 |
<?php } ?>
|
|
|
269 |
<?php if($display_shipping_provider_name == 1){ ?>
|
270 |
<td class="tracking-provider" data-title="<?php _e( 'Provider Name', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
|
271 |
-
<?php echo apply_filters( 'ast_provider_title', esc_html( $
|
272 |
</td>
|
273 |
<?php } ?>
|
274 |
|
275 |
-
<?php do_action(
|
276 |
|
277 |
<td class="tracking-number" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
|
278 |
-
<?php if($tracking_item['
|
279 |
-
|
280 |
-
<a href="<?php echo esc_url( $url ); ?>" style="text-decoration: none;" target="_blank"><?php echo esc_html( $tracking_item['tracking_number'] ); ?></a>
|
281 |
<?php } else{
|
282 |
echo esc_html( $tracking_item['tracking_number'] );
|
283 |
} ?>
|
284 |
</td>
|
|
|
285 |
<?php if($preview){ ?>
|
286 |
<td class="date-shipped <?php if($remove_date_from_tracking_info == 1){ echo 'hide'; } ?>" data-title="<?php _e( 'Status', 'woocommerce' ); ?>" style="<?php echo $td_column_style; ?>">
|
287 |
<time datetime="<?php echo date( 'Y-m-d', $date_shipped ); ?>" title="<?php echo date( 'Y-m-d', $date_shipped ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $date_shipped ); ?></time>
|
288 |
</td>
|
289 |
<?php } else{
|
290 |
-
if($remove_date_from_tracking_info != 1){ ?>
|
291 |
<td class="date-shipped" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Date', 'woocommerce' ); ?>" style="text-align:left; white-space:nowrap;">
|
292 |
<time datetime="<?php echo date( 'Y-m-d', $date_shipped ); ?>" title="<?php echo date( 'Y-m-d', $date_shipped ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $date_shipped ); ?></time>
|
293 |
</td>
|
294 |
<?php }
|
295 |
-
|
296 |
-
|
297 |
-
?>
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
</td>
|
304 |
<?php } ?>
|
305 |
</tr><?php
|
306 |
-
}
|
307 |
-
|
308 |
</table><br/>
|
309 |
<?php }
|
310 |
if( !isset($show_shipment_status) ) $show_shipment_status = false;
|
13 |
* @version 1.6.4
|
14 |
*/
|
15 |
if ( $tracking_items ) :
|
16 |
+
$settings = new wcast_initialise_customizer_settings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
18 |
|
19 |
+
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$settings->defaults['select_tracking_template']);
|
20 |
|
21 |
$show_provider_th = 1;
|
22 |
$colspan = 1;
|
|
|
|
|
|
|
23 |
|
24 |
+
$display_thumbnail = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_image',$settings->defaults['display_shipment_provider_image']);
|
25 |
+
$display_shipping_provider_name = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_name',$settings->defaults['display_shipment_provider_name']);
|
26 |
$tracking_number_link = $ast->get_checkbox_option_value_from_array('tracking_info_settings','tracking_number_link','');
|
27 |
|
28 |
if($display_shipping_provider_name == 1 && $display_thumbnail == 1){
|
44 |
if(is_rtl()){
|
45 |
$header_content_text_align = 'right';
|
46 |
} else{
|
47 |
+
$header_content_text_align = $ast->get_option_value_from_array('tracking_info_settings','header_content_text_align',$settings->defaults['header_content_text_align']);
|
48 |
}
|
49 |
|
50 |
$table_padding = 10;
|
51 |
|
52 |
+
$email_border_color = $ast->get_option_value_from_array('tracking_info_settings','table_border_color',$settings->defaults['table_border_color']);
|
53 |
+
$email_border_size = $ast->get_option_value_from_array('tracking_info_settings','table_border_size',$settings->defaults['table_border_size']);
|
|
|
|
|
54 |
$hide_trackig_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_trackig_header','');
|
|
|
55 |
$shipment_tracking_header = $ast->get_option_value_from_array('tracking_info_settings','header_text_change','Tracking Information');
|
|
|
56 |
$shipment_tracking_header_text = $ast->get_option_value_from_array('tracking_info_settings','additional_header_text','');
|
57 |
+
$email_table_backgroud_color = $ast->get_option_value_from_array('tracking_info_settings','table_bg_color',$settings->defaults['table_bg_color']);
|
58 |
+
$table_content_line_height = $ast->get_option_value_from_array('tracking_info_settings','table_content_line_height',$settings->defaults['table_content_line_height']);
|
59 |
+
$table_content_font_weight = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_weight',$settings->defaults['table_content_font_weight']);
|
60 |
+
$table_header_bg_color = $ast->get_option_value_from_array('tracking_info_settings','table_header_bg_color',$settings->defaults['table_header_bg_color']);
|
61 |
+
$table_header_font_size = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_size',$settings->defaults['table_header_font_size']);
|
62 |
+
$table_header_font_weight = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_weight',$settings->defaults['table_header_font_weight']);
|
63 |
+
$table_header_font_color = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_color',$settings->defaults['table_header_font_color']);
|
64 |
+
$table_content_font_size = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_size',$settings->defaults['table_content_font_size']);
|
65 |
+
$table_content_font_color = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_color',$settings->defaults['table_content_font_color']);
|
66 |
+
$tracking_link_font_color = $ast->get_option_value_from_array('tracking_info_settings','tracking_link_font_color',$settings->defaults['tracking_link_font_color']);
|
67 |
+
$tracking_link_bg_color = $ast->get_option_value_from_array('tracking_info_settings','tracking_link_bg_color',$settings->defaults['tracking_link_bg_color']);
|
68 |
+
$hide_table_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_table_header','');
|
69 |
+
$remove_date_from_tracking_info = $ast->get_checkbox_option_value_from_array('tracking_info_settings','remove_date_from_tracking',$settings->defaults['remove_date_from_tracking']);
|
70 |
+
$show_track_label = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_track_label',$settings->defaults['show_track_label']);
|
71 |
+
$provider_header_text = $ast->get_option_value_from_array('tracking_info_settings','provider_header_text',$settings->defaults['provider_header_text']);
|
72 |
+
$tracking_number_header_text = $ast->get_option_value_from_array('tracking_info_settings','tracking_number_header_text',$settings->defaults['tracking_number_header_text']);
|
73 |
+
$shipped_date_header_text = $ast->get_option_value_from_array('tracking_info_settings','shipped_date_header_text',$settings->defaults['shipped_date_header_text']);
|
74 |
+
$track_header_text = $ast->get_option_value_from_array('tracking_info_settings','track_header_text',$settings->defaults['track_header_text']);
|
75 |
+
$simple_layout_content = $ast->get_option_value_from_array('tracking_info_settings','simple_layout_content',$settings->defaults['simple_layout_content']);
|
76 |
+
$simple_provider_font_size = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_size',$settings->defaults['simple_provider_font_size']);
|
77 |
+
$simple_provider_font_color = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_color',$settings->defaults['simple_provider_font_color']);
|
78 |
+
$show_provider_border = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_provider_border',$settings->defaults['show_provider_border']);
|
79 |
+
$provider_border_color = $ast->get_option_value_from_array('tracking_info_settings','provider_border_color',$settings->defaults['provider_border_color']);
|
80 |
+
|
81 |
+
$preview = ( isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview'] ) ? true : false;
|
82 |
|
83 |
+
$text_align = is_rtl() ? 'right' : 'left';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
$th_column_style = "background:".$table_header_bg_color.";text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px;font-weight:".$table_header_font_weight."; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: ".$table_padding."px;";
|
|
|
86 |
$td_column_style = "text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px;font-weight:".$table_content_font_weight."; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: ".$table_padding."px;min-width: auto;";
|
|
|
87 |
$tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";padding: 10px;text-decoration: none;";
|
|
|
88 |
$tracking_link_style2 = "color: ".$tracking_link_font_color.";padding: 10px;text-decoration: none;";
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
91 |
+
|
92 |
+
if( $preview ){ ?>
|
93 |
+
<h2 class="header_text <?php if( $hide_trackig_header ){ echo 'hide'; } ?>" style="text-align:<?php echo $text_align; ?>;">
|
94 |
+
<?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?>
|
95 |
+
</h2>
|
96 |
<?php } else{ ?>
|
97 |
+
<h2 class="header_text" style="text-align:<?php echo $text_align; ?>;<?php if( $hide_trackig_header ){ echo 'display:none;'; } ?>">
|
98 |
+
<?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?>
|
99 |
+
</h2>
|
100 |
<?php } ?>
|
101 |
+
|
102 |
<p class="addition_header"><?php echo $shipment_tracking_header_text; ?></p>
|
103 |
|
104 |
<?php if( $select_tracking_template == 'simple_list' ){ ?>
|
105 |
+
<div class="tracking_info">
|
106 |
+
<ul class="tracking_list">
|
107 |
+
<?php foreach ( $tracking_items as $tracking_item ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
+
$date_shipped = ( isset( $tracking_item['date_shipped'] ) ) ? $tracking_item['date_shipped'] : date("Y-m-d");
|
110 |
+
|
111 |
+
$simple_layout_content_updated = ''; ?>
|
112 |
+
|
113 |
+
<li class="tracking_list_li">
|
114 |
+
<div class="tracking_list_div" style="font-size:<?php echo $simple_provider_font_size; ?>px;color:<?php echo $simple_provider_font_color; ?>;border-bottom:<?php echo $show_provider_border; ?>px solid <?php echo $provider_border_color; ?>">
|
115 |
+
<?php
|
116 |
+
$formatted_tracking_provider = apply_filters( 'ast_provider_title', esc_html( $tracking_item[ 'formatted_tracking_provider' ] ));
|
117 |
+
$simple_layout_content_updated = str_replace('{ship_date}',date_i18n( get_option( 'date_format' ), $date_shipped ),$simple_layout_content);
|
118 |
+
$simple_layout_content_updated = str_replace('{shipping_provider}',$formatted_tracking_provider,$simple_layout_content_updated);
|
119 |
+
$tracking_number_link = '<a target="_blank" href="'.esc_url( $tracking_item['ast_tracking_link'] ).'">'.$tracking_item['tracking_number'].'</a>';
|
120 |
+
$simple_layout_content_updated = str_replace('{tracking_number_link}',$tracking_number_link,$simple_layout_content_updated);
|
121 |
+
echo $simple_layout_content_updated; ?>
|
122 |
+
</div>
|
123 |
+
<?php do_action("ast_tracking_simple_list_email_body", $order_id,$tracking_item); ?>
|
124 |
+
</li>
|
125 |
+
<?php } ?>
|
126 |
+
</ul>
|
127 |
+
</div>
|
128 |
<?php } else if( $select_tracking_template == 'default_table' ){ ?>
|
129 |
<table class="td tracking_table" cellspacing="0" cellpadding="6" style="width: 100%;border-collapse: collapse;background:<?php echo $email_table_backgroud_color; ?>" border="1">
|
130 |
+
<?php if( $preview ){ ?>
|
131 |
+
<thead class="<?php if( $hide_table_header ){ echo 'hide'; }?>">
|
132 |
+
<tr>
|
133 |
+
<?php if( $show_provider_th ){ ?>
|
134 |
+
<th class="tracking-provider" colspan="<?php echo $colspan; ?>" scope="col" class="td" style="<?php echo $th_column_style; ?>">
|
135 |
+
<?php _e( $provider_header_text, 'woo-advanced-shipment-tracking' ); ?>
|
136 |
+
</th>
|
137 |
+
<?php }
|
138 |
+
|
139 |
+
do_action("ast_tracking_email_header", $order_id, $th_column_style); ?>
|
140 |
+
|
141 |
+
<th class="tracking-number" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( $tracking_number_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
142 |
+
<?php if( $preview ){ ?>
|
143 |
+
<th class="date-shipped <?php if( $remove_date_from_tracking_info == 1 ){ echo 'hide'; } ?>" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
144 |
+
<?php } else{
|
145 |
+
if( $remove_date_from_tracking_info != 1 ){ ?>
|
146 |
<th class="date-shipped" style="<?php echo $th_column_style; ?>"><span class="nobr"><?php _e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
147 |
<?php }
|
148 |
+
}
|
149 |
+
|
150 |
+
if( !$tracking_number_link ){
|
151 |
+
if( $preview ){ ?>
|
152 |
+
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><span class="track_label <?php if( $show_track_label != 1 ){ echo 'hide'; } ?>"><?php _e( $track_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
153 |
+
<?php } else{ ?>
|
154 |
+
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php if( $show_track_label == 1 ){ _e( $track_header_text, 'woo-advanced-shipment-tracking' ); } ?></th>
|
155 |
+
<?php }
|
156 |
} ?>
|
157 |
+
</tr>
|
158 |
+
</thead>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
<?php } else{ ?>
|
160 |
+
<thead style="<?php if( $hide_table_header ){ echo 'display:none'; }?>">
|
161 |
+
<tr>
|
162 |
+
<?php if( $show_provider_th ){ ?>
|
163 |
+
<th class="tracking-provider" colspan="<?php echo $colspan; ?>" scope="col" class="td" style="<?php echo $th_column_style; ?>">
|
164 |
+
<?php esc_html_e( $provider_header_text, 'woo-advanced-shipment-tracking' ); ?>
|
165 |
+
</th>
|
166 |
+
<?php }
|
167 |
+
|
168 |
+
do_action("ast_tracking_email_header", $order_id, $th_column_style); ?>
|
169 |
+
|
170 |
+
<th class="tracking-number" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php esc_html_e( $tracking_number_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
171 |
+
<?php if( $preview ){ ?>
|
172 |
+
<th class="date-shipped <?php if($remove_date_from_tracking_info == 1){ echo 'hide'; } ?>" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php esc_html_e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
173 |
+
<?php } else{
|
174 |
if($remove_date_from_tracking_info != 1){ ?>
|
175 |
<th class="date-shipped" style="<?php echo $th_column_style; ?>"><span class="nobr"><?php esc_html_e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
176 |
+
<?php }
|
177 |
+
}
|
178 |
+
|
179 |
+
if( !$tracking_number_link ){
|
180 |
+
if( $preview ){ ?>
|
181 |
+
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><span class="track_label <?php if($show_track_label != 1){ echo 'hide'; } ?>"><?php _e( $track_header_text, 'woo-advanced-shipment-tracking' ); ?></span></th>
|
182 |
+
<?php } else{ ?>
|
183 |
+
<th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php if($show_track_label == 1){ _e( $track_header_text, 'woo-advanced-shipment-tracking' ); } ?></th>
|
184 |
+
<?php }
|
185 |
} ?>
|
186 |
+
</tr>
|
187 |
+
</thead>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
<?php } ?>
|
189 |
|
190 |
<tbody style="line-height:<?php echo $table_content_line_height; ?>px;"><?php
|
191 |
foreach ( $tracking_items as $key => $tracking_item ) {
|
|
|
|
|
|
|
|
|
192 |
|
193 |
+
$date_shipped = ( isset( $tracking_item['date_shipped'] ) ) ? $tracking_item['date_shipped'] : date("Y-m-d");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
?>
|
195 |
<tr class="tracking" style="background-color:<?php echo $email_table_backgroud_color; ?>">
|
196 |
+
|
197 |
<?php if($display_thumbnail == 1){ ?>
|
198 |
<td class="tracking-provider" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>;width: 50px;">
|
199 |
+
<img style="width: 50px;vertical-align: middle;" src="<?php echo esc_url( $tracking_item['tracking_provider_image'] ); ?>">
|
200 |
</td>
|
201 |
<?php } ?>
|
202 |
+
|
203 |
<?php if($display_shipping_provider_name == 1){ ?>
|
204 |
<td class="tracking-provider" data-title="<?php _e( 'Provider Name', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
|
205 |
+
<?php echo apply_filters( 'ast_provider_title', esc_html( $tracking_item[ 'formatted_tracking_provider' ] )); ?>
|
206 |
</td>
|
207 |
<?php } ?>
|
208 |
|
209 |
+
<?php do_action( 'ast_tracking_email_body', $order_id, $tracking_item, $td_column_style ); ?>
|
210 |
|
211 |
<td class="tracking-number" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
|
212 |
+
<?php if($tracking_item['ast_tracking_link'] && $tracking_number_link){ ?>
|
213 |
+
<a href="<?php echo esc_url( $tracking_item['ast_tracking_link'] ); ?>" style="text-decoration: none;" target="_blank"><?php echo esc_html( $tracking_item['tracking_number'] ); ?></a>
|
|
|
214 |
<?php } else{
|
215 |
echo esc_html( $tracking_item['tracking_number'] );
|
216 |
} ?>
|
217 |
</td>
|
218 |
+
|
219 |
<?php if($preview){ ?>
|
220 |
<td class="date-shipped <?php if($remove_date_from_tracking_info == 1){ echo 'hide'; } ?>" data-title="<?php _e( 'Status', 'woocommerce' ); ?>" style="<?php echo $td_column_style; ?>">
|
221 |
<time datetime="<?php echo date( 'Y-m-d', $date_shipped ); ?>" title="<?php echo date( 'Y-m-d', $date_shipped ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $date_shipped ); ?></time>
|
222 |
</td>
|
223 |
<?php } else{
|
224 |
+
if( $remove_date_from_tracking_info != 1 ){ ?>
|
225 |
<td class="date-shipped" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Date', 'woocommerce' ); ?>" style="text-align:left; white-space:nowrap;">
|
226 |
<time datetime="<?php echo date( 'Y-m-d', $date_shipped ); ?>" title="<?php echo date( 'Y-m-d', $date_shipped ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $date_shipped ); ?></time>
|
227 |
</td>
|
228 |
<?php }
|
229 |
+
}
|
230 |
+
|
231 |
+
if( !$tracking_number_link ){ ?>
|
232 |
+
<td class="order-actions" style="<?php echo $td_column_style; ?>">
|
233 |
+
<?php if($tracking_item['ast_tracking_link']){ ?>
|
234 |
+
<a href="<?php echo esc_url( $tracking_item['ast_tracking_link'] ); ?>" style="<?php echo $tracking_link_style; ?>" target="_blank"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
|
235 |
+
<?php } ?>
|
236 |
+
</td>
|
|
|
237 |
<?php } ?>
|
238 |
</tr><?php
|
239 |
+
} ?>
|
240 |
+
</tbody>
|
241 |
</table><br/>
|
242 |
<?php }
|
243 |
if( !isset($show_shipment_status) ) $show_shipment_status = false;
|
templates/emails/wcast-billing-email-addresses.php
CHANGED
@@ -21,14 +21,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
21 |
|
22 |
$text_align = is_rtl() ? 'right' : 'left';
|
23 |
$address = $order->get_formatted_billing_address();
|
24 |
-
$shipping = $order->get_formatted_shipping_address();
|
25 |
|
26 |
-
?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 48%;
|
27 |
<tr>
|
28 |
-
<td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:
|
29 |
-
<
|
30 |
-
|
31 |
-
<address class="address">
|
32 |
<?php echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
|
33 |
<?php if ( $order->get_billing_phone() ) : ?>
|
34 |
<br/><?php echo esc_html( $order->get_billing_phone() ); ?>
|
21 |
|
22 |
$text_align = is_rtl() ? 'right' : 'left';
|
23 |
$address = $order->get_formatted_billing_address();
|
|
|
24 |
|
25 |
+
?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 48%;display:inline-block;vertical-align: top; margin-bottom: 20px; padding:0;border: 1px solid #e0e0e0;" border="0">
|
26 |
<tr>
|
27 |
+
<td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:15px;" valign="top" width="50%">
|
28 |
+
<strong style="color: #4e4e4e;padding-bottom: 5px;font-size: 14px;"><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></strong>
|
29 |
+
<address class="address" style="padding: 0;border:0;margin: 5px 0 0 0;font-size: 14px;font-style: normal;vertical-align: middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;line-height: 20px;color: #4e4e4e;">
|
|
|
30 |
<?php echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
|
31 |
<?php if ( $order->get_billing_phone() ) : ?>
|
32 |
<br/><?php echo esc_html( $order->get_billing_phone() ); ?>
|
templates/emails/wcast-shipping-email-addresses.php
CHANGED
@@ -22,14 +22,13 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
22 |
$text_align = is_rtl() ? 'right' : 'left';
|
23 |
$address = $order->get_formatted_billing_address();
|
24 |
$shipping = $order->get_formatted_shipping_address();
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
</table>
|
22 |
$text_align = is_rtl() ? 'right' : 'left';
|
23 |
$address = $order->get_formatted_billing_address();
|
24 |
$shipping = $order->get_formatted_shipping_address();
|
25 |
+
if( !empty($shipping) ){ ?>
|
26 |
+
<table id="addresses" cellspacing="0" cellpadding="0" style="width: 48%;display:inline-block;vertical-align: top; margin-bottom: 20px; padding:0;border: 1px solid #e0e0e0;" border="0">
|
27 |
+
<tr>
|
28 |
+
<td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:15px;" valign="top" width="50%">
|
29 |
+
<strong style="color: #4e4e4e;padding-bottom: 5px;font-size: 14px;"><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></strong>
|
30 |
+
<address class="address" style="padding: 0;border:0;margin: 5px 0 0 0;font-size: 14px;font-style: normal;vertical-align: middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;line-height: 20px;color: #4e4e4e;"><?php echo wp_kses_post( $shipping ); ?></address>
|
31 |
+
</td>
|
32 |
+
</tr>
|
33 |
+
</table>
|
34 |
+
<?php } ?>
|
|
templates/myaccount/tracking-info.php
CHANGED
@@ -14,33 +14,16 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
*/
|
15 |
|
16 |
if ( $tracking_items ) :
|
17 |
-
$
|
18 |
-
$table_header_font_size = '';
|
19 |
-
$table_header_font_color = '';
|
20 |
-
$table_content_font_size = '';
|
21 |
-
$table_content_font_color = '';
|
22 |
-
$email_border_color = '';
|
23 |
-
$email_border_size = '';
|
24 |
-
$shipment_tracking_header_text = '';
|
25 |
-
$email_table_backgroud_color = '';
|
26 |
-
$tracking_link_font_color = '';
|
27 |
-
$tracking_link_bg_color = '';
|
28 |
-
$table_content_line_height = '';
|
29 |
-
$table_content_font_weight = '';
|
30 |
-
|
31 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
32 |
-
|
33 |
-
$tracking_info_settings = get_option('tracking_info_settings');
|
34 |
|
35 |
-
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$
|
36 |
|
37 |
$show_provider_th = 1;
|
38 |
$colspan = 1;
|
39 |
|
40 |
-
$display_thumbnail = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_image',$
|
41 |
-
|
42 |
-
$display_shipping_provider_name = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_name',$wcast_customizer_settings->defaults['display_shipment_provider_name']);
|
43 |
-
|
44 |
$tracking_number_link = $ast->get_checkbox_option_value_from_array('tracking_info_settings','tracking_number_link','');
|
45 |
|
46 |
if($display_shipping_provider_name == 1 && $display_thumbnail == 1){
|
@@ -59,231 +42,193 @@ if ( $tracking_items ) :
|
|
59 |
$show_provider_th = 0;
|
60 |
}
|
61 |
|
62 |
-
$email_border_color = $ast->get_option_value_from_array('tracking_info_settings','table_border_color',$
|
63 |
-
|
64 |
-
if(get_theme_mod('table_border_size')){ $email_border_size = get_theme_mod('table_border_size'); } else{ $email_border_size = "1"; }
|
65 |
-
|
66 |
$hide_trackig_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_trackig_header','');
|
67 |
-
|
68 |
$shipment_tracking_header = $ast->get_option_value_from_array('tracking_info_settings','header_text_change','Tracking Information');
|
69 |
-
|
70 |
$shipment_tracking_header_text = $ast->get_option_value_from_array('tracking_info_settings','additional_header_text','');
|
71 |
-
|
72 |
-
$
|
73 |
-
|
74 |
-
$
|
75 |
-
|
76 |
-
$
|
77 |
-
|
78 |
-
$
|
79 |
-
|
80 |
-
$
|
81 |
-
|
82 |
-
$
|
83 |
-
|
84 |
-
$
|
85 |
-
|
86 |
-
$
|
87 |
-
|
88 |
-
$
|
89 |
-
|
90 |
-
$
|
91 |
-
|
92 |
-
$
|
93 |
-
|
|
|
|
|
94 |
if(is_rtl()){
|
95 |
$header_content_text_align = 'right';
|
96 |
} else{
|
97 |
-
$header_content_text_align = $ast->get_option_value_from_array('tracking_info_settings','header_content_text_align',$
|
98 |
}
|
99 |
|
100 |
$th_column_style = "background:".$table_header_bg_color.";text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;font-weight:".$table_header_font_weight.";";
|
101 |
|
102 |
-
$td_column_style = "text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px;font-weight:".$table_content_font_weight."; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;line-height: ".$table_content_line_height."px;";
|
103 |
-
|
104 |
-
$tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";margin-bottom: 0;";
|
105 |
-
|
106 |
-
$hide_table_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_table_header','');
|
107 |
-
|
108 |
-
$remove_date_from_tracking_info = $ast->get_checkbox_option_value_from_array('tracking_info_settings','remove_date_from_tracking',$wcast_customizer_settings->defaults['remove_date_from_tracking']);
|
109 |
-
|
110 |
-
$show_track_label = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_track_label',$wcast_customizer_settings->defaults['show_track_label']);
|
111 |
|
112 |
-
$
|
113 |
-
|
114 |
-
$tracking_number_header_text = $ast->get_option_value_from_array('tracking_info_settings','tracking_number_header_text',$wcast_customizer_settings->defaults['tracking_number_header_text']);
|
115 |
-
|
116 |
-
$shipped_date_header_text = $ast->get_option_value_from_array('tracking_info_settings','shipped_date_header_text',$wcast_customizer_settings->defaults['shipped_date_header_text']);
|
117 |
-
|
118 |
-
$track_header_text = $ast->get_option_value_from_array('tracking_info_settings','track_header_text',$wcast_customizer_settings->defaults['track_header_text']);
|
119 |
-
|
120 |
-
$simple_layout_content = $ast->get_option_value_from_array('tracking_info_settings','simple_layout_content',$wcast_customizer_settings->defaults['simple_layout_content']);
|
121 |
-
|
122 |
-
$simple_provider_font_size = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_size',$wcast_customizer_settings->defaults['simple_provider_font_size']);
|
123 |
-
|
124 |
-
$simple_provider_font_color = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_color',$wcast_customizer_settings->defaults['simple_provider_font_color']);
|
125 |
-
|
126 |
-
$show_provider_border = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_provider_border',$wcast_customizer_settings->defaults['show_provider_border']);
|
127 |
-
|
128 |
-
$provider_border_color = $ast->get_option_value_from_array('tracking_info_settings','provider_border_color',$wcast_customizer_settings->defaults['provider_border_color']);
|
129 |
-
?>
|
130 |
-
|
131 |
-
<?php if($hide_trackig_header != 1){ ?>
|
132 |
<h2><?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?></h2>
|
133 |
<?php } ?>
|
134 |
|
135 |
<p><?php echo $shipment_tracking_header_text; ?></p>
|
136 |
|
137 |
<?php if($select_tracking_template == 'simple_list'){ ?>
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
143 |
-
$status = '';
|
144 |
-
|
145 |
-
if(isset($shipment_status[$key])){
|
146 |
-
if(isset($shipment_status[$key]['status'])){
|
147 |
-
$status = $shipment_status[$key]['status'];
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
$ts_tracking_page = $ast->check_ts_tracking_page_for_tracking_item( $order_id, $tracking_item, $status );
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
$provider_name = apply_filters('get_ast_provider_name', $tracking_provider, $results);
|
165 |
-
|
166 |
-
$url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']);
|
167 |
-
$simple_layout_content_updated = '';
|
168 |
-
?>
|
169 |
-
<li class="tracking_list_li">
|
170 |
-
<div class="tracking_list_div" style="font-size:<?php echo $simple_provider_font_size; ?>px;color:<?php echo $simple_provider_font_color; ?>;border-bottom:<?php echo $show_provider_border; ?>px solid <?php echo $provider_border_color; ?>">
|
171 |
-
<?php
|
172 |
-
$formatted_tracking_provider = apply_filters( 'ast_provider_title', esc_html( $provider_name ));
|
173 |
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
-
$
|
|
|
|
|
|
|
|
|
177 |
|
178 |
-
|
179 |
-
$tracking_number_link = '<a href="javascript:void(0)" class="open_tracking_lightbox" data-order="'.$order_id.'" data-tracking="'.$tracking_item['tracking_number'].'">'.$tracking_item['tracking_number'].'</a>';
|
180 |
-
} else{
|
181 |
-
$tracking_number_link = '<a target="_blank" href="'.esc_url( $url ).'">'.$tracking_item['tracking_number'].'</a>';
|
182 |
-
}
|
183 |
|
184 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
<th class="" style="<?php echo $th_column_style; ?>"><?php _e( $tracking_number_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
205 |
-
<?php if($remove_date_from_tracking_info != 1){ ?>
|
206 |
-
<th class="date-shipped" style="<?php echo $th_column_style; ?>"><?php _e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
207 |
-
<?php }
|
208 |
-
if(!$tracking_number_link){
|
209 |
-
?>
|
210 |
-
<th class="order-actions" style="<?php echo $th_column_style; ?>"><?php if($show_track_label == 1) { _e( $track_header_text, 'woo-advanced-shipment-tracking' ); }?></th>
|
211 |
-
<?php } ?>
|
212 |
-
</tr>
|
213 |
-
</thead>
|
214 |
<?php } ?>
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$status = '';
|
220 |
-
|
221 |
-
if(isset($shipment_status[$key])){
|
222 |
-
if(isset($shipment_status[$key]['status'])){
|
223 |
-
$status = $shipment_status[$key]['status'];
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
$ts_tracking_page = $ast->check_ts_tracking_page_for_tracking_item( $order_id, $tracking_item, $status );
|
228 |
-
|
229 |
-
global $wpdb;
|
230 |
-
|
231 |
-
$tracking_provider = isset( $tracking_item['tracking_provider'] ) ? $tracking_item['tracking_provider'] : $tracking_item['custom_tracking_provider'];
|
232 |
-
$tracking_provider = apply_filters('convert_provider_name_to_slug',$tracking_provider);
|
233 |
-
|
234 |
-
$results = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woo_shippment_provider WHERE ts_slug = %s", $tracking_provider ) );
|
235 |
-
|
236 |
-
$provider_name = apply_filters('get_ast_provider_name', $tracking_provider, $results);
|
237 |
-
?><tr class="tracking">
|
238 |
-
<?php if($display_thumbnail == 1){ ?>
|
239 |
-
<td class="tracking-provider" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>">
|
240 |
-
<img style="width: 50px;margin-right: 5px;vertical-align: middle;" src="<?php echo apply_filters('get_shipping_provdider_src',$results); ?>">
|
241 |
-
</td>
|
242 |
-
<?php } ?>
|
243 |
-
<?php if($display_shipping_provider_name == 1){ ?>
|
244 |
-
<td class="tracking-provider" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Provider Name', 'woo-advanced-shipment-tracking' ); ?>">
|
245 |
-
<?php echo apply_filters( 'ast_provider_title', esc_html( $provider_name )); ?>
|
246 |
-
</td>
|
247 |
-
<?php } ?>
|
248 |
-
<?php do_action("ast_tracking_my_account_body", $order_id,$tracking_item, $td_column_style); ?>
|
249 |
-
<td class="tracking-number" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>">
|
250 |
-
<?php if('' !== $tracking_item['formatted_tracking_link'] && $tracking_number_link){
|
251 |
-
$url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']);
|
252 |
-
if($ts_tracking_page){ ?>
|
253 |
-
<a href="javascript:void(0)" class="open_tracking_lightbox" data-order="<?php echo $order_id; ?>" data-tracking="<?php echo esc_html( $tracking_item['tracking_number'] ); ?>" style="<?php echo $tracking_link_style; ?>"><?php echo esc_html( $tracking_item['tracking_number'] ); ?></a>
|
254 |
-
<?php } else{ ?>
|
255 |
-
<a href="<?php echo esc_url( $url ); ?>" target="_blank" style="<?php echo $tracking_link_style; ?>"><?php echo esc_html( $tracking_item['tracking_number'] ); ?></a>
|
256 |
-
<?php }
|
257 |
-
} else{
|
258 |
-
echo esc_html( $tracking_item['tracking_number'] );
|
259 |
-
}
|
260 |
-
?>
|
261 |
-
</td>
|
262 |
-
<?php if($remove_date_from_tracking_info != 1){ ?>
|
263 |
-
<td class="date-shipped" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Date', 'woocommerce' ); ?>" style="text-align:left; white-space:nowrap;">
|
264 |
-
<time datetime="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>" title="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $tracking_item['date_shipped'] ); ?></time>
|
265 |
-
</td>
|
266 |
-
<?php } if(!$tracking_number_link){ ?>
|
267 |
-
<td class="order-actions" style="<?php echo $td_column_style; ?>;text-align:center;">
|
268 |
-
<?php if ( '' !== $tracking_item['formatted_tracking_link'] ) {
|
269 |
-
$url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']);
|
270 |
-
|
271 |
-
if($ts_tracking_page){ ?>
|
272 |
-
<a href="javascript:void(0)" class="button open_tracking_lightbox" data-order="<?php echo $order_id; ?>" data-tracking="<?php echo esc_html( $tracking_item['tracking_number'] ); ?>" style="<?php echo $tracking_link_style; ?>"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
|
273 |
-
<?php } else{ ?>
|
274 |
-
<a href="<?php echo esc_url( $url ); ?>" target="_blank" class="button" style="<?php echo $tracking_link_style; ?>"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
|
275 |
-
<?php } } ?>
|
276 |
-
</td>
|
277 |
-
<?php } ?>
|
278 |
-
</tr><?php
|
279 |
-
}
|
280 |
-
?></tbody>
|
281 |
-
</table>
|
282 |
-
<?php
|
283 |
-
}
|
284 |
if( !isset($show_shipment_status) ) $show_shipment_status = false;
|
285 |
-
|
286 |
-
?>
|
|
|
287 |
<div id="" class="popupwrapper ts_tracking_popup" style="display:none;">
|
288 |
<div class="popuprow">
|
289 |
|
14 |
*/
|
15 |
|
16 |
if ( $tracking_items ) :
|
17 |
+
$settings = new wcast_initialise_customizer_settings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
$ast = new WC_Advanced_Shipment_Tracking_Actions;
|
|
|
|
|
19 |
|
20 |
+
$select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$settings->defaults['select_tracking_template']);
|
21 |
|
22 |
$show_provider_th = 1;
|
23 |
$colspan = 1;
|
24 |
|
25 |
+
$display_thumbnail = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_image',$settings->defaults['display_shipment_provider_image']);
|
26 |
+
$display_shipping_provider_name = $ast->get_checkbox_option_value_from_array('tracking_info_settings','display_shipment_provider_name',$settings->defaults['display_shipment_provider_name']);
|
|
|
|
|
27 |
$tracking_number_link = $ast->get_checkbox_option_value_from_array('tracking_info_settings','tracking_number_link','');
|
28 |
|
29 |
if($display_shipping_provider_name == 1 && $display_thumbnail == 1){
|
42 |
$show_provider_th = 0;
|
43 |
}
|
44 |
|
45 |
+
$email_border_color = $ast->get_option_value_from_array('tracking_info_settings','table_border_color',$settings->defaults['table_border_color']);
|
46 |
+
$email_border_size = $ast->get_option_value_from_array('tracking_info_settings','table_border_size',$settings->defaults['table_border_size']);
|
|
|
|
|
47 |
$hide_trackig_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_trackig_header','');
|
|
|
48 |
$shipment_tracking_header = $ast->get_option_value_from_array('tracking_info_settings','header_text_change','Tracking Information');
|
|
|
49 |
$shipment_tracking_header_text = $ast->get_option_value_from_array('tracking_info_settings','additional_header_text','');
|
50 |
+
$email_table_backgroud_color = $ast->get_option_value_from_array('tracking_info_settings','table_bg_color',$settings->defaults['table_bg_color']);
|
51 |
+
$table_content_line_height = $ast->get_option_value_from_array('tracking_info_settings','table_content_line_height',$settings->defaults['table_content_line_height']);
|
52 |
+
$table_content_font_weight = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_weight',$settings->defaults['table_content_font_weight']);
|
53 |
+
$table_header_bg_color = $ast->get_option_value_from_array('tracking_info_settings','table_header_bg_color',$settings->defaults['table_header_bg_color']);
|
54 |
+
$table_header_font_size = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_size',$settings->defaults['table_header_font_size']);
|
55 |
+
$table_header_font_weight = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_weight',$settings->defaults['table_header_font_weight']);
|
56 |
+
$table_header_font_color = $ast->get_option_value_from_array('tracking_info_settings','table_header_font_color',$settings->defaults['table_header_font_color']);
|
57 |
+
$table_content_font_size = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_size',$settings->defaults['table_content_font_size']);
|
58 |
+
$table_content_font_color = $ast->get_option_value_from_array('tracking_info_settings','table_content_font_color',$settings->defaults['table_content_font_color']);
|
59 |
+
$tracking_link_font_color = $ast->get_option_value_from_array('tracking_info_settings','tracking_link_font_color',$settings->defaults['tracking_link_font_color']);
|
60 |
+
$tracking_link_bg_color = $ast->get_option_value_from_array('tracking_info_settings','tracking_link_bg_color',$settings->defaults['tracking_link_bg_color']);
|
61 |
+
$tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";margin-bottom: 0;";
|
62 |
+
$hide_table_header = $ast->get_checkbox_option_value_from_array('tracking_info_settings','hide_table_header','');
|
63 |
+
$remove_date_from_tracking_info = $ast->get_checkbox_option_value_from_array('tracking_info_settings','remove_date_from_tracking',$settings->defaults['remove_date_from_tracking']);
|
64 |
+
$show_track_label = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_track_label',$settings->defaults['show_track_label']);
|
65 |
+
$provider_header_text = $ast->get_option_value_from_array('tracking_info_settings','provider_header_text',$settings->defaults['provider_header_text']);
|
66 |
+
$tracking_number_header_text = $ast->get_option_value_from_array('tracking_info_settings','tracking_number_header_text',$settings->defaults['tracking_number_header_text']);
|
67 |
+
$shipped_date_header_text = $ast->get_option_value_from_array('tracking_info_settings','shipped_date_header_text',$settings->defaults['shipped_date_header_text']);
|
68 |
+
$track_header_text = $ast->get_option_value_from_array('tracking_info_settings','track_header_text',$settings->defaults['track_header_text']);
|
69 |
+
$simple_layout_content = $ast->get_option_value_from_array('tracking_info_settings','simple_layout_content',$settings->defaults['simple_layout_content']);
|
70 |
+
$simple_provider_font_size = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_size',$settings->defaults['simple_provider_font_size']);
|
71 |
+
$simple_provider_font_color = $ast->get_option_value_from_array('tracking_info_settings','simple_provider_font_color',$settings->defaults['simple_provider_font_color']);
|
72 |
+
$show_provider_border = $ast->get_checkbox_option_value_from_array('tracking_info_settings','show_provider_border',$settings->defaults['show_provider_border']);
|
73 |
+
$provider_border_color = $ast->get_option_value_from_array('tracking_info_settings','provider_border_color',$settings->defaults['provider_border_color']);
|
74 |
+
|
75 |
if(is_rtl()){
|
76 |
$header_content_text_align = 'right';
|
77 |
} else{
|
78 |
+
$header_content_text_align = $ast->get_option_value_from_array('tracking_info_settings','header_content_text_align',$settings->defaults['header_content_text_align']);
|
79 |
}
|
80 |
|
81 |
$th_column_style = "background:".$table_header_bg_color.";text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;font-weight:".$table_header_font_weight.";";
|
82 |
|
83 |
+
$td_column_style = "text-align: ".$header_content_text_align."; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px;font-weight:".$table_content_font_weight."; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;line-height: ".$table_content_line_height."px;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
+
if( $hide_trackig_header != 1 ){ ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
<h2><?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?></h2>
|
87 |
<?php } ?>
|
88 |
|
89 |
<p><?php echo $shipment_tracking_header_text; ?></p>
|
90 |
|
91 |
<?php if($select_tracking_template == 'simple_list'){ ?>
|
92 |
+
<div class="tracking_info">
|
93 |
+
<ul class="tracking_list">
|
94 |
+
<?php foreach ( $tracking_items as $key => $tracking_item ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
97 |
+
$status = '';
|
98 |
+
|
99 |
+
if(isset($shipment_status[$key])){
|
100 |
+
if(isset($shipment_status[$key]['status'])){
|
101 |
+
$status = $shipment_status[$key]['status'];
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
$ts_tracking_page = $ast->check_ts_tracking_page_for_tracking_item( $order_id, $tracking_item, $status );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
+
$date_shipped = ( isset( $tracking_item['date_shipped'] ) ) ? $tracking_item['date_shipped'] : date("Y-m-d");
|
108 |
+
|
109 |
+
$simple_layout_content_updated = ''; ?>
|
110 |
+
|
111 |
+
<li class="tracking_list_li">
|
112 |
+
<div class="tracking_list_div" style="font-size:<?php echo $simple_provider_font_size; ?>px;color:<?php echo $simple_provider_font_color; ?>;border-bottom:<?php echo $show_provider_border; ?>px solid <?php echo $provider_border_color; ?>">
|
113 |
+
<?php
|
114 |
+
|
115 |
+
$formatted_tracking_provider = apply_filters( 'ast_provider_title', esc_html( $tracking_item[ 'formatted_tracking_provider' ] ));
|
116 |
+
|
117 |
+
$simple_layout_content_updated = str_replace('{ship_date}',date_i18n( get_option( 'date_format' ), $date_shipped ),$simple_layout_content);
|
118 |
+
|
119 |
+
$simple_layout_content_updated = str_replace('{shipping_provider}',$formatted_tracking_provider,$simple_layout_content_updated);
|
120 |
+
|
121 |
+
if($ts_tracking_page){
|
122 |
+
$tracking_number_link = '<a href="javascript:void(0)" class="open_tracking_lightbox" data-order="'.$order_id.'" data-tracking="'.$tracking_item['tracking_number'].'">'.$tracking_item['tracking_number'].'</a>';
|
123 |
+
} else{
|
124 |
+
$tracking_number_link = '<a target="_blank" href="'.esc_url( $tracking_item['ast_tracking_link'] ).'">'.$tracking_item['tracking_number'].'</a>';
|
125 |
+
}
|
126 |
+
|
127 |
+
$simple_layout_content_updated = str_replace('{tracking_number_link}',$tracking_number_link,$simple_layout_content_updated);
|
128 |
+
|
129 |
+
echo $simple_layout_content_updated; ?>
|
130 |
+
</div>
|
131 |
+
<?php do_action("ast_tracking_simple_list_email_body", $order_id,$tracking_item); ?>
|
132 |
+
</li>
|
133 |
+
<?php } ?>
|
134 |
+
</ul>
|
135 |
+
</div>
|
136 |
+
<?php } else if( $select_tracking_template == 'default_table' ){ ?>
|
137 |
+
<table class="shop_table shop_table_responsive my_account_tracking" style="width: 100%;border-collapse: collapse;background:<?php echo $email_table_backgroud_color; ?>">
|
138 |
+
<?php if( $hide_table_header != 1 ){ ?>
|
139 |
+
<thead>
|
140 |
+
<tr>
|
141 |
+
<?php if( $show_provider_th ){ ?>
|
142 |
+
<th class="tracking-provider" colspan="<?php echo $colspan; ?>" style="<?php echo $th_column_style; ?>">
|
143 |
+
<?php _e( $provider_header_text, 'woo-advanced-shipment-tracking' ); ?>
|
144 |
+
</th>
|
145 |
+
<?php }
|
146 |
+
|
147 |
+
do_action("ast_tracking_my_acoount_header", $order_id, $th_column_style); ?>
|
148 |
+
|
149 |
+
<th class="" style="<?php echo $th_column_style; ?>"><?php _e( $tracking_number_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
150 |
+
|
151 |
+
<?php if($remove_date_from_tracking_info != 1){ ?>
|
152 |
+
<th class="date-shipped" style="<?php echo $th_column_style; ?>"><?php _e( $shipped_date_header_text, 'woo-advanced-shipment-tracking' ); ?></th>
|
153 |
+
<?php }
|
154 |
+
|
155 |
+
if(!$tracking_number_link){ ?>
|
156 |
+
<th class="order-actions" style="<?php echo $th_column_style; ?>"><?php if($show_track_label == 1) { _e( $track_header_text, 'woo-advanced-shipment-tracking' ); }?></th>
|
157 |
+
<?php } ?>
|
158 |
+
</tr>
|
159 |
+
</thead>
|
160 |
+
<?php } ?>
|
161 |
+
<tbody><?php
|
162 |
+
foreach ( $tracking_items as $key => $tracking_item ) {
|
163 |
+
|
164 |
+
$shipment_status = get_post_meta( $order_id, "shipment_status", true);
|
165 |
+
$status = '';
|
166 |
+
|
167 |
+
if(isset($shipment_status[$key])){
|
168 |
+
if(isset($shipment_status[$key]['status'])){
|
169 |
+
$status = $shipment_status[$key]['status'];
|
170 |
+
}
|
171 |
+
}
|
172 |
+
$date_shipped = ( isset( $tracking_item['date_shipped'] ) ) ? $tracking_item['date_shipped'] : date("Y-m-d");
|
173 |
+
|
174 |
+
$ts_tracking_page = $ast->check_ts_tracking_page_for_tracking_item( $order_id, $tracking_item, $status );
|
175 |
+
|
176 |
+
?>
|
177 |
+
|
178 |
+
<tr class="tracking">
|
179 |
+
<?php if($display_thumbnail == 1){ ?>
|
180 |
+
<td class="tracking-provider" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>">
|
181 |
+
<img style="width: 50px;margin-right: 5px;vertical-align: middle;" src="<?php echo esc_url( $tracking_item['tracking_provider_image'] ); ?>">
|
182 |
+
</td>
|
183 |
+
<?php } ?>
|
184 |
|
185 |
+
<?php if($display_shipping_provider_name == 1){ ?>
|
186 |
+
<td class="tracking-provider" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Provider Name', 'woo-advanced-shipment-tracking' ); ?>">
|
187 |
+
<?php echo apply_filters( 'ast_provider_title', esc_html( $tracking_item[ 'formatted_tracking_provider' ] )); ?>
|
188 |
+
</td>
|
189 |
+
<?php }
|
190 |
|
191 |
+
do_action("ast_tracking_my_account_body", $order_id,$tracking_item, $td_column_style); ?>
|
|
|
|
|
|
|
|
|
192 |
|
193 |
+
<td class="tracking-number" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>">
|
194 |
+
<?php if( '' !== $tracking_item['ast_tracking_link'] && $tracking_number_link ){
|
195 |
+
if( $ts_tracking_page ){ ?>
|
196 |
+
<a href="javascript:void(0)" class="open_tracking_lightbox" data-order="<?php echo $order_id; ?>" data-tracking="<?php echo esc_html( $tracking_item['tracking_number'] ); ?>" style="<?php echo $tracking_link_style; ?>"><?php echo esc_html( $tracking_item['tracking_number'] ); ?></a>
|
197 |
+
<?php } else{ ?>
|
198 |
+
<a href="<?php echo esc_url( $tracking_item['ast_tracking_link'] ); ?>" target="_blank" style="<?php echo $tracking_link_style; ?>"><?php echo esc_html( $tracking_item['tracking_number'] ); ?></a>
|
199 |
+
<?php }
|
200 |
+
} else{
|
201 |
+
echo esc_html( $tracking_item['tracking_number'] );
|
202 |
+
} ?>
|
203 |
+
</td>
|
204 |
|
205 |
+
<?php if($remove_date_from_tracking_info != 1){ ?>
|
206 |
+
<td class="date-shipped" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Date', 'woocommerce' ); ?>" style="text-align:left; white-space:nowrap;">
|
207 |
+
<time datetime="<?php echo date( 'Y-m-d', $date_shipped ); ?>" title="<?php echo date( 'Y-m-d', $date_shipped ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $date_shipped ); ?></time>
|
208 |
+
</td>
|
209 |
+
<?php }
|
210 |
+
|
211 |
+
if( !$tracking_number_link ){ ?>
|
212 |
+
<td class="order-actions" style="<?php echo $td_column_style; ?>;text-align:center;">
|
213 |
+
<?php if ( '' !== $tracking_item['ast_tracking_link'] ) {
|
214 |
+
|
215 |
+
if($ts_tracking_page){ ?>
|
216 |
+
<a href="javascript:void(0)" class="button open_tracking_lightbox" data-order="<?php echo $order_id; ?>" data-tracking="<?php echo esc_html( $tracking_item['tracking_number'] ); ?>" style="<?php echo $tracking_link_style; ?>"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
|
217 |
+
<?php } else{ ?>
|
218 |
+
<a href="<?php echo esc_url( $tracking_item['ast_tracking_link'] ); ?>" target="_blank" class="button" style="<?php echo $tracking_link_style; ?>"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
|
219 |
+
<?php } } ?>
|
220 |
+
</td>
|
221 |
+
<?php } ?>
|
222 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
<?php } ?>
|
224 |
+
</tbody>
|
225 |
+
</table>
|
226 |
+
<?php }
|
227 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
if( !isset($show_shipment_status) ) $show_shipment_status = false;
|
229 |
+
|
230 |
+
do_action( 'my_account_tracking_info_template' , $order_id, $tracking_items, $show_shipment_status ); ?>
|
231 |
+
|
232 |
<div id="" class="popupwrapper ts_tracking_popup" style="display:none;">
|
233 |
<div class="popuprow">
|
234 |
|
woocommerce-advanced-shipment-tracking.php
CHANGED
@@ -4,13 +4,13 @@
|
|
4 |
* Plugin Name: Advanced Shipment Tracking for WooCommerce
|
5 |
* Plugin URI: https://www.zorem.com/products/woocommerce-advanced-shipment-tracking/
|
6 |
* Description: Add shipment tracking information to your WooCommerce orders and provide customers with an easy way to track their orders. Shipment tracking Info will appear in customers accounts (in the order panel) and in WooCommerce order complete email.
|
7 |
-
* Version: 3.2.
|
8 |
* Author: zorem
|
9 |
* Author URI: https://www.zorem.com
|
10 |
* License: GPL-2.0+
|
11 |
* License URI:
|
12 |
* Text Domain: woo-advanced-shipment-tracking
|
13 |
-
* WC tested up to: 5.
|
14 |
*/
|
15 |
|
16 |
class zorem_woocommerce_advanced_shipment_tracking {
|
@@ -20,7 +20,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
20 |
*
|
21 |
* @var string
|
22 |
*/
|
23 |
-
public $version = '3.2.
|
24 |
|
25 |
/**
|
26 |
* Initialize the main plugin function
|
@@ -28,28 +28,33 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
28 |
public function __construct() {
|
29 |
|
30 |
$this->plugin_file = __FILE__;
|
31 |
-
// Add your templates to this array.
|
32 |
|
33 |
-
|
|
|
34 |
|
35 |
global $wpdb;
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
39 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
40 |
}
|
|
|
41 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
42 |
-
$main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
|
43 |
-
$this->table = $main_blog_prefix.
|
44 |
-
} else{
|
45 |
-
$this->table = $wpdb->prefix.
|
46 |
}
|
47 |
|
48 |
-
} else{
|
49 |
-
$this->table = $wpdb->prefix.
|
50 |
}
|
51 |
|
52 |
if ( $this->is_wc_active() ) {
|
|
|
53 |
// Include required files.
|
54 |
$this->includes();
|
55 |
|
@@ -73,7 +78,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
73 |
|
74 |
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
|
75 |
|
76 |
-
if(!class_exists('trackship_for_woocommerce')){
|
77 |
$this->late_shipments->init();
|
78 |
$this->trackship->init();
|
79 |
}
|
@@ -84,9 +89,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
-
* Check if WooCommerce is active
|
88 |
-
*
|
89 |
-
* @access private
|
90 |
* @since 1.0.0
|
91 |
* @return bool
|
92 |
*/
|
@@ -110,15 +113,15 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
-
* Display WC active notice
|
114 |
-
*
|
115 |
-
* @access public
|
116 |
* @since 1.0.0
|
117 |
*/
|
118 |
public function notice_activate_wc() {
|
119 |
?>
|
120 |
<div class="error">
|
121 |
-
<p><?php
|
|
|
|
|
122 |
</div>
|
123 |
<?php
|
124 |
}
|
@@ -126,15 +129,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
126 |
/*
|
127 |
* init when class loaded
|
128 |
*/
|
129 |
-
public function init(){
|
130 |
|
131 |
-
add_action( 'init', array( $this, 'wst_load_textdomain'));
|
132 |
-
register_activation_hook( __FILE__, array( $this->install, 'woo_shippment_tracking_install' ));
|
133 |
|
134 |
add_action( 'add_meta_boxes', array( $this->actions, 'add_meta_box' ) );
|
135 |
add_action( 'woocommerce_view_order', array( $this->actions, 'show_tracking_info_order' ) );
|
136 |
-
|
137 |
-
//add_filter( 'woocommerce_my_account_my_orders_columns', array( $this->actions, 'add_column_my_account_orders' ) );
|
138 |
add_action( 'woocommerce_my_account_my_orders_actions', array( $this->actions, 'add_column_my_account_orders_ast_track_column' ),10, 2 );
|
139 |
|
140 |
add_action( 'wp_ajax_wc_shipment_tracking_delete_item', array( $this->actions, 'meta_box_delete_tracking' ) );
|
@@ -143,17 +145,13 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
143 |
|
144 |
add_action( 'wp_ajax_reassign_order_status', array( $this, 'reassign_order_status' ) );
|
145 |
|
146 |
-
|
147 |
-
$preview = true;
|
148 |
-
} else{
|
149 |
-
$preview = false;
|
150 |
-
}
|
151 |
|
152 |
-
if(!$preview){
|
153 |
$tracking_info_settings = get_option('tracking_info_settings');
|
154 |
-
if(isset($tracking_info_settings['display_tracking_info_at']) && $tracking_info_settings['display_tracking_info_at']
|
155 |
add_action( 'woocommerce_email_order_meta', array( $this->actions, 'email_display' ), 0, 4 );
|
156 |
-
} else{
|
157 |
add_action( 'woocommerce_email_before_order_table', array( $this->actions, 'email_display' ), 0, 4 );
|
158 |
}
|
159 |
}
|
@@ -162,58 +160,59 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
162 |
add_filter( 'manage_shop_order_posts_columns', array( $this->actions, 'shop_order_columns' ), 99 );
|
163 |
add_action( 'manage_shop_order_posts_custom_column', array( $this->actions, 'render_shop_order_columns' ) );
|
164 |
|
165 |
-
add_action('admin_footer', array( $this->actions, 'custom_validation_js'));
|
166 |
|
167 |
add_action( 'wp_ajax_add_inline_tracking_number', array( $this->actions, 'save_inline_tracking_number' ) );
|
168 |
|
169 |
-
add_filter( 'get_ast_provider_name', array( $this->actions, 'get_ast_provider_name_callback' ),10,2 );
|
170 |
-
add_filter( 'get_shipping_provdider_src', array( $this->actions, 'get_shipping_provdider_src_callback' ));
|
171 |
|
172 |
//load css js
|
173 |
add_action( 'admin_enqueue_scripts', array( $this->admin, 'admin_styles' ), 4);
|
174 |
|
175 |
//Custom Woocomerce menu
|
176 |
-
add_action('admin_menu', array( $this->admin, 'register_woocommerce_menu' ), 99 );
|
177 |
|
178 |
//ajax save admin api settings
|
179 |
add_action( 'wp_ajax_wc_ast_settings_form_update', array( $this->admin, 'wc_ast_settings_form_update_callback' ) );
|
180 |
|
181 |
-
add_action( 'wp_ajax_wc_ast_custom_order_status_form_update', array( $this->admin, 'wc_ast_custom_order_status_form_update') );
|
182 |
|
183 |
-
$wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
|
184 |
-
if($wc_ast_status_partial_shipped
|
185 |
-
|
|
|
186 |
|
187 |
-
$wc_ast_status_updated_tracking = get_option('wc_ast_status_updated_tracking');
|
188 |
-
if($wc_ast_status_updated_tracking
|
189 |
-
|
|
|
190 |
|
191 |
-
if(!class_exists('trackship_for_woocommerce')){
|
192 |
add_action( 'template_redirect', array( $this->front, 'preview_tracking_page') );
|
193 |
}
|
|
|
|
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
-
* Send email when order status change to
|
198 |
-
*
|
199 |
*/
|
200 |
-
public function email_trigger_partial_shipped($order_id, $order = false){
|
201 |
require_once( 'includes/email-manager.php' );
|
202 |
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
-
* Send email when order status change to
|
207 |
-
*
|
208 |
*/
|
209 |
-
public function email_trigger_updated_tracking($order_id, $order = false){
|
210 |
require_once( 'includes/email-manager.php' );
|
211 |
WC()->mailer()->emails['WC_Email_Customer_Updated_Tracking_Order']->trigger( $order_id, $order );
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
-
* Init advanced shipment tracking REST API.
|
216 |
-
*
|
217 |
*/
|
218 |
private function init_rest_api() {
|
219 |
add_action( 'rest_api_init', array( $this, 'rest_api_register_routes' ) );
|
@@ -276,10 +275,9 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
276 |
* @return mixed
|
277 |
*/
|
278 |
public function get_shipping_providers( $output = OBJECT ) {
|
279 |
-
global $wpdb;
|
280 |
-
$woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
|
281 |
return $wpdb->get_results( "
|
282 |
-
SELECT * FROM {$
|
283 |
WHERE shipping_default = 0
|
284 |
ORDER BY id ASC
|
285 |
", $output );
|
@@ -288,7 +286,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
288 |
/*
|
289 |
* include files
|
290 |
*/
|
291 |
-
private function includes(){
|
292 |
|
293 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking.php';
|
294 |
$this->actions = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
@@ -308,7 +306,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
308 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-license.php';
|
309 |
$this->license = WC_Advanced_Shipment_Tracking_License::get_instance();
|
310 |
|
311 |
-
if(!class_exists('trackship_for_woocommerce')){
|
312 |
|
313 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-late-shipments.php';
|
314 |
$this->late_shipments = WC_Advanced_Shipment_Tracking_Late_Shipments::get_instance();
|
@@ -323,10 +321,6 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
323 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-api-call.php';
|
324 |
}
|
325 |
|
326 |
-
|
327 |
-
//cron function
|
328 |
-
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-cron.php';
|
329 |
-
|
330 |
require_once $this->get_plugin_path() . '/includes/email-manager.php';
|
331 |
}
|
332 |
|
@@ -336,6 +330,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
336 |
* @since 1.5.0
|
337 |
*/
|
338 |
public function rest_api_register_routes() {
|
|
|
339 |
if ( ! is_a( WC()->api, 'WC_API' ) ) {
|
340 |
return;
|
341 |
}
|
@@ -361,8 +356,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
361 |
|
362 |
$shipment_api_controller_v3 = new WC_Advanced_Shipment_Tracking_REST_API_Controller();
|
363 |
$shipment_api_controller_v3->set_namespace( 'wc-shipment-tracking/v3' );
|
364 |
-
$shipment_api_controller_v3->register_routes();
|
365 |
-
|
366 |
}
|
367 |
|
368 |
/*
|
@@ -373,9 +367,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
373 |
|
374 |
require_once $this->get_plugin_path() . '/includes/customizer/class-wcast-customizer.php';
|
375 |
|
376 |
-
require_once $this->get_plugin_path() . '/includes/customizer/class-wc-tracking-info-customizer.php';
|
377 |
-
|
378 |
-
//require_once $this->get_plugin_path() . '/includes/customizer/class-wc-email-customizer.php';
|
379 |
|
380 |
require_once $this->get_plugin_path() . '/includes/customizer/class-wc-partial-shipped-email-customizer.php';
|
381 |
|
@@ -389,17 +381,17 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
389 |
/*
|
390 |
* return plugin directory URL
|
391 |
*/
|
392 |
-
public function plugin_dir_url(){
|
393 |
return plugin_dir_url( __FILE__ );
|
394 |
}
|
395 |
|
396 |
/*
|
397 |
* Plugin uninstall code
|
398 |
*/
|
399 |
-
public function uninstall_notice(){
|
400 |
$screen = get_current_screen();
|
401 |
|
402 |
-
if(
|
403 |
wp_enqueue_style( 'ast_styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/admin.css', array(), wc_advanced_shipment_tracking()->version );
|
404 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
405 |
wp_enqueue_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
@@ -407,15 +399,16 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
407 |
|
408 |
$delivered_count = wc_orders_count( 'delivered' );
|
409 |
$ps_count = wc_orders_count( 'partial-shipped' );
|
410 |
-
$ut_count = wc_orders_count( 'updated-tracking' );
|
411 |
|
412 |
$order_statuses = wc_get_order_statuses();
|
413 |
|
414 |
-
unset($order_statuses['wc-partial-shipped']);
|
415 |
-
unset($order_statuses['wc-updated-tracking']);
|
416 |
-
unset($order_statuses['wc-delivered']);
|
417 |
|
418 |
-
if($delivered_count > 0 || $ps_count > 0 || $ut_count > 0){
|
|
|
419 |
|
420 |
<script>
|
421 |
|
@@ -467,10 +460,15 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
467 |
</div>
|
468 |
<div class="popup_body">
|
469 |
<form method="post" id="order_reassign_form">
|
470 |
-
<?php
|
471 |
-
|
472 |
-
|
473 |
|
|
|
|
|
|
|
|
|
|
|
474 |
<select id="reassign_delivered_order" name="reassign_delivered_order" class="reassign_select">
|
475 |
<option value=""><?php _e('Select', 'woocommerce'); ?></option>
|
476 |
<?php foreach($order_statuses as $key => $status){ ?>
|
@@ -478,10 +476,15 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
478 |
<?php } ?>
|
479 |
</select>
|
480 |
|
481 |
-
<?php }
|
482 |
-
|
483 |
-
|
484 |
-
|
|
|
|
|
|
|
|
|
|
|
485 |
|
486 |
<select id="reassign_ps_order" name="reassign_ps_order" class="reassign_select">
|
487 |
<option value=""><?php _e('Select', 'woocommerce'); ?></option>
|
@@ -490,11 +493,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
490 |
<?php } ?>
|
491 |
</select>
|
492 |
|
493 |
-
<?php }
|
494 |
-
|
495 |
-
|
496 |
-
<p><?php
|
497 |
-
|
|
|
|
|
|
|
498 |
<select id="reassign_ut_order" name="reassign_ut_order" class="reassign_select">
|
499 |
<option value=""><?php _e('Select', 'woocommerce'); ?></option>
|
500 |
<?php foreach($order_statuses as $key => $status){ ?>
|
@@ -505,7 +511,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
505 |
<?php } ?>
|
506 |
<p>
|
507 |
<input type="hidden" name="action" value="reassign_order_status">
|
508 |
-
<input type="button" value="Uninstall" class="uninstall_plugin button-primary
|
509 |
<input type="button" value="Close" class="uninstall_close button-primary btn_red">
|
510 |
</p>
|
511 |
</form>
|
@@ -516,12 +522,16 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
516 |
<?php }
|
517 |
}
|
518 |
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
|
|
|
|
|
|
|
|
523 |
|
524 |
-
if($reassign_delivered_order
|
525 |
|
526 |
$args = array(
|
527 |
'status' => 'delivered',
|
@@ -530,14 +540,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
530 |
|
531 |
$orders = wc_get_orders( $args );
|
532 |
|
533 |
-
foreach($orders as $order){
|
534 |
$order_id = $order->get_id();
|
535 |
-
$order = new WC_Order($order_id);
|
536 |
-
$order->update_status($reassign_delivered_order);
|
537 |
}
|
538 |
}
|
539 |
|
540 |
-
if($reassign_ps_order
|
541 |
|
542 |
$args = array(
|
543 |
'status' => 'partial-shipped',
|
@@ -546,14 +556,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
546 |
|
547 |
$ps_orders = wc_get_orders( $args );
|
548 |
|
549 |
-
foreach($ps_orders as $order){
|
550 |
$order_id = $order->get_id();
|
551 |
-
$order = new WC_Order($order_id);
|
552 |
-
$order->update_status($reassign_ps_order);
|
553 |
}
|
554 |
}
|
555 |
|
556 |
-
if($reassign_ut_order
|
557 |
|
558 |
$args = array(
|
559 |
'status' => 'updated-tracking',
|
@@ -562,13 +572,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
562 |
|
563 |
$ut_orders = wc_get_orders( $args );
|
564 |
|
565 |
-
foreach($ut_orders as $order){
|
566 |
$order_id = $order->get_id();
|
567 |
-
$order = new WC_Order($order_id);
|
568 |
-
$order->update_status($reassign_ut_order);
|
569 |
}
|
570 |
}
|
571 |
-
echo 1;
|
|
|
572 |
}
|
573 |
|
574 |
/**
|
@@ -581,11 +592,10 @@ class zorem_woocommerce_advanced_shipment_tracking {
|
|
581 |
* @param array $links List of existing plugin action links.
|
582 |
* @return array List of modified plugin action links.
|
583 |
*/
|
584 |
-
function ast_plugin_action_links( $links ) {
|
585 |
-
|
586 |
'<a href="' . esc_url( admin_url( '/admin.php?page=woocommerce-advanced-shipment-tracking' ) ) . '">' . __( 'Settings' ) . '</a>'
|
587 |
-
), $links );
|
588 |
-
return $links;
|
589 |
}
|
590 |
}
|
591 |
|
4 |
* Plugin Name: Advanced Shipment Tracking for WooCommerce
|
5 |
* Plugin URI: https://www.zorem.com/products/woocommerce-advanced-shipment-tracking/
|
6 |
* Description: Add shipment tracking information to your WooCommerce orders and provide customers with an easy way to track their orders. Shipment tracking Info will appear in customers accounts (in the order panel) and in WooCommerce order complete email.
|
7 |
+
* Version: 3.2.2
|
8 |
* Author: zorem
|
9 |
* Author URI: https://www.zorem.com
|
10 |
* License: GPL-2.0+
|
11 |
* License URI:
|
12 |
* Text Domain: woo-advanced-shipment-tracking
|
13 |
+
* WC tested up to: 5.1.0
|
14 |
*/
|
15 |
|
16 |
class zorem_woocommerce_advanced_shipment_tracking {
|
20 |
*
|
21 |
* @var string
|
22 |
*/
|
23 |
+
public $version = '3.2.2';
|
24 |
|
25 |
/**
|
26 |
* Initialize the main plugin function
|
28 |
public function __construct() {
|
29 |
|
30 |
$this->plugin_file = __FILE__;
|
|
|
31 |
|
32 |
+
// Add your templates to this array.
|
33 |
+
if (!defined('SHIPMENT_TRACKING_PATH')) define( 'SHIPMENT_TRACKING_PATH', $this->get_plugin_path());
|
34 |
|
35 |
global $wpdb;
|
36 |
+
|
37 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
38 |
+
|
39 |
+
if( is_multisite() ) {
|
40 |
+
|
41 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
42 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
43 |
}
|
44 |
+
|
45 |
if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
|
46 |
+
$main_blog_prefix = $wpdb->get_blog_prefix( BLOG_ID_CURRENT_SITE );
|
47 |
+
$this->table = $main_blog_prefix . 'woo_shippment_provider';
|
48 |
+
} else {
|
49 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
50 |
}
|
51 |
|
52 |
+
} else {
|
53 |
+
$this->table = $wpdb->prefix . 'woo_shippment_provider';
|
54 |
}
|
55 |
|
56 |
if ( $this->is_wc_active() ) {
|
57 |
+
|
58 |
// Include required files.
|
59 |
$this->includes();
|
60 |
|
78 |
|
79 |
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
|
80 |
|
81 |
+
if( !class_exists( 'trackship_for_woocommerce' ) ) {
|
82 |
$this->late_shipments->init();
|
83 |
$this->trackship->init();
|
84 |
}
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
+
* Check if WooCommerce is active
|
|
|
|
|
93 |
* @since 1.0.0
|
94 |
* @return bool
|
95 |
*/
|
113 |
}
|
114 |
|
115 |
/**
|
116 |
+
* Display WC active notice
|
|
|
|
|
117 |
* @since 1.0.0
|
118 |
*/
|
119 |
public function notice_activate_wc() {
|
120 |
?>
|
121 |
<div class="error">
|
122 |
+
<p><?php
|
123 |
+
/* translators: %s: search WooCommerce plugin link */
|
124 |
+
printf( esc_html__( 'Please install and activate %1$sWooCommerce%2$s for Advanced Shipment Tracking for WooCommerce!', 'woo-advanced-shipment-tracking' ), '<a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=WooCommerce&plugin-search-input=Search+Plugins' ) ) . '">', '</a>' ); ?></p>
|
125 |
</div>
|
126 |
<?php
|
127 |
}
|
129 |
/*
|
130 |
* init when class loaded
|
131 |
*/
|
132 |
+
public function init() {
|
133 |
|
134 |
+
add_action( 'init', array( $this, 'wst_load_textdomain') );
|
135 |
+
register_activation_hook( __FILE__, array( $this->install, 'woo_shippment_tracking_install' ) );
|
136 |
|
137 |
add_action( 'add_meta_boxes', array( $this->actions, 'add_meta_box' ) );
|
138 |
add_action( 'woocommerce_view_order', array( $this->actions, 'show_tracking_info_order' ) );
|
139 |
+
|
|
|
140 |
add_action( 'woocommerce_my_account_my_orders_actions', array( $this->actions, 'add_column_my_account_orders_ast_track_column' ),10, 2 );
|
141 |
|
142 |
add_action( 'wp_ajax_wc_shipment_tracking_delete_item', array( $this->actions, 'meta_box_delete_tracking' ) );
|
145 |
|
146 |
add_action( 'wp_ajax_reassign_order_status', array( $this, 'reassign_order_status' ) );
|
147 |
|
148 |
+
$preview = isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview'] ? true : false ;
|
|
|
|
|
|
|
|
|
149 |
|
150 |
+
if ( !$preview ) {
|
151 |
$tracking_info_settings = get_option('tracking_info_settings');
|
152 |
+
if( isset( $tracking_info_settings['display_tracking_info_at'] ) && 'after_order' == $tracking_info_settings['display_tracking_info_at'] ) {
|
153 |
add_action( 'woocommerce_email_order_meta', array( $this->actions, 'email_display' ), 0, 4 );
|
154 |
+
} else {
|
155 |
add_action( 'woocommerce_email_before_order_table', array( $this->actions, 'email_display' ), 0, 4 );
|
156 |
}
|
157 |
}
|
160 |
add_filter( 'manage_shop_order_posts_columns', array( $this->actions, 'shop_order_columns' ), 99 );
|
161 |
add_action( 'manage_shop_order_posts_custom_column', array( $this->actions, 'render_shop_order_columns' ) );
|
162 |
|
163 |
+
add_action( 'admin_footer', array( $this->actions, 'custom_validation_js') );
|
164 |
|
165 |
add_action( 'wp_ajax_add_inline_tracking_number', array( $this->actions, 'save_inline_tracking_number' ) );
|
166 |
|
167 |
+
add_filter( 'get_ast_provider_name', array( $this->actions, 'get_ast_provider_name_callback' ), 10, 2 );
|
168 |
+
add_filter( 'get_shipping_provdider_src', array( $this->actions, 'get_shipping_provdider_src_callback' ) );
|
169 |
|
170 |
//load css js
|
171 |
add_action( 'admin_enqueue_scripts', array( $this->admin, 'admin_styles' ), 4);
|
172 |
|
173 |
//Custom Woocomerce menu
|
174 |
+
add_action( 'admin_menu', array( $this->admin, 'register_woocommerce_menu' ), 99 );
|
175 |
|
176 |
//ajax save admin api settings
|
177 |
add_action( 'wp_ajax_wc_ast_settings_form_update', array( $this->admin, 'wc_ast_settings_form_update_callback' ) );
|
178 |
|
179 |
+
add_action( 'wp_ajax_wc_ast_custom_order_status_form_update', array( $this->admin, 'wc_ast_custom_order_status_form_update' ) );
|
180 |
|
181 |
+
$wc_ast_status_partial_shipped = get_option( 'wc_ast_status_partial_shipped' );
|
182 |
+
if ( $wc_ast_status_partial_shipped ) {
|
183 |
+
add_action( 'woocommerce_order_status_partial-shipped', array( $this, 'email_trigger_partial_shipped' ), 10, 2 );
|
184 |
+
}
|
185 |
|
186 |
+
$wc_ast_status_updated_tracking = get_option( 'wc_ast_status_updated_tracking' );
|
187 |
+
if ( $wc_ast_status_updated_tracking ) {
|
188 |
+
add_action( 'woocommerce_order_status_updated-tracking', array( $this, 'email_trigger_updated_tracking' ), 10, 2 );
|
189 |
+
}
|
190 |
|
191 |
+
if ( !class_exists( 'trackship_for_woocommerce' ) ) {
|
192 |
add_action( 'template_redirect', array( $this->front, 'preview_tracking_page') );
|
193 |
}
|
194 |
+
|
195 |
+
add_action( 'ast_add_tracking_btn', array( $this->actions, 'ast_add_tracking_btn' ) );
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
+
* Send email when order status change to 'Partial Shipped'
|
|
|
200 |
*/
|
201 |
+
public function email_trigger_partial_shipped( $order_id, $order = false ) {
|
202 |
require_once( 'includes/email-manager.php' );
|
203 |
WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
* Send email when order status change to 'Updated Tracking'
|
|
|
208 |
*/
|
209 |
+
public function email_trigger_updated_tracking( $order_id, $order = false ) {
|
210 |
require_once( 'includes/email-manager.php' );
|
211 |
WC()->mailer()->emails['WC_Email_Customer_Updated_Tracking_Order']->trigger( $order_id, $order );
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
+
* Init advanced shipment tracking REST API.
|
|
|
216 |
*/
|
217 |
private function init_rest_api() {
|
218 |
add_action( 'rest_api_init', array( $this, 'rest_api_register_routes' ) );
|
275 |
* @return mixed
|
276 |
*/
|
277 |
public function get_shipping_providers( $output = OBJECT ) {
|
278 |
+
global $wpdb;
|
|
|
279 |
return $wpdb->get_results( "
|
280 |
+
SELECT * FROM {$this->table}
|
281 |
WHERE shipping_default = 0
|
282 |
ORDER BY id ASC
|
283 |
", $output );
|
286 |
/*
|
287 |
* include files
|
288 |
*/
|
289 |
+
private function includes() {
|
290 |
|
291 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking.php';
|
292 |
$this->actions = WC_Advanced_Shipment_Tracking_Actions::get_instance();
|
306 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-license.php';
|
307 |
$this->license = WC_Advanced_Shipment_Tracking_License::get_instance();
|
308 |
|
309 |
+
if ( !class_exists( 'trackship_for_woocommerce' ) ) {
|
310 |
|
311 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-late-shipments.php';
|
312 |
$this->late_shipments = WC_Advanced_Shipment_Tracking_Late_Shipments::get_instance();
|
321 |
require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-api-call.php';
|
322 |
}
|
323 |
|
|
|
|
|
|
|
|
|
324 |
require_once $this->get_plugin_path() . '/includes/email-manager.php';
|
325 |
}
|
326 |
|
330 |
* @since 1.5.0
|
331 |
*/
|
332 |
public function rest_api_register_routes() {
|
333 |
+
|
334 |
if ( ! is_a( WC()->api, 'WC_API' ) ) {
|
335 |
return;
|
336 |
}
|
356 |
|
357 |
$shipment_api_controller_v3 = new WC_Advanced_Shipment_Tracking_REST_API_Controller();
|
358 |
$shipment_api_controller_v3->set_namespace( 'wc-shipment-tracking/v3' );
|
359 |
+
$shipment_api_controller_v3->register_routes();
|
|
|
360 |
}
|
361 |
|
362 |
/*
|
367 |
|
368 |
require_once $this->get_plugin_path() . '/includes/customizer/class-wcast-customizer.php';
|
369 |
|
370 |
+
require_once $this->get_plugin_path() . '/includes/customizer/class-wc-tracking-info-customizer.php';
|
|
|
|
|
371 |
|
372 |
require_once $this->get_plugin_path() . '/includes/customizer/class-wc-partial-shipped-email-customizer.php';
|
373 |
|
381 |
/*
|
382 |
* return plugin directory URL
|
383 |
*/
|
384 |
+
public function plugin_dir_url() {
|
385 |
return plugin_dir_url( __FILE__ );
|
386 |
}
|
387 |
|
388 |
/*
|
389 |
* Plugin uninstall code
|
390 |
*/
|
391 |
+
public function uninstall_notice() {
|
392 |
$screen = get_current_screen();
|
393 |
|
394 |
+
if ( 'plugins.php' == $screen->parent_file ) {
|
395 |
wp_enqueue_style( 'ast_styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/admin.css', array(), wc_advanced_shipment_tracking()->version );
|
396 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
397 |
wp_enqueue_script( 'jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true );
|
399 |
|
400 |
$delivered_count = wc_orders_count( 'delivered' );
|
401 |
$ps_count = wc_orders_count( 'partial-shipped' );
|
402 |
+
$ut_count = wc_orders_count( 'updated-tracking' );
|
403 |
|
404 |
$order_statuses = wc_get_order_statuses();
|
405 |
|
406 |
+
unset( $order_statuses['wc-partial-shipped'] );
|
407 |
+
unset( $order_statuses['wc-updated-tracking'] );
|
408 |
+
unset( $order_statuses['wc-delivered'] );
|
409 |
|
410 |
+
if( $delivered_count > 0 || $ps_count > 0 || $ut_count > 0 ) {
|
411 |
+
?>
|
412 |
|
413 |
<script>
|
414 |
|
460 |
</div>
|
461 |
<div class="popup_body">
|
462 |
<form method="post" id="order_reassign_form">
|
463 |
+
<?php
|
464 |
+
if ( $delivered_count > 0 ) {
|
465 |
+
?>
|
466 |
|
467 |
+
<p><?php
|
468 |
+
/* translators: %s: replace with delivered order count */
|
469 |
+
printf( esc_html__('We detected %s orders that use the Delivered order status, You can reassign these orders to a different status', 'woo-advanced-shipment-tracking'), $delivered_count );
|
470 |
+
?>
|
471 |
+
</p>
|
472 |
<select id="reassign_delivered_order" name="reassign_delivered_order" class="reassign_select">
|
473 |
<option value=""><?php _e('Select', 'woocommerce'); ?></option>
|
474 |
<?php foreach($order_statuses as $key => $status){ ?>
|
476 |
<?php } ?>
|
477 |
</select>
|
478 |
|
479 |
+
<?php }
|
480 |
+
|
481 |
+
if ( $ps_count > 0 ) {
|
482 |
+
?>
|
483 |
+
<p><?php
|
484 |
+
/* translators: %s: replace with Partially Shipped order count */
|
485 |
+
printf( esc_html__('We detected %s orders that use the Partially Shipped order status, You can reassign these orders to a different status', 'woo-advanced-shipment-tracking'), $ps_count );
|
486 |
+
?>
|
487 |
+
</p>
|
488 |
|
489 |
<select id="reassign_ps_order" name="reassign_ps_order" class="reassign_select">
|
490 |
<option value=""><?php _e('Select', 'woocommerce'); ?></option>
|
493 |
<?php } ?>
|
494 |
</select>
|
495 |
|
496 |
+
<?php }
|
497 |
+
if( $ut_count > 0 ){
|
498 |
+
?>
|
499 |
+
<p><?php
|
500 |
+
/* translators: %s: replace with Updated Tracking order count */
|
501 |
+
printf( esc_html__('We detected %s orders that use the Updated Tracking order status, You can reassign these orders to a different status', 'woo-advanced-shipment-tracking'), $ut_count );
|
502 |
+
?>
|
503 |
+
</p>
|
504 |
<select id="reassign_ut_order" name="reassign_ut_order" class="reassign_select">
|
505 |
<option value=""><?php _e('Select', 'woocommerce'); ?></option>
|
506 |
<?php foreach($order_statuses as $key => $status){ ?>
|
511 |
<?php } ?>
|
512 |
<p>
|
513 |
<input type="hidden" name="action" value="reassign_order_status">
|
514 |
+
<input type="button" value="Uninstall" class="uninstall_plugin button-primary btn_ast2">
|
515 |
<input type="button" value="Close" class="uninstall_close button-primary btn_red">
|
516 |
</p>
|
517 |
</form>
|
522 |
<?php }
|
523 |
}
|
524 |
|
525 |
+
/*
|
526 |
+
* Functon for reassign order status on plugin deactivation
|
527 |
+
*/
|
528 |
+
public function reassign_order_status() {
|
529 |
+
|
530 |
+
$reassign_delivered_order = isset( $_POST['reassign_delivered_order'] ) ? wc_clean( $_POST['reassign_delivered_order'] ) : '';
|
531 |
+
$reassign_ps_order = isset( $_POST['reassign_ps_order'] ) ? wc_clean( $_POST['reassign_ps_order'] ) : '';
|
532 |
+
$reassign_ut_order = isset( $_POST['reassign_ut_order'] ) ? wc_clean( $_POST['reassign_ut_order'] ) : '';
|
533 |
|
534 |
+
if ( '' != $reassign_delivered_order ) {
|
535 |
|
536 |
$args = array(
|
537 |
'status' => 'delivered',
|
540 |
|
541 |
$orders = wc_get_orders( $args );
|
542 |
|
543 |
+
foreach ( $orders as $order ) {
|
544 |
$order_id = $order->get_id();
|
545 |
+
$order = new WC_Order( $order_id );
|
546 |
+
$order->update_status( $reassign_delivered_order );
|
547 |
}
|
548 |
}
|
549 |
|
550 |
+
if ( '' != $reassign_ps_order ) {
|
551 |
|
552 |
$args = array(
|
553 |
'status' => 'partial-shipped',
|
556 |
|
557 |
$ps_orders = wc_get_orders( $args );
|
558 |
|
559 |
+
foreach ( $ps_orders as $order ) {
|
560 |
$order_id = $order->get_id();
|
561 |
+
$order = new WC_Order( $order_id );
|
562 |
+
$order->update_status( $reassign_ps_order );
|
563 |
}
|
564 |
}
|
565 |
|
566 |
+
if( '' != $reassign_ut_order ){
|
567 |
|
568 |
$args = array(
|
569 |
'status' => 'updated-tracking',
|
572 |
|
573 |
$ut_orders = wc_get_orders( $args );
|
574 |
|
575 |
+
foreach ( $ut_orders as $order ) {
|
576 |
$order_id = $order->get_id();
|
577 |
+
$order = new WC_Order( $order_id );
|
578 |
+
$order->update_status( $reassign_ut_order );
|
579 |
}
|
580 |
}
|
581 |
+
echo 1;
|
582 |
+
die();
|
583 |
}
|
584 |
|
585 |
/**
|
592 |
* @param array $links List of existing plugin action links.
|
593 |
* @return array List of modified plugin action links.
|
594 |
*/
|
595 |
+
public function ast_plugin_action_links ( $links ) {
|
596 |
+
return array_merge( array(
|
597 |
'<a href="' . esc_url( admin_url( '/admin.php?page=woocommerce-advanced-shipment-tracking' ) ) . '">' . __( 'Settings' ) . '</a>'
|
598 |
+
), $links );
|
|
|
599 |
}
|
600 |
}
|
601 |
|