Changeset 2737858
- Timestamp:
- 06/06/2022 06:40:50 AM (4 years ago)
- Location:
- unify/trunk
- Files:
-
- 3 edited
-
Actions/Tools.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
unify.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
unify/trunk/Actions/Tools.php
r2705107 r2737858 2 2 3 3 namespace CodeClouds\Unify\Actions; 4 5 use CodeClouds\Unify\Model\Tools_model; 6 use \CodeClouds\Unify\Model\ConfigEncryption; 7 use \CodeClouds\Unify\Service\Helper; 8 use \CodeClouds\Unify\Service\Notice; 4 9 use \CodeClouds\Unify\Service\Request; 5 use CodeClouds\Unify\Model\Tools_model;6 use \CodeClouds\Unify\Service\Notice;7 use \CodeClouds\Unify\Service\Helper;8 use \CodeClouds\Unify\Model\ConfigEncryption;9 10 10 11 /** … … 14 15 class Tools 15 16 { 16 /**17 * Setup tools page18 */ 17 /** 18 * Setup tools page 19 */ 19 20 public static function tools_page() 20 { 21 global $wpdb; 22 $request = []; 23 24 $sections = [ 25 'product-mapping', 26 'shipping-mapping', 27 'import-export', 28 29 ]; 30 //******* Get setting for connection Starts ******** 31 $crm_meta = ''; 32 $crm_model_meta = ''; 33 $setting_option = \get_option('woocommerce_codeclouds_unify_settings'); 34 35 if (!empty($setting_option) && !empty($setting_option['connection'])) 36 { 21 { 22 global $wpdb; 23 $request = []; 37 24 38 $meta_data = \get_post_meta($setting_option['connection'], 'unify_connection_crm'); 25 $sections = [ 26 'product-mapping', 27 'shipping-mapping', 28 'import-export', 39 29 40 $meta_data_salt = \get_post_meta($setting_option['connection'], 'unify_connection_crm_salt'); 30 ]; 31 //******* Get setting for connection Starts ******** 32 $crm_meta = ''; 33 $crm_model_meta = ''; 34 $setting_option = \get_option('woocommerce_codeclouds_unify_settings'); 41 35 36 if (!empty($setting_option) && !empty($setting_option['connection'])) { 42 37 43 if (!empty($meta_data)) 44 { 45 $crm_meta = isset($meta_data_salt[0])?ConfigEncryption::metaDecryptSingle($meta_data[0],$meta_data_salt [0]):$meta_data[0]; 46 47 if($crm_meta == 'limelight'){ 48 $meta_model_data = get_post_meta($setting_option['connection'], 'unify_connection_offer_model'); 49 $crm_model_meta = (!empty($meta_model_data)) ? $meta_model_data[0] : ''; 50 $shipping_price_settings_option = (!empty($setting_option['shipment_price_settings'])) ? $setting_option['shipment_price_settings'] : ''; 51 } 52 if($crm_meta == 'sublytics'){ 53 $meta_model_data = get_post_meta($setting_option['connection'], 'unify_connection_offer_model'); 54 $crm_model_meta = (!empty($meta_model_data)) ? $meta_model_data[0] : ''; 55 $shipping_price_settings_option = (!empty($setting_option['shipment_price_settings'])) ? $setting_option['shipment_price_settings'] : ''; 56 } 38 $meta_data = \get_post_meta($setting_option['connection'], 'unify_connection_crm'); 57 39 58 if($crm_meta == 'response'){ 59 $meta_model_data = \get_post_meta($setting_option['connection'], 'unify_response_crm_type_enable'); 60 $crm_model_meta = (!empty($meta_model_data)) ? $meta_model_data[0] : ''; 61 } 40 $meta_data_salt = \get_post_meta($setting_option['connection'], 'unify_connection_crm_salt'); 62 41 42 if (!empty($meta_data)) { 43 $crm_meta = isset($meta_data_salt[0]) ? ConfigEncryption::metaDecryptSingle($meta_data[0], $meta_data_salt[0]) : $meta_data[0]; 63 44 64 } 65 } 66 //******* Get setting for connection Ends ******** 67 68 $request['paged'] = (empty($_GET['paged'])) ? 1 : sanitize_text_field(wp_unslash($_GET['paged'])); 69 $request['posts_per_page'] = (empty($_GET['posts_per_page'])) ? 10 : sanitize_text_field(wp_unslash($_GET['posts_per_page'])); 70 71 $request['orderby'] = (empty($_GET['orderby'])) ? 'post_title' : sanitize_text_field(wp_unslash($_GET['orderby'])); 72 $request['order'] = (empty($_GET['order'])) ? 'asc' : sanitize_text_field(wp_unslash($_GET['order'])); 73 74 $tools_model_object = new Tools_model(); 75 $data = $tools_model_object->get_products_with_meta($request); 45 if ($crm_meta == 'limelight') { 46 $meta_model_data = get_post_meta($setting_option['connection'], 'unify_connection_offer_model'); 47 $crm_model_meta = (!empty($meta_model_data)) ? $meta_model_data[0] : ''; 48 $shipping_price_settings_option = (!empty($setting_option['shipment_price_settings'])) ? $setting_option['shipment_price_settings'] : ''; 49 } 50 if ($crm_meta == 'sublytics') { 51 $meta_model_data = get_post_meta($setting_option['connection'], 'unify_connection_offer_model'); 52 $crm_model_meta = (!empty($meta_model_data)) ? $meta_model_data[0] : ''; 53 $shipping_price_settings_option = (!empty($setting_option['shipment_price_settings'])) ? $setting_option['shipment_price_settings'] : ''; 54 } 76 55 77 if(!empty($data['list'])){ 78 foreach($data['list'] as $k => $prod_list){ 79 $product = \wc_get_product( $prod_list['ID'] ); 80 $data['list'][$k]['price'] = $product->get_price(); 81 } 82 } 56 if ($crm_meta == 'response') { 57 $meta_model_data = \get_post_meta($setting_option['connection'], 'unify_response_crm_type_enable'); 58 $crm_model_meta = (!empty($meta_model_data)) ? $meta_model_data[0] : ''; 59 } 83 60 84 $prev_dis = (($request['paged'] == 1)) ? true : false; 85 $next_dis = (!empty($request['paged']) && $request['paged'] == $data['total']) ? true : false; 61 } 62 } 63 //******* Get setting for connection Ends ******** 64 65 $request['paged'] = (empty($_GET['paged'])) ? 1 : sanitize_text_field(wp_unslash($_GET['paged'])); 66 $request['posts_per_page'] = (empty($_GET['posts_per_page'])) ? 10 : sanitize_text_field(wp_unslash($_GET['posts_per_page'])); 67 68 $request['orderby'] = (empty($_GET['orderby'])) ? 'post_title' : sanitize_text_field(wp_unslash($_GET['orderby'])); 69 $request['order'] = (empty($_GET['order'])) ? 'asc' : sanitize_text_field(wp_unslash($_GET['order'])); 70 71 $tools_model_object = new Tools_model(); 72 $data = $tools_model_object->get_products_with_meta($request); 73 74 if (!empty($data['list'])) { 75 foreach ($data['list'] as $k => $prod_list) { 76 $product = \wc_get_product($prod_list['ID']); 77 $data['list'][$k]['price'] = $product->get_price(); 78 } 79 } 80 81 $prev_dis = (($request['paged'] == 1)) ? true : false; 82 $next_dis = (!empty($request['paged']) && $request['paged'] == $data['total']) ? true : false; 86 83 include_once __DIR__ . '/../Templates/tools.php'; 87 84 } 88 85 89 86 public static function save_product() 90 { 91 $nonce = Request::post('_wpnonce'); 92 $messages = Helper::getDataFromFile('Messages'); 93 $param = ''; 94 95 if (wp_verify_nonce($nonce, 'unify-product') && Request::post('check_submit') == 'update_product') 96 { 97 $fields = ['codeclouds_unify_connection', 'codeclouds_unify_shipping', 'codeclouds_unify_offer_id', 'codeclouds_unify_billing_model_id', 'codeclouds_unify_group_id']; 98 99 foreach (Request::post()['map'] as $post_id => $value) 100 { 101 foreach ($value as $field_key => $field_val) 102 { 103 if (in_array($field_key, $fields)) 104 { 105 106 if ( 107 (gettype(\get_post_meta($post_id, $field_key, true))=='array' && count(\get_post_meta($post_id, $field_key, true)) > 0) || 108 (gettype(\get_post_meta($post_id, $field_key, true))=='string' && !empty(\get_post_meta($post_id, $field_key, true))) 109 ) 110 { 111 if (!empty($field_val)) 112 { 113 /** 114 * If the custom field already has a value, update it. 115 */ 116 var_dump(\update_post_meta($post_id, $field_key, trim(esc_attr($field_val)))); 117 } 118 else 119 { 120 /** 121 * Delete the meta key if there's no value 122 */ 123 \delete_post_meta($post_id, $field_key); 124 } 125 } 126 else 127 { 128 /** 129 * If the custom field doesn't have a value, add it. 130 */ 131 \add_post_meta($post_id, $field_key, trim(esc_attr($field_val))); 132 } 133 } 134 } 135 } 136 $msg = $messages['PRODUCT_MAP']['SUCCESS']; 137 Notice::setFlashMessage('success', $msg); 138 }else if (Request::post('check_submit') == 'sort_field'){ // sort_field is for sorting 139 $orderBy = (!empty(Request::post('orderby'))) ? Request::post('orderby') : 'post_title'; 140 $order = (!empty(Request::post('order'))) ? Request::post('order') : 'desc'; 141 $param .= (empty($_GET['orderby'])) ? '&orderby='.$orderBy : $orderBy; 142 $param .= (empty($_GET['order'])) ? '&order='.$order : $order; 143 }else{ 144 $msg = $messages['COMMON']['ERROR']; 145 Notice::setFlashMessage('error', $msg); 146 } 147 148 wp_redirect(Request::post('_wp_http_referer').(!empty($param) ? $param : '')); 149 exit(); 150 } 87 { 88 $nonce = Request::post('_wpnonce'); 89 $messages = Helper::getDataFromFile('Messages'); 90 $param = ''; 151 91 152 public static function save_shipping() 153 { 154 $nonce = Request::post('_wpnonce'); 155 $messages = Helper::getDataFromFile('Messages'); 156 $param = ''; 157 158 if (wp_verify_nonce($nonce, 'unify-shipping') && Request::post('check_submit') == 'update_product') 159 { 160 $fields = ['crm_shipping_id','woo_shipping_method_price','crm_shipping_price']; 161 162 foreach (Request::post()['map'] as $post_id => $value) 163 { 164 foreach ($value as $field_key => $field_val) 165 { 166 if (in_array($field_key, $fields)) 167 { 168 if ( 169 (gettype(\get_post_meta($post_id, $field_key, true))=='array' && count(\get_post_meta($post_id, $field_key, true)) > 0) || 170 (gettype(\get_post_meta($post_id, $field_key, true))=='string' && !empty(\get_post_meta($post_id, $field_key, true))) 171 ) 172 { 173 if (!empty($field_val)) 174 { 175 /** 176 * If the custom field already has a value, update it. 177 */ 178 var_dump(\update_post_meta($post_id, $field_key, trim(esc_attr($field_val)))); 179 } 180 else 181 { 182 /** 183 * Delete the meta key if there's no value 184 */ 185 \delete_post_meta($post_id, $field_key); 186 } 187 } 188 else 189 { 190 /** 191 * If the custom field doesn't have a value, add it. 192 */ 193 \add_post_meta($post_id, $field_key, trim(esc_attr($field_val))); 194 } 195 } 196 } 197 } 198 $msg = $messages['SHIPPING_MAP']['SUCCESS']; 199 Notice::setFlashMessage('success', $msg); 200 }else{ 201 $msg = $messages['COMMON']['ERROR']; 202 Notice::setFlashMessage('error', $msg); 203 } 204 205 wp_redirect(Request::post('_wp_http_referer').(!empty($param) ? $param : '')); 206 exit(); 207 } 92 if (wp_verify_nonce($nonce, 'unify-product') && Request::post('check_submit') == 'update_product') { 93 $fields = ['codeclouds_unify_connection', 'codeclouds_unify_shipping', 'codeclouds_unify_offer_id', 'codeclouds_unify_billing_model_id', 'codeclouds_unify_group_id']; 94 95 foreach (Request::post()['map'] as $post_id => $value) { 96 foreach ($value as $field_key => $field_val) { 97 if (in_array($field_key, $fields)) { 98 if (count(\get_post_meta($post_id, $field_key)) > 0) { 99 if (!empty($field_val)) { 100 /** 101 * If the custom field already has a value, update it. 102 */ 103 var_dump(\update_post_meta($post_id, $field_key, trim(esc_attr($field_val)))); 104 } else { 105 /** 106 * Delete the meta key if there's no value 107 */ 108 \delete_post_meta($post_id, $field_key); 109 } 110 } else { 111 /** 112 * If the custom field doesn't have a value, add it. 113 */ 114 \add_post_meta($post_id, $field_key, trim(esc_attr($field_val))); 115 } 116 } 117 } 118 } 119 $msg = $messages['PRODUCT_MAP']['SUCCESS']; 120 Notice::setFlashMessage('success', $msg); 121 } else if (Request::post('check_submit') == 'sort_field') { // sort_field is for sorting 122 $orderBy = (!empty(Request::post('orderby'))) ? Request::post('orderby') : 'post_title'; 123 $order = (!empty(Request::post('order'))) ? Request::post('order') : 'desc'; 124 $param .= (empty($_GET['orderby'])) ? '&orderby=' . $orderBy : $orderBy; 125 $param .= (empty($_GET['order'])) ? '&order=' . $order : $order; 126 } else { 127 $msg = $messages['COMMON']['ERROR']; 128 Notice::setFlashMessage('error', $msg); 129 } 130 131 wp_redirect(Request::post('_wp_http_referer') . (!empty($param) ? $param : '')); 132 exit(); 133 } 134 135 public static function save_shipping() 136 { 137 $nonce = Request::post('_wpnonce'); 138 $messages = Helper::getDataFromFile('Messages'); 139 $param = ''; 140 141 if (wp_verify_nonce($nonce, 'unify-shipping') && Request::post('check_submit') == 'update_product') { 142 $fields = ['crm_shipping_id', 'woo_shipping_method_price', 'crm_shipping_price']; 143 144 foreach (Request::post()['map'] as $post_id => $value) { 145 foreach ($value as $field_key => $field_val) { 146 if (in_array($field_key, $fields)) { 147 if (count(\get_post_meta($post_id, $field_key)) > 0) { 148 if (!empty($field_val)) { 149 /** 150 * If the custom field already has a value, update it. 151 */ 152 var_dump(\update_post_meta($post_id, $field_key, trim(esc_attr($field_val)))); 153 } else { 154 /** 155 * Delete the meta key if there's no value 156 */ 157 \delete_post_meta($post_id, $field_key); 158 } 159 } else { 160 /** 161 * If the custom field doesn't have a value, add it. 162 */ 163 \add_post_meta($post_id, $field_key, trim(esc_attr($field_val))); 164 } 165 } 166 } 167 } 168 169 $msg = $messages['SHIPPING_MAP']['SUCCESS']; 170 Notice::setFlashMessage('success', $msg); 171 } else { 172 $msg = $messages['COMMON']['ERROR']; 173 Notice::setFlashMessage('error', $msg); 174 } 175 176 wp_redirect(Request::post('_wp_http_referer') . (!empty($param) ? $param : '')); 177 exit(); 178 } 208 179 } -
unify/trunk/readme.txt
r2719260 r2737858 5 5 Tested up to: 5.9 6 6 Requires PHP: 5.6 7 Stable tag: 3.3. 47 Stable tag: 3.3.5 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html\ … … 95 95 == Changelog == 96 96 97 = 3.3.5 = 98 * Fix - Product mapping saving issue. 99 97 100 = 3.3.4 = 98 101 * Enhacement - Updated License management links. -
unify/trunk/unify.php
r2719260 r2737858 7 7 * Author: CodeClouds <sales@codeclouds.com> 8 8 * Author URI: https://www.CodeClouds.com/ 9 * Version: 3.3. 49 * Version: 3.3.5 10 10 * License: GPLv2 or later 11 11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 60 60 define('UNIFY_PLATFORM_LOGIN', 'https://accounts.unify.to/login'); 61 61 define('UNIFY_WP_HOME_URL', home_url()); 62 define('UNIFY_JS_VERSION', '3.3. 4');62 define('UNIFY_JS_VERSION', '3.3.5');
Note: See TracChangeset
for help on using the changeset viewer.