Changeset 2903804
- Timestamp:
- 04/25/2023 10:05:43 AM (3 years ago)
- Location:
- abrestan/trunk
- Files:
-
- 6 edited
-
abrestan.php (modified) (2 diffs)
-
assets/js/custom210.js (modified) (6 diffs)
-
inc/Api/abrestan_CreateFactor.php (modified) (5 diffs)
-
inc/Api/abrestan_sync_orders.php (modified) (1 diff)
-
inc/Controller/ProductDetails.php (modified) (1 diff)
-
templates/admin/admin.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
abrestan/trunk/abrestan.php
r2643897 r2903804 4 4 * Plugin URI: abrestan.com 5 5 * Description: Using this web service, you can connect your store to abrestan cloud accounting software. 6 * Version: 2.2. 36 * Version: 2.2.6 7 7 * Author: KTE 8 8 * WC requires at least: 4.1.0 … … 180 180 { 181 181 $logs = get_log(); 182 unlink(__DIR__ . "/abrestan_logs.log"); 182 if (file_exists(__DIR__ . "/abrestan_logs.log")){ 183 unlink(__DIR__ . "/abrestan_logs.log"); 184 } 185 183 186 $file = fopen(__DIR__ . "/abrestan_logs.log", "a"); 184 187 foreach ($logs as $log) { -
abrestan/trunk/assets/js/custom210.js
r2636452 r2903804 144 144 dataType: 'json', 145 145 success: function (response) { 146 $('.loader').show(); 146 147 send_order(response) 147 $('.loader').show();148 148 } 149 149 }); … … 170 170 dataType: 'json', 171 171 success: function (response) { 172 172 173 $('#alert-success-sync_orders').each(function (){ 173 174 $(this).removeClass(); … … 208 209 dataType: 'json', 209 210 success: function (response) { 210 console.log(response) 211 211 212 $(".loader").hide(); 212 213 $("#abrestan_setting_btn").removeAttr('disabled', 'disabled'); … … 246 247 'orders': part_data, 247 248 }; 248 console.log(data) 249 249 250 250 251 $.ajax({ … … 255 256 async: false, 256 257 success: function (res) { 257 $('#alert-success-sync_orders').each(function (){258 $(this).removeClass();259 $(this).addClass("uk-alert uk-alert-success");260 $(this).show();261 $(this).children("p").text("عملیات با موفقیت انجام شد. جهت کسب اطلاعات بیشتر رخداد هارا بررسی بفرمایید!");262 })263 258 264 259 } … … 267 262 } 268 263 } 269 264 $('#alert-success-sync_orders').each(function (){ 265 $(this).removeClass(); 266 $(this).addClass("uk-alert uk-alert-success"); 267 $(this).show(); 268 $(this).children("p").text("عملیات با موفقیت انجام شد. جهت کسب اطلاعات بیشتر رخداد هارا بررسی بفرمایید!"); 269 }) 270 270 $(".loader").hide(); 271 271 $("#abrestan_sync_orders_btn").removeAttr('disabled', 'disabled'); -
abrestan/trunk/inc/Api/abrestan_CreateFactor.php
r2636452 r2903804 25 25 return $randomString; 26 26 } 27 public function tr_num($str, $mod = 'en', $mf = '٫') { 28 $num_a = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'); 29 $key_a = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $mf); 30 return ($mod == 'fa') ? str_replace($num_a, $key_a, $str) : str_replace($key_a, $num_a, $str); 31 } 27 32 28 33 public function create_factor($order_id) 29 34 { 35 $hidden_order_itemmeta = apply_filters( 36 'woocommerce_hidden_order_itemmeta', 37 array( 38 '_qty', 39 '_tax_class', 40 '_product_id', 41 '_variation_id', 42 '_line_subtotal', 43 '_line_subtotal_tax', 44 '_line_total', 45 '_line_tax', 46 'method_id', 47 'cost', 48 '_reduced_stock', 49 '_restock_refunded_items', 50 ) 51 ); 52 53 54 55 30 56 $item_details = new ItemsDetails(); 31 57 $order = wc_get_order($order_id); … … 39 65 $custmerLastName = $order_billing_data['last_name']; 40 66 41 if ($custmer_id == 0) { 42 if (abrestan_string_to_bool(get_option('abrestan_setting')['AddCustomerToOrder'])) { 43 $lastUser = get_user_by('login', $order_billing_data['phone']); 44 45 if ($lastUser) { 46 $custmer_id = $lastUser->ID; 67 $user = new \WP_User($custmer_id); 68 69 if (!$user->exists()) { 70 var_dump($this->tr_num($order_billing_data['phone'])); 71 72 73 74 75 76 $custmerFirstName = ($order_billing_data['first_name'])?$order_billing_data['first_name']:(($order_billing_data['last_name'])?$order_billing_data['last_name']:"کاربر"); 77 $custmerLastName = ($order_billing_data['last_name'])?$order_billing_data['last_name']:(($order_billing_data['first_name'])?$order_billing_data['first_name']:"مهمان");; 78 $custmerUserLogin = ($order_billing_data['phone'])?$this->tr_num($order_billing_data['phone']):$this->randomStr(12); 79 $custmerUserEmail = ($order_billing_data['email'])?$order_billing_data['email']:""; 80 81 var_dump($custmerFirstName); 82 var_dump($custmerLastName); 83 var_dump($custmerUserLogin); 84 var_dump($custmerUserEmail); 85 var_dump($custmer_id); 86 87 if ($custmer_id == 0) { 88 if (abrestan_string_to_bool(get_option('abrestan_setting')['AddCustomerToOrder'])) { 89 $lastUser = get_user_by('login', $order_billing_data['phone']); 90 91 if ($lastUser) { 92 $custmer_id = $lastUser->ID; 93 update_post_meta($order->get_id(), '_customer_user', $custmer_id); 94 } else { 95 $userdata = array( 96 'user_pass' => $this->randomStr(12), //(string) The plain-text user password. 97 'user_login' => $custmerUserLogin, //(string) The user's login username. 98 'user_email' => $custmerUserEmail, //(string) The user email address. 99 'display_name' => $custmerFirstName . " " . $custmerLastName, //(string) The user's display name. Default is the user's username. 100 'first_name' => $custmerFirstName, //(string) The user's first name. For new users, will be used to build the first part of the user's display name if $display_name is not specified. 101 'last_name' => $custmerLastName, //(string) The user's last name. For new users, will be used to build the second part of the user's display name if $display_name is not specified. 102 'role' => 'Customer', 103 ); 104 $user_id = wp_insert_user($userdata); 105 update_post_meta($order->get_id(), '_customer_user', $user_id); 106 $custmer_id = $user_id; 107 } 108 } else { 109 $custmer_id = "9999"; 110 $custmerFirstName = "کاربر"; 111 $custmerLastName = "مهمان"; 112 } 113 114 } else { 115 116 117 118 $lastUserbymobile = get_user_by('login', $order_billing_data['phone']); 119 $lastUserbyemail = get_user_by('email', $order_billing_data['email']); 120 121 if ($lastUserbymobile) { 122 $custmer_id = $lastUserbymobile->ID; 123 update_post_meta($order->get_id(), '_customer_user', $custmer_id); 124 } elseif ($lastUserbyemail) { 125 $custmer_id = $lastUserbyemail->ID; 47 126 update_post_meta($order->get_id(), '_customer_user', $custmer_id); 48 127 } else { 49 128 $userdata = array( 50 129 'user_pass' => $this->randomStr(12), //(string) The plain-text user password. 51 'user_login' => $ order_billing_data['phone'], //(string) The user's login username.52 'user_email' => $ order_billing_data['email'], //(string) The user email address.130 'user_login' => $custmerUserLogin, //(string) The user's login username. 131 'user_email' => $custmerUserEmail, //(string) The user email address. 53 132 'display_name' => $custmerFirstName . " " . $custmerLastName, //(string) The user's display name. Default is the user's username. 54 133 'first_name' => $custmerFirstName, //(string) The user's first name. For new users, will be used to build the first part of the user's display name if $display_name is not specified. … … 60 139 $custmer_id = $user_id; 61 140 } 62 } else {63 $custmer_id = "9999";64 $custmerFirstName = "کاربر";65 $custmerLastName = "مهمان";66 141 } 142 67 143 68 144 } … … 75 151 76 152 153 77 154 if ($product_id != "error") { 78 $product_name = $product_details->get_product_name($product_id); 155 156 157 158 159 160 161 162 163 $product_name = $product_details->get_product_name($order_item); 79 164 $product_quantity = $product_data['quantity']; 80 165 $product_price = $item_details->covert_price($product_data['subtotal'] / $product_data['quantity'], $order_currency); … … 134 219 } 135 220 221 136 222 return $factor; 137 223 -
abrestan/trunk/inc/Api/abrestan_sync_orders.php
r2643897 r2903804 129 129 $result = json_decode(wp_remote_retrieve_body($wp_remote_post), true); 130 130 131 var_dump($result); 132 131 133 if ($result['code'] == 105) { 132 134 -
abrestan/trunk/inc/Controller/ProductDetails.php
r2597509 r2903804 33 33 return $product_id; 34 34 } 35 public function get_product_name($ product_id)35 public function get_product_name($item) 36 36 { 37 $product=$this->get_product($product_id); 38 $product_name=$product->get_data()['name']; 37 $hidden_order_itemmeta = apply_filters( 38 'woocommerce_hidden_order_itemmeta', 39 array( 40 '_qty', 41 '_tax_class', 42 '_product_id', 43 '_variation_id', 44 '_line_subtotal', 45 '_line_subtotal_tax', 46 '_line_total', 47 '_line_tax', 48 'method_id', 49 'cost', 50 '_reduced_stock', 51 '_restock_refunded_items', 52 ) 53 ); 54 $product_name=$item->get_name(); 55 $meta_data = $item->get_all_formatted_meta_data( '' ); 56 if ( $meta_data ){ 57 if (count($meta_data)>1){ 58 foreach ( $meta_data as $meta_id => $meta ){ 59 if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) { 60 continue; 61 } 62 $product_name=$product_name." - ".strip_tags(wp_kses_post( force_balance_tags( $meta->display_value ))); 63 64 } 65 } 66 67 } 68 39 69 40 70 return $product_name; -
abrestan/trunk/templates/admin/admin.php
r2636452 r2903804 1 1 <?php 2 $login=false; 2 3 if (get_option('abrestan_login')) { 3 4 $login = true; … … 174 175 <?php 175 176 $companies = get_option('abrestan_companies_list'); 177 176 178 $i = 0; 177 foreach ($companies as $company) { 178 ?> 179 <option <?php echo (get_option('abrestan_company')['companyCode'] == esc_attr($company['company_id'])) ? 'selected' : ''; ?> 180 value=<?php echo esc_attr($company['company_id']) ?>><?php echo esc_attr($company['company_name']) ?></option> 181 <?php 182 $i++; 179 if ($companies){ 180 foreach ($companies as $company) { 181 ?> 182 <option <?php echo (get_option('abrestan_company') && get_option('abrestan_company')['companyCode'] == esc_attr($company['company_id'])) ? 'selected' : ''; ?> 183 value="<?php echo esc_attr($company['company_id']) ?>"><?php echo esc_attr($company['company_name']) ?></option> 184 <?php 185 $i++; 186 } 183 187 } 188 184 189 ?> 185 190 </select> … … 220 225 for="from-date"><?php _e('from date', 'abrestan'); ?></label> 221 226 <input dir="ltr" class="uk-input uk-form-width-small" id="from-date" type="text" 222 name="from-date" placeholder="1400/01/01" value="140 0/01/01">227 name="from-date" placeholder="1400/01/01" value="1401/05/01"> 223 228 </div> 224 229 <div class="uk-margin uk-grid "> … … 226 231 for="to-date"><?php _e('to date', 'abrestan'); ?></label> 227 232 <input dir="ltr" class="uk-input uk-form-width-small" id="to-date" type="text" 228 name="to-date" placeholder="1400/12/29" value="140 0/12/29">233 name="to-date" placeholder="1400/12/29" value="1401/05/29"> 229 234 </div> 230 235 <div class="uk-margin">
Note: See TracChangeset
for help on using the changeset viewer.