diff --git a/cbwct.php b/cbwct.php new file mode 100644 index 0000000..93e83d5 --- /dev/null +++ b/cbwct.php @@ -0,0 +1,38 @@ + admin_url('admin-ajax.php')) ); +} +add_action('wp_enqueue_scripts','cbwct_basic_scripts'); +//Include additional file +require_once( CBWCT_TRACKER_PATH . '/inc/custom.php' ); +require_once( CBWCT_TRACKER_PATH . '/inc/shortcode.php' ); +require_once( CBWCT_TRACKER_PATH . '/inc/hooks.php' ); + diff --git a/css/ali-animate.css b/css/ali-animate.css new file mode 100644 index 0000000..91f54dc --- /dev/null +++ b/css/ali-animate.css @@ -0,0 +1,65 @@ + +@keyframes cbwct_wc_circle{ + 0%{ + transform: rotate(0deg) + translate(0) + rotate(0deg); + + } + 100%{ + transform:rotate(0) + translate(0) + rotate(360deg) + } +} + + +/* Chrome, Safari, Opera */ +@-webkit-keyframes bounce { + 0% { margin-top:0; -webkit-animation-timing-function: ease-out; } + 50% { margin-top:15px; -webkit-animation-timing-function: ease-in; } + 100% { margin-top:0; -webkit-animation-timing-function: ease-out; } +} + +/* Standard syntax */ +@keyframes bounce { + 0% { margin-top:0; animation-timing-function: ease-out; } + 50% { margin-top:15px; animation-timing-function: ease-in; } + 100% { margin-top:0; animation-timing-function: ease-out; } +} + + +/* Standard syntax */ + +@keyframes cbwct_left_to_right { + + + 100% { + transform: translateX(180px); + } +} + +@keyframes CBWC_Tracking { + 0% { + background-position: 0% 50%; + } + 50% { + background-position: 100% 50%; + } + 100% { + background-position: 0% 50%; + } +} + + + +@keyframes cbwct_loader { + 0% { + top: 8px; + height: 64px; + } + 50%, 100% { + top: 24px; + height: 32px; + } +} diff --git a/css/responsive.css b/css/responsive.css new file mode 100644 index 0000000..db94a33 --- /dev/null +++ b/css/responsive.css @@ -0,0 +1,123 @@ +/* Tablet Layout: 768px. */ + +@media only screen and (min-width: 768px) and (max-width: 991px) { + +.cbwct-tracking-title h2 { + font-size: 20px; +} +.cbwct-tracking { + padding: 10px; +} +.cbwct-tracking-from { + padding: 0 10px; +} +.cbwct-tracking-from form input[type="text"] { + flex-basis: 100%; +} +.cbwct-tracking-form-field { + display: flex; + flex-direction: column; + flex-basis: 100%; +} + +} + + + +/* Mobile Layout: 320px. */ + +@media only screen and (max-width: 767px) { + +.cbwct-tracking-container { + padding: 0px 5px; +} +.cbwct-tracking { + width: 100%; + margin: 0 auto; +} +table tr td:first-child { + min-width: 150px !important; + line-height: 30px; +} +.cbwct-tracking-container { + margin-top: 18px; +} +.cbwct-tracking-title { + text-align: center; +} +.cbwct-tracking-from form label { + padding-right: 10px; + font-weight: 400; +} +.cbwct-tracking-from { + margin-top: 40px; + text-align: center; + margin-bottom: 30px; +} +.cbwct-tracking-title h2 { + font-size: 16px; +} + +@keyframes cbwct_left_to_right { + 100% { + transform: translateX(60px); + } +} + +.cbwct_shipping.active { + animation: cbwct_left_to_right 2s linear infinite; +} + +.cbwct-tracking-form-area { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.cbwct-tracking-form-field { + flex-basis: 100%; +margin-bottom: 10px; +display: flex; +flex-direction: column; +} +.cbwct-tracking-from form input[type="text"] { + flex-basis: 100%; + margin-right: 0; +} + +} + + + +/* Wide Mobile Layout: 480px. */ + +@media only screen and (min-width: 480px) and (max-width: 767px) { + +.cbwct-tracking-title h2 { + font-size: 18px; +} + +@keyframes cbwct_left_to_right { + + 100% { + transform: translateX(65px); + } +} +.cbwct_shipping.active { + animation: cbwct_left_to_right 2s linear infinite; +} +.cbwct-tracking-form-area { + text-align: center; +} +.cbwct-tracking-form-field { + flex-basis: 100%; + margin-bottom: 10px; +} +.cbwct-tracking-from form input[type="text"] { + flex-basis: 100%; +} + + +} + + diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..d2cd62c --- /dev/null +++ b/css/style.css @@ -0,0 +1,256 @@ + +.cbwct-tracking-container table { + width: 100%; +} + +.cbwct-tracking-container tr { + vertical-align: middle; +} + +.cbwct-tracking-container table tr td:first-child{font-size: 16px;color: #404040;vertical-align: middle;font-family: 'Lato',Helvetica, sans-serif !important;font-weight: 400;} + + +.cbwct-tracking-container td { + padding: 9px; +} + +.cbwct-tracking-container tr:nth-child(odd) { + background-color: #dddddd; +} +.cbwct-tracking-container { + margin-top: 50px; +} +.cbwct-tracking{max-width: 1140px; margin: 30px auto;} +.cbwct-tracking-porgressbar { + border-style: solid; + border-width: 1px; + border: rgb(136,136,136); + background-color: rgb(255,255,255); + -webkit-box-shadow: 0px 0px 9px 1px rgb(136,136,136); + -moz-box-shadow: 0px 0px 9px 1px rgb(136,136,136); + box-shadow: 0px 0px 9px 1px rgb(136,136,136); + margin-bottom: 1em; + margin-top: 1em; + position: relative; + height: 75px; +} + +.cbwct-tracking-progress { + background: #0cc5b7; /* Old browsers */ + background: -moz-linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); /* FF3.6-15 */ + background: -webkit-linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); /* Chrome10-25,Safari5.1-6 */ + background: linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0cc5b7', endColorstr='#2bd891',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */ + background-size: 400% 400%; + color:#fff; + animation: CBWC_Tracking 15s ease infinite; + position: absolute; + bottom: 0; + height: 34px; + text-align: center; + border-radius: 3px; +} + +.cbwct-tracking-progress {} +.cbwct-tracking-from form input[type="text"] { + padding: 10px; + border: 1px solid #0a212d; + border-radius: 3px; + margin-right: 10px; + width: 250px; +} +.cbwct-tracking-from form input[type="submit"] { + padding: 10px 20px; + text-align: center; + text-transform: uppercase; + border-radius: 4px; + margin-top: -2px; + border: none; + box-shadow: none; + text-shadow: none; + font-weight: 400; + vertical-align: middle; + cursor: pointer; + white-space: nowrap; + font-size: 14px; + color: #FFF; + + background: #ff934b; /* Old browsers */ +background: -moz-linear-gradient(-45deg, #ff934b 0%, #ff5e62 100%); +background: -webkit-linear-gradient(-45deg, #ff934b 0%,#ff5e62 100%); +background: linear-gradient(135deg, #ff934b 0%,#ff5e62 100%); +filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff934b', endColorstr='#ff5e62',GradientType=1 ); +} +.cbwct-tracking-from form label { + font-weight: 800; + padding-right: 5px; + font-family: 'Lato', sans-serif; + color: #666; + font-size: 14px; +} +.cbwct-tracking-from { + margin-top: 40px; + margin-bottom: 0px; +} +.cbwct-tracking-title h2 { + font-family: 'Montserrat', sans-serif; + font-weight: 600; + font-size: 20px; + color: #666; +} + +.cbwct_wc_traking_steps { + position: absolute; + display: flex; + justify-content: space-between; + width: 97%; + top: 6px; + left: 10px; + right: 10px; + margin: 0 auto; +} +.cbwct-wc-traking-round { + width: 20px; + height: 20px; + background: #fff; + border: 2px solid #ACACA6; + border-radius: 50%; + transition: background 1s; + margin: 0 auto; +} + +.cbwct-wc-traking-round.active:before { + content:''; + width: 0; + height: 0; + border-style: solid; + border-width: 20px 10px 0 10px; + border-color: #23d5ab transparent transparent transparent; + display:block; + -webkit-animation-name: bounce; + -webkit-animation-duration: 1s; + -webkit-animation-iteration-count: infinite; + animation-name: bounce; + animation-duration: 1s; + animation-iteration-count: infinite; + cursor:pointer; + top: -36px; + position: absolute; +} + +.cbwct-wc-traking-round.active:after{ + content: 'Order'; +display: inline-block; +position: absolute; +top: -62px; +left: -44px; +right: 0; +color: #666; +-webkit-animation-name: bounce; +-webkit-animation-duration: 1s; +-webkit-animation-iteration-count: infinite; +animation-name: bounce; +animation-duration: 1s; +animation-iteration-count: infinite; +font-size: 14px; +text-align: center; +width: 125px; +} +.cbwct-wc-traking-round.active.ali-wc-payment:after{ + content:'Payment Pending'; +} + +.cbwct-wc-traking-round.active.ali-wc-hold:after{ + content:'On Hold'; +} +.cbwct-wc-traking-round.active.ali-wc-processing:after{ + content:'Processing'; +} +.cbwct-wc-traking-round.active.ali-wc-shipping:after{ + content:'Shipped'; +} +.cbwct-wc-traking-round.active.ali-wc-delivered:after{ + content:'Delivered'; +} + +.cbwct_wc_traking_step p {color:white;} +.cbwct-wc-traking-img img{width: 30px;margin-bottom: 12px;} + +.cbwct_shipping{position: absolute; +left: 0;top:0} +.cbwct_shipping.active{ + animation: cbwct_left_to_right 5s linear infinite; + +} +.cbwct_wc_traking_step { + text-align: center; + position: relative; +} +.cbwct-wc-traking-img { + margin: 0 auto; +} + +.cbwct-wc-traking-round.active{ background: #0cc5b7; /* Old browsers */ + background: -moz-linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); /* FF3.6-15 */ + background: -webkit-linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); /* Chrome10-25,Safari5.1-6 */ + background: linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0cc5b7', endColorstr='#2bd891',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */ + background-size: 400% 400%; + animation: CBWC_Tracking 15s ease infinite; + border-color:#fff; +} + +.cbwct_notice{color: red; +font-size: 15px; +font-weight: 600; +display: inline-block; +border-radius: 3px;} +.cbwct_progress{animation: cbwct_wc_circle 6s linear infinite;} + +.cbwct_wc_order_cancelled { + font-size: 20px; +display: flex; +justify-content: center; +align-items: center; +height: 100%; +width:100% !important; +} +.cbwct-traking-form-result { + margin-top: 20px; +} +.cbwct-tracking-form-area{display: flex; + flex-wrap: nowrap; + justify-content: center; + flex-direction: row; + align-items: flex-end;} +.cbwct-tracking-form-field{display: flex; +flex-direction: column;} +.cbwct-traking-form-submit{} + + +.cbwct_wc_order_tracker_loader { + display: inline-block; + position: relative; + width: 80px; + height: 80px; +} +.cbwct_wc_order_tracker_loader div { + display: inline-block; + position: absolute; + left: 8px; + width: 16px; + background: #ff5e62 ; + animation: cbwct_loader 1.2s cubic-bezier(0, 0.5, 0.5, 1) infinite; +} +.cbwct_wc_order_tracker_loader div:nth-child(1) { + left: 8px; + animation-delay: -0.24s; +} +.cbwct_wc_order_tracker_loader div:nth-child(2) { + left: 32px; + animation-delay: -0.12s; +} +.cbwct_wc_order_tracker_loader div:nth-child(3) { + left: 56px; + animation-delay: 0; +} \ No newline at end of file diff --git a/img/delivered.png b/img/delivered.png new file mode 100644 index 0000000..7de7dad Binary files /dev/null and b/img/delivered.png differ diff --git a/img/delivery.png b/img/delivery.png new file mode 100644 index 0000000..3ffad69 Binary files /dev/null and b/img/delivery.png differ diff --git a/img/hold.png b/img/hold.png new file mode 100644 index 0000000..8421238 Binary files /dev/null and b/img/hold.png differ diff --git a/img/payment.png b/img/payment.png new file mode 100644 index 0000000..d7da4ea Binary files /dev/null and b/img/payment.png differ diff --git a/img/place-order.png b/img/place-order.png new file mode 100644 index 0000000..17cb094 Binary files /dev/null and b/img/place-order.png differ diff --git a/img/processing.png b/img/processing.png new file mode 100644 index 0000000..df21679 Binary files /dev/null and b/img/processing.png differ diff --git a/inc/custom.php b/inc/custom.php new file mode 100644 index 0000000..8fd5e7d --- /dev/null +++ b/inc/custom.php @@ -0,0 +1,242 @@ + +
Woocommerce Is Required! Woocommerce plugin needs to activated if you want to install the "%s" plugin.
+ ', $woo_url, $plugin_data['Name']); + }else { + return false; + } + +} +add_action('admin_notices', 'cbwct_notice_for_wc_admin_notice'); + + + +if(!class_exists('CBWCT_ORDER_TRACKER')) { + + final class CBWCT_ORDER_TRACKER { + + function __construct(){ + + } + + // progress bar active icon/img condition + public static function cbwct_wcps($data, $status, $value){ + + if($data == $status) { + echo esc_html($value); + } + + } + // Progress bar text for invalid order + public static function order_text($status){ + + if ('cancelled' === $status) { + printf(esc_html__('The order has been %s, Please contact support', 'cbwct'), esc_html(ucwords($status))); + } elseif ('refunded' === $status) { + printf(esc_html__('The order has been %s, Please contact support', 'cbwct'), esc_html(ucwords($status))); + } elseif ('failed' === $status) { + printf(esc_html__('The order has been %s, Please contact support', 'cbwct'), esc_html(ucwords($status))); + } + + + } + + // Progress bar Background color for invalid order + public static function order_class($status){ + + if('cancelled' === $status || 'refunded' === $status || 'failed' === $status ) { + echo esc_attr('cbwct_wc_order_cancelled'); + }else { + return true; + } + + } + // Progress bar individual Background color for valid order + public static function prograssbar($status) { + if('pending' === $status) { + printf('%s', apply_filters( 'cbwct_pending_prograss_percent', '23' )); + } + elseif('on-hold' === $status) { + printf('%s', apply_filters( 'cbwct_on_hold_prograss_percent', '42' )); + } + elseif('processing' === $status) { + printf('%s', apply_filters( 'cbwct_processing_prograss_percent', '61' )); + } + elseif('shipped' === $status) { + printf('%s', apply_filters( 'cbwct_shipped_prograss_percent', '80' )); + } + elseif('completed' === $status) { + printf('%s', apply_filters( 'cbwct_completed_prograss_percent', '100' )); + } + } + + // find payment method name from selected gateway ID + public static function selected_gateway_name($selected) { + + $payment_method = WC()->payment_gateways->payment_gateways(); + + if(array_key_exists($selected, $payment_method)) { + $payment_method_title = $payment_method[$selected]->title; + echo $payment_method_title; + }else { + + echo esc_html__('No exists', 'cbwct'); + } + + } + + // check if order number exists + + public static function order_number_exists($order_number) { + $order = wc_get_order($order_number); + return ($order && $order->get_id() != null); + } + + + + } +} + +// Ajax action function +function cbwct_wc_order_tracking_result() { + + if(wp_verify_nonce( $_POST['Ali_nonce'], 'cbwct_nonce_data' )) { + + require_once(CBWCT_TRACKER_PATH . '/inc/process.php'); + }else { + echo esc_html__('Invalid User', 'cbwct'); + } + + exit; +} + +add_action('wp_ajax_cbwct_wc_order_tracking_result', 'cbwct_wc_order_tracking_result'); +add_action('wp_ajax_nopriv_cbwct_wc_order_tracking_result', 'cbwct_wc_order_tracking_result'); + + +function cbwct_tracker_tamplate_add_page_attribute_dropdown( $post_templates, $wp_theme, $post, $post_type ) { + + $post_templates['template.php'] = __('Order Tracker for WooCommerce'); + + return $post_templates; +} + +add_filter( 'theme_page_templates', 'cbwct_tracker_tamplate_add_page_attribute_dropdown', 10, 4 ); + + +function cbwct_tracker_load_tamplate( $template ) { + + if( get_page_template_slug() === 'template.php' ) { + + if ( $theme_file = locate_template( array( 'template.php' ) ) ) { + $template = $theme_file; + } else { + $template = plugin_dir_path( __FILE__ ) . 'template.php'; + } + } + + if($template == '') { + throw new \Exception('No template found'); + } + + return $template; +} + +add_filter( 'template_include', 'cbwct_tracker_load_tamplate' ); + + + + +// Register a custom order status +add_action('init', 'cbwct_register_custom_order_statuses'); +function cbwct_register_custom_order_statuses() { + register_post_status('wc-shipped ', array( + 'label' => __( 'Shipped', 'woocommerce' ), + 'public' => true, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + 'label_count' => _n_noop('Shipped (%s)', 'Shipped (%s)') + )); +} + + +// Add a custom order status to list of WC Order statuses +add_filter('wc_order_statuses', 'cbwct_add_custom_order_statuses'); +function cbwct_add_custom_order_statuses($order_statuses) { + $new_order_statuses = array(); + + // add new order status before processing + foreach ($order_statuses as $key => $status) { + $new_order_statuses[$key] = $status; + if ('wc-processing' === $key) { + $new_order_statuses['wc-shipped'] = __('Shipped', 'woocommerce' ); + } + } + return $new_order_statuses; +} + + +// Adding custom status 'awaiting-delivery' to admin order list bulk dropdown +add_filter( 'bulk_actions-edit-shop_order', 'cbwct_custom_dropdown_bulk_actions_shop_order', 50, 1 ); +function cbwct_custom_dropdown_bulk_actions_shop_order( $actions ) { + $new_actions = array(); + + // add new order status before processing + foreach ($actions as $key => $action) { + if ('mark_processing' === $key) + $new_actions['mark_shipped'] = __( 'Change status to shipped', 'woocommerce' ); + + $new_actions[$key] = $action; + } + return $new_actions; +} + +// Add a custom order status action button (for orders with "processing" status) +add_filter( 'woocommerce_admin_order_actions', 'cbwct_add_custom_order_status_actions_button', 100, 2 ); +function cbwct_add_custom_order_status_actions_button( $actions, $order ) { + // Display the button for all orders that have a 'processing', 'pending' or 'on-hold' status + if ( $order->has_status( array( 'on-hold', 'processing', 'pending' ) ) ) { + + // The key slug defined for your action button + $action_slug = 'shipped'; + + // Set the action button + $actions[$action_slug] = array( + 'url' => wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce_mark_order_status&status='.$action_slug.'&order_id='.$order->get_id() ), 'woocommerce-mark-order-status' ), + 'name' => __( 'Shipped', 'woocommerce' ), + 'action' => $action_slug, + ); + } + return $actions; +} + +// Set styling for custom order status action button icon and List icon +add_action( 'admin_head', 'cbwct_add_custom_order_status_actions_button_css' ); +function cbwct_add_custom_order_status_actions_button_css() { + $action_slug = "shipped"; // The key slug defined for your action button + ?> + + ', ''); +} +add_filter( 'cbwct_order_number_phone_number_required', 'cbwct_order_number_phone_number_required'); + +// set limit for showing title in tracking page +function cbwct_product_title_trim_words($value) { + return 7; +} +add_filter('cbwct_product_title_trim_words', 'cbwct_product_title_trim_words'); + + +// set progress bar percent +function cbwct_shipped_prograss_percent() { + return 80; +} +add_filter('cbwct_shipped_prograss_percent', 'cbwct_shipped_prograss_percent'); + + +function cbwct_order_is_not_found($value, $order_number) { + + $order_not_found = sprintf('%s Oops! Sorry! %s order is not found! please check order or phone number %s', '+ | get_id()); ?> | +|
+ | date('d-M-y @ h:i:s A')); ?> | +|
+ | get_status())); ?> | +|
+ | date('d-M-y @ h:i:s A')); ?> | +|
+ |
+
|
+ |
+ + | + + | + + |
+ + | + + | + + |
+ | + | |
+ | get_customer_note()); ?> | +|
+ | get_shipping_method()); ?> | +|
+ | get_payment_method())); ?> | +|
+ | get_total(), 2)); ?> | +