Changeset 2925247
- Timestamp:
- 06/13/2023 11:19:40 AM (3 years ago)
- Location:
- afterinc-app/trunk
- Files:
-
- 2 edited
-
Custom_app.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
afterinc-app/trunk/Custom_app.php
r2925221 r2925247 4 4 Plugin URI: https://www.afterinc.com/contact/ 5 5 Description: Plugin allows merchants to sell After Plan’s product protection plans for wide variety of products. 6 Version: 3.6. 66 Version: 3.6.7 7 7 Author: After Inc. 8 8 Author URI: https://www.afterinc.com … … 197 197 add_action('my_oneminute_event', array($this, 'order_scheduler_cron')); 198 198 199 add_action('my_custom_5_minute_cron', array($this,'my_custom_5_minute_function'));199 add_action('my_custom_5_minute_cron', array($this,'my_custom_5_minute_function')); 200 200 add_filter('cron_schedules', array($this,'add_custom_cron_intervals')); 201 202 add_action('save_post', array($this,'save_custom_bulk_edit_data')); 201 203 202 203 204 204 } 205 205 … … 3054 3054 $phpmailer->FromName = "QuickCover"; 3055 3055 } 3056 3057 3058 function save_custom_bulk_edit_data($post_id) { 3059 3060 if($_REQUEST['action'] === 'edit'){ 3061 3062 $appConfig = $this->wpdb->get_results($this->wpdb->prepare("SELECT * FROM app_configurations WHERE id = %d", 1)); 3063 3064 $productsbulk_data = array(); 3065 global $woocommerce,$product; 3066 $all_cat = $_GET['tax_input']['product_cat']; 3067 3068 $cat_name = []; 3069 foreach ($all_cat as $key => $valueid) { 3070 $allterm = get_term_by( 'id', $valueid, 'product_cat'); 3071 if(isset($allterm->name)){ 3072 $cat_name[] = trim($allterm->name); 3073 } 3074 } 3075 3076 if(!empty($appConfig)){ 3077 3078 $api_key = $appConfig[0]->api_key; 3079 $quick_store_id = $appConfig[0]->store_id; 3080 $autosync_status = $appConfig[0]->sync_type; 3081 3082 if($autosync_status == 1){ 3083 global $woocommerce,$product; 3084 3085 $productsbulk_data = array(); 3086 $getselected_data = $_REQUEST['post']; 3087 3088 foreach ($_REQUEST['post'] as $product_id) { 3089 3090 $product_list = wc_get_product($product_id); 3091 3092 $priceCurrency = get_option('woocommerce_currency'); 3093 3094 $name = $product_list->get_name(); 3095 3096 $pricebulk = ($product_list->get_price() != '') ? $product_list->get_price() : ''; 3097 $sku = ($product_list->get_sku() != '') ? $product_list->get_sku() : $product_id; 3098 $description = ($product_list->get_description() != '') ? $product_list->get_description() : ''; 3099 $model = ($product_list->get_sku() != '') ? $product_list->get_sku() : $product_id; 3100 3101 $category = ($product_list->get_categories() != '') ? trim($product_list->get_categories()) : ''; 3102 $category = strip_tags($category); 3103 $category = strtolower($category); 3104 3105 if ($category == "uncategorized") { 3106 $category = ""; 3107 } 3108 3109 $category_into_array= explode(",",$category); 3110 $category_into_array=array_map('trim',$category_into_array); 3111 $final_array = array_merge($category_into_array,$cat_name); 3112 $new_final_array = array_unique($final_array); 3113 3114 3115 $productsbulk_data['priceCurrency'] = $priceCurrency; 3116 $productsbulk_data['id'] = $product_id; 3117 $productsbulk_data['category'] = implode(',',$new_final_array); 3118 $productsbulk_data['description'] = $description; 3119 $productsbulk_data['model'] = $model; 3120 $productsbulk_data['price'] = (100*(float)$_GET['_regular_price']) ? (100*(float)$_GET['_regular_price']) : 100*($pricebulk); 3121 $productsbulk_data['name'] = $name; 3122 $productsbulk_data['sku'] = $sku; 3123 $data[] = $productsbulk_data; 3124 3125 } 3126 3127 $productbulk_array['data'] = $data; 3128 $productbulk_Json = json_encode($productbulk_array); 3129 $base_url = AfterInc::API_BASE_URL; 3130 $url = $base_url . 'products/batch/outlet/' . $quick_store_id . '?upsert=true'; 3131 3132 $body = array( 3133 'headers' => array( 3134 'Content-Type' => 'application/json', 3135 'X-QUICKCOVER-API-KEY' => $api_key 3136 ), 3137 'body' => $productbulk_Json, 3138 'method' => 'POST', 3139 'timeout' => 300 3140 ); 3141 3142 $response = wp_remote_post($url, $body); 3143 $response_status = wp_remote_retrieve_response_code($response); 3144 $response = wp_remote_retrieve_body($response); 3145 $table_name = $this->wpdb->prefix . 'postmeta'; 3146 3147 if($response_status == 202){ 3148 3149 foreach ($productbulk_array['data'] as $postid){ 3150 3151 update_post_meta((int)$postid['id'], '_sync', 'Synced'); 3152 } 3153 3154 plugin_log(['status' => $response_status, 'response' => $response, 'request' => $productbulk_Json]); 3155 } 3156 3157 else 3158 { 3159 foreach ($productbulk_array['data'] as $postid ){ 3160 3161 update_post_meta((int)$postid['id'], '_sync', 'Failed'); 3162 } 3163 plugin_log(['status' => $response_status, 'response' => $response, 'request' => $productbulk_Json]); 3164 } 3165 } else{ 3166 3167 foreach ($getselected_data as $postid ){ 3168 3169 update_post_meta((int)$postid, '_sync', 'Not Synced'); 3170 } 3171 3172 plugin_log(['status' => $response_status, 'response' => $response, 'request' => $productbulk_Json]); 3173 } 3174 } 3175 } 3176 } 3056 3177 3057 3178 -
afterinc-app/trunk/readme.txt
r2925221 r2925247 7 7 Requires PHP: 7.2 8 8 WC tested up to: 5.6.0 9 Stable tag: 3.6. 69 Stable tag: 3.6.7 10 10 License: GPLv3 11 11 License URI: https://www.afterinc.com
Note: See TracChangeset
for help on using the changeset viewer.