Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.1.0.1
- * @ Author : DeZender
- * @ Release on : 29.08.2020
- * @ Official site : http://DeZender.Net
- *
- */
- defined('ABSPATH') || exit('No script kiddies please!');
- if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
- class DevVN_Woo_GHTK_Class
- {
- static protected $instance;
- protected $_version = '';
- public $_optionName = 'devvn_woo_district';
- public $_optionGroup = 'devvn-district-options-group';
- public $_defaultOptions = [
- 'active_village' => '',
- 'required_village' => '',
- 'to_vnd' => '',
- 'remove_methob_title' => '',
- 'freeship_remove_other_methob' => '',
- 'khoiluong_quydoi' => '6000',
- 'active_vnd2usd' => 0,
- 'vnd_usd_rate' => '22745',
- 'vnd2usd_currency' => 'USD',
- 'shop_store' => [],
- 'token_key' => '',
- 'is_freeship' => 0,
- 'is_sandbox' => 0,
- 'transport' => 'road',
- 'active_orderstyle' => 0,
- 'ghtk_hash' => '',
- 'alepay_support' => 0,
- 'enable_postcode' => 0,
- 'enable_gender' => 0,
- 'print_logo' => '',
- 'print_note' => '<strong>Chú ý:</strong> Kiểm tra hàng khi có mặt shiper.',
- 'mashop' => '',
- 'license_key' => '',
- 'send_shipid_active' => 0,
- 'send_shipid_title' => 'Mã vận đơn tại {site_title}',
- 'send_shipid_content' => 'Đơn hàng #{order_id} của bạn đang được vận chuyển. <br>Mã vận đơn là: {ship_id}<br> Ngày dự kiến giao hàng: {estimated_deliver}'
- ];
- public $_default_status = [
- 'success' => false,
- 'message' => '',
- 'order' => ['label_id' => '', 'partner_id' => '', 'status' => '', 'created' => '', 'updated' => '', 'pick_date' => '', 'pick_period' => '', 'deliver_date' => '', 'deliver_period' => '', 'status_id' => '', 'action_time' => '', 'reason_code' => '', 'reason' => '', 'weight' => '', 'fee' => '']
- ];
- public $_weight_option = 'kilogram';
- public $enabled_free_shipping = '';
- static public function init()
- {
- is_null(self::$instance) && (self::$instance = new self());
- return self::$instance;
- }
- public function __construct()
- {
- global $ghtk_settings;
- $ghtk_settings = $this->get_ghtk_options();
- $this->set_weight_option();
- $this->_version = DEVVN_GHTK_VERSION_NUM;
- add_filter('woocommerce_checkout_fields', [$this, 'custom_override_checkout_fields'], 99999);
- add_filter('woocommerce_states', [$this, 'vietnam_cities_woocommerce'], 9999);
- add_action('woocommerce_checkout_process', [$this, 'devvn_gender_field_process']);
- add_action('wp_enqueue_scripts', [$this, 'devvn_enqueue_UseAjaxInWp']);
- add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']);
- add_action('wp_ajax_load_diagioihanhchinh', [$this, 'load_diagioihanhchinh_func']);
- add_action('wp_ajax_nopriv_load_diagioihanhchinh', [$this, 'load_diagioihanhchinh_func']);
- add_filter('woocommerce_localisation_address_formats', [$this, 'devvn_woocommerce_localisation_address_formats']);
- add_filter('woocommerce_order_formatted_billing_address', [$this, 'devvn_woocommerce_order_formatted_billing_address'], 10, 2);
- add_action('woocommerce_admin_order_data_after_shipping_address', [$this, 'devvn_after_shipping_address'], 10, 1);
- add_filter('woocommerce_order_formatted_shipping_address', [$this, 'devvn_woocommerce_order_formatted_shipping_address'], 10, 2);
- add_filter('woocommerce_order_details_after_customer_details', [$this, 'devvn_woocommerce_order_details_after_customer_details'], 10);
- add_filter('woocommerce_my_account_my_address_formatted_address', [$this, 'devvn_woocommerce_my_account_my_address_formatted_address'], 10, 3);
- add_filter('default_checkout_billing_country', [$this, 'devvn_change_default_checkout_country'], 999);
- add_filter('default_checkout_shipping_country', [$this, 'devvn_change_default_checkout_country'], 999);
- add_action('admin_menu', [$this, 'admin_menu']);
- add_action('admin_init', [$this, 'register_mysettings']);
- add_filter('plugin_action_links_' . DEVVN_GHTK_BASENAME, [$this, 'plugin_action_links']);
- add_option($this->_optionName, $this->_defaultOptions);
- include_once 'includes/apps.php';
- include_once 'includes/class-ghtk-shipping.php';
- add_filter('woocommerce_default_address_fields', [$this, 'devvn_custom_override_default_address_fields'], 99999);
- add_filter('woocommerce_get_country_locale', [$this, 'devvn_woocommerce_get_country_locale'], 99);
- add_filter('woocommerce_admin_billing_fields', [$this, 'devvn_woocommerce_admin_billing_fields'], 99);
- add_filter('woocommerce_admin_shipping_fields', [$this, 'devvn_woocommerce_admin_shipping_fields'], 99);
- add_filter('woocommerce_form_field_select', [$this, 'devvn_woocommerce_form_field_select'], 10, 4);
- add_action('woocommerce_admin_order_data_after_order_details', [$this, 'devvn_woocommerce_admin_order_data_after_order_details']);
- add_action('wp_ajax_dang_order_ghtk', [$this, 'func_dang_order_ghtk']);
- add_action('wp_ajax_print_order_ghtk', [$this, 'print_order_ghtk_func']);
- add_action('wp_ajax_check_status_ghtk', [$this, 'check_status_ghtk_func']);
- add_action('wp_ajax_ghtk_add_url', [$this, 'ghtk_add_url_func']);
- add_action('wp_ajax_ghtk_delete_url', [$this, 'ghtk_delete_url_func']);
- add_action('wp_ajax_nopriv_update_shipping_status', [$this, 'update_shipping_status_func']);
- add_filter('woocommerce_shipping_calculator_enable_postcode', '__return_false');
- add_filter('woocommerce_get_order_address', [$this, 'devvn_woocommerce_get_order_address'], 99, 2);
- add_filter('woocommerce_rest_prepare_shop_order_object', [$this, 'devvn_woocommerce_rest_prepare_shop_order_object'], 99, 3);
- include_once 'includes/updates.php';
- add_action('wp_ajax_inhoadon_ghtk', [$this, 'devvn_print_order']);
- add_action('xc_woo_cloud_print_after_order_details', [$this, 'xc_woo_cloud_print_after_order_details'], 10, 2);
- add_action('admin_print_footer_scripts', [$this, 'devvn_admin_print_footer_scripts'], 999999);
- add_action('wp_ajax_ghtk_tracking', [$this, 'ghtk_tracking_func']);
- add_action('wp_ajax_nopriv_ghtk_tracking', [$this, 'ghtk_tracking_func']);
- add_shortcode('ghtk_tracking_form', [$this, 'ghtk_tracking_form_func']);
- add_filter('woocommerce_formatted_address_replacements', [$this, 'devvn_woocommerce_formatted_address_replacements'], 9);
- add_action('devvn_ghtk_action', [$this, 'devvn_ghtk_action_func']);
- add_action('wp_ajax_ghtk_creat_order_ajax', [$this, 'ghtk_creat_order_ajax_func']);
- add_filter('bulk_actions-edit-shop_order', [$this, 'define_bulk_actions']);
- add_filter('handle_bulk_actions-edit-shop_order', [$this, 'ghtk_bulk_action_handler'], 10, 3);
- add_filter('woocommerce_customer_meta_fields', [$this, 'woocommerce_customer_meta_fields']);
- add_filter('woocommerce_general_settings', [$this, 'woocommerce_general_settings']);
- add_action('woocommerce_admin_field_selectajax', [$this, 'woocommerce_admin_field_selectajax']);
- add_action('woocommerce_my_account_my_orders_column_order-status', [$this, 'devvn_custom_order_status_myaccount']);
- add_action('woocommerce_checkout_update_order_review', [$this, 'devvn_update_checkout_func'], 10);
- include_once DEVVN_GHTK_PLUGIN_DIR . '/includes/freeshipping-by-payment-methob.php';
- $free_shipping = get_option('woocommerce_devvn_freeshipping_by_paymentmethod_settings');
- $this->enabled_free_shipping = (isset($free_shipping['enabled']) ? $free_shipping['enabled'] : 'no');
- }
- public function get_ghtk_options()
- {
- return wp_parse_args(get_option($this->_optionName), $this->_defaultOptions);
- }
- public function set_weight_option()
- {
- $wc_weight = get_option('woocommerce_weight_unit');
- if ($wc_weight == 'g') {
- $this->_weight_option = 'gram';
- }
- }
- static public function on_activation()
- {
- if (!current_user_can('activate_plugins')) {
- return false;
- }
- $plugin = (isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '');
- check_admin_referer('activate-plugin_' . $plugin);
- }
- static public function on_deactivation()
- {
- if (!current_user_can('activate_plugins')) {
- return false;
- }
- $plugin = (isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '');
- check_admin_referer('deactivate-plugin_' . $plugin);
- }
- static public function on_uninstall()
- {
- if (!current_user_can('activate_plugins')) {
- return false;
- }
- }
- public function admin_menu()
- {
- add_submenu_page('woocommerce', __('Cài đặt GHTK', 'devvn-ghtk'), __('Cài đặt GHTK', 'devvn-ghtk'), 'manage_woocommerce', 'devvn-woo-ghtk', [$this, 'devvn_district_setting']);
- }
- public function register_mysettings()
- {
- register_setting($this->_optionGroup, $this->_optionName);
- }
- public function devvn_district_setting()
- {
- wp_enqueue_media();
- include 'includes/setting-page.php';
- }
- public function vietnam_cities_woocommerce($states)
- {
- $states['VN'] = $this->get_tinhthanhpho();
- return $states;
- }
- public function custom_override_checkout_fields($fields)
- {
- if ($this->get_options('enable_gender')) {
- $fields['billing']['billing_gender'] = [
- 'label' => __('Gender', 'devvn-ghtk'),
- 'priority' => 5,
- 'default' => 'female',
- 'required' => true,
- 'type' => 'radio',
- 'options' => ['male' => __('Mr', 'devvn-ghtk'), 'female' => __('Mrs', 'devvn-ghtk')]
- ];
- }
- if (!$this->get_options('alepay_support')) {
- $fields['billing']['billing_first_name'] = [
- 'label' => __('Full name', 'devvn-ghtk'),
- 'placeholder' => _x('Type Full name', 'placeholder', 'devvn-ghtk'),
- 'required' => true,
- 'class' => ['form-row-wide'],
- 'clear' => true,
- 'priority' => 10
- ];
- }
- if (isset($fields['billing']['billing_phone'])) {
- $fields['billing']['billing_phone']['class'] = ['form-row-first'];
- $fields['billing']['billing_phone']['placeholder'] = __('Type your phone', 'devvn-ghtk');
- }
- if (isset($fields['billing']['billing_email'])) {
- $fields['billing']['billing_email']['class'] = ['form-row-last'];
- $fields['billing']['billing_email']['placeholder'] = __('Type your email', 'devvn-ghtk');
- }
- $fields['billing']['billing_state'] = [
- 'label' => __('Province/City', 'devvn-ghtk'),
- 'required' => true,
- 'type' => 'select',
- 'class' => ['form-row-first', 'devvn-address-field'],
- 'placeholder' => _x('Select Province/City', 'placeholder', 'devvn-ghtk'),
- 'options' => ['' => __('Select Province/City', 'devvn-ghtk')] + $this->get_tinhthanhpho(),
- 'priority' => 30
- ];
- $fields['billing']['billing_city'] = [
- 'label' => __('District', 'devvn-ghtk'),
- 'required' => true,
- 'type' => 'select',
- 'class' => ['form-row-last', 'address-field', 'update_totals_on_change'],
- 'placeholder' => _x('Select District', 'placeholder', 'devvn-ghtk'),
- 'options' => ['' => ''],
- 'priority' => 40
- ];
- if (!$this->get_options()) {
- $fields['billing']['billing_address_2'] = [
- 'label' => __('Commune/Ward/Town', 'devvn-ghtk'),
- 'required' => true,
- 'type' => 'select',
- 'class' => ['form-row-first', 'devvn-address-field'],
- 'placeholder' => _x('Select Commune/Ward/Town', 'placeholder', 'devvn-ghtk'),
- 'options' => ['' => ''],
- 'priority' => 50
- ];
- if ($this->get_options('required_village')) {
- $fields['billing']['billing_address_2']['required'] = false;
- }
- }
- $fields['billing']['billing_address_1']['placeholder'] = _x('Ex: No. 20, 90 Alley', 'placeholder', 'devvn-ghtk');
- if (!$this->get_options()) {
- $fields['billing']['billing_address_1']['class'] = ['form-row-last'];
- }
- else {
- $fields['billing']['billing_address_1']['class'] = ['form-row-wide'];
- }
- $fields['billing']['billing_address_1']['priority'] = 60;
- if (isset($fields['billing']['billing_phone'])) {
- $fields['billing']['billing_phone']['priority'] = 20;
- }
- if (isset($fields['billing']['billing_email'])) {
- $fields['billing']['billing_email']['priority'] = 21;
- }
- if (!$this->get_options('alepay_support')) {
- unset($fields['billing']['billing_country']);
- unset($fields['billing']['billing_last_name']);
- }
- else {
- $fields['billing']['billing_country']['priority'] = 22;
- }
- unset($fields['billing']['billing_company']);
- if (!$this->get_options('alepay_support')) {
- $fields['shipping']['shipping_first_name'] = [
- 'label' => __('Full name', 'devvn-ghtk'),
- 'placeholder' => _x('Type Full name', 'placeholder', 'devvn-ghtk'),
- 'required' => true,
- 'class' => ['form-row-first'],
- 'clear' => true,
- 'priority' => 10
- ];
- }
- $fields['shipping']['shipping_phone'] = [
- 'label' => __('Phone', 'devvn-ghtk'),
- 'placeholder' => _x('Phone', 'placeholder', 'devvn-ghtk'),
- 'required' => false,
- 'class' => ['form-row-last'],
- 'clear' => true,
- 'priority' => 20
- ];
- if ($this->get_options('alepay_support')) {
- $fields['shipping']['shipping_phone']['class'] = ['form-row-wide'];
- }
- $fields['shipping']['shipping_state'] = [
- 'label' => __('Province/City', 'devvn-ghtk'),
- 'required' => true,
- 'type' => 'select',
- 'class' => ['form-row-first', 'devvn-address-field'],
- 'placeholder' => _x('Select Province/City', 'placeholder', 'devvn-ghtk'),
- 'options' => ['' => __('Select Province/City', 'devvn-ghtk')] + $this->get_tinhthanhpho(),
- 'priority' => 30
- ];
- $fields['shipping']['shipping_city'] = [
- 'label' => __('District', 'devvn-ghtk'),
- 'required' => true,
- 'type' => 'select',
- 'class' => ['form-row-last', 'address-field', 'update_totals_on_change'],
- 'placeholder' => _x('Select District', 'placeholder', 'devvn-ghtk'),
- 'options' => ['' => ''],
- 'priority' => 40
- ];
- if (!$this->get_options()) {
- $fields['shipping']['shipping_address_2'] = [
- 'label' => __('Commune/Ward/Town', 'devvn-ghtk'),
- 'required' => true,
- 'type' => 'select',
- 'class' => ['form-row-first', 'devvn-address-field'],
- 'placeholder' => _x('Select Commune/Ward/Town', 'placeholder', 'devvn-ghtk'),
- 'options' => ['' => ''],
- 'priority' => 50
- ];
- if ($this->get_options('required_village')) {
- $fields['shipping']['shipping_address_2']['required'] = false;
- }
- }
- $fields['shipping']['shipping_address_1']['placeholder'] = _x('Ex: No. 20, 90 Alley', 'placeholder', 'devvn-ghtk');
- if (!$this->get_options()) {
- $fields['shipping']['shipping_address_1']['class'] = ['form-row-last'];
- }
- else {
- $fields['shipping']['shipping_address_1']['class'] = ['form-row-wide'];
- }
- $fields['shipping']['shipping_address_1']['priority'] = 60;
- if (!$this->get_options('alepay_support')) {
- unset($fields['shipping']['shipping_country']);
- unset($fields['shipping']['shipping_last_name']);
- }
- else {
- $fields['shipping']['shipping_country']['priority'] = 22;
- }
- unset($fields['shipping']['shipping_company']);
- uasort($fields['billing'], [$this, 'sort_fields_by_order']);
- uasort($fields['shipping'], [$this, 'sort_fields_by_order']);
- return apply_filters('ghtk_custom_field_checkout', $fields);
- }
- public function sort_fields_by_order($a, $b)
- {
- if (!isset($b['priority']) || !isset($a['priority']) || ($a['priority'] == $b['priority'])) {
- return 0;
- }
- return $a['priority'] < $b['priority'] ? -1 : 1;
- }
- public function search_in_array($array, $key, $value)
- {
- $results = [];
- if (is_array($array)) {
- if (isset($array[$key]) && ($array[$key] == $value)) {
- $results[] = $array;
- }
- else if (isset($array[$key]) && is_serialized($array[$key]) && in_array($value, maybe_unserialize($array[$key]))) {
- $results[] = $array;
- }
- foreach ($array as $subarray) {
- $results = array_merge($results, $this->search_in_array($subarray, $key, $value));
- }
- }
- return $results;
- }
- public function check_file_open_status($file_url = '')
- {
- if (!$file_url) {
- return false;
- }
- try {
- $response = @file_get_contents($file_url);
- $status_line = $http_response_header[0];
- preg_match('{HTTP\\/\\S*\\s(\\d{3})}', $status_line, $match);
- $status = (isset($match[1]) ? $match[1] : false);
- return $status;
- }
- catch (Exception $e) {
- return false;
- }
- return false;
- }
- public function devvn_enqueue_UseAjaxInWp()
- {
- if (is_checkout() || is_page(get_option('woocommerce_edit_address_page_id'))) {
- wp_enqueue_style('ghtk_styles', plugins_url('/assets/css/devvn_dwas_style.css', __FILE__), [], $this->_version, 'all');
- wp_enqueue_script('devvn_tinhthanhpho', plugins_url('assets/js/devvn_tinhthanh.js', __FILE__), ['jquery', 'select2'], $this->_version, true);
- $get_address = DEVVN_GHTK_URL . 'get-address.php';
- if ($this->check_file_open_status($get_address) != 200) {
- $get_address = admin_url('admin-ajax.php');
- }
- $php_array = ['admin_ajax' => admin_url('admin-ajax.php'), 'get_address' => $get_address, 'home_url' => home_url(), 'formatNoMatches' => __('No value', 'devvn-ghtk'), 'enabled_free_shipping' => false];
- if ($this->enabled_free_shipping == 'yes') {
- $php_array['enabled_free_shipping'] = true;
- }
- wp_localize_script('devvn_tinhthanhpho', 'ghtk_array', $php_array);
- }
- }
- public function load_diagioihanhchinh_func()
- {
- $matp = (isset($_POST['matp']) ? sanitize_text_field($_POST['matp']) : '');
- .............................................................................
- ................................................
- ........................
Add Comment
Please, Sign In to add comment