Changeset 3252598
- Timestamp:
- 03/08/2025 06:07:17 PM (13 months ago)
- Location:
- ilachat/trunk
- Files:
-
- 4 edited
-
ilachat.php (modified) (1 diff)
-
languages/ilachat.pot (modified) (4 diffs)
-
src/Integrations/Woocommerce.php (modified) (13 diffs)
-
templates/admin/wc-integration-page.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ilachat/trunk/ilachat.php
r3252285 r3252598 45 45 46 46 // Define constants 47 define('ILACHAT_VERSION', '1. 0.3');47 define('ILACHAT_VERSION', '1.1.0'); 48 48 define('ILACHAT_ROOT', __FILE__); 49 49 define('ILACHAT_PATH', plugin_dir_path(ILACHAT_ROOT)); -
ilachat/trunk/languages/ilachat.pot
r3252285 r3252598 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: ILACHAT - AI Chatbot & Live Chat 1. 0.3\n"5 "Project-Id-Version: ILACHAT - AI Chatbot & Live Chat 1.1.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/ilachat\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2025-03-0 7T16:58:33+01:00\n"12 "POT-Creation-Date: 2025-03-08T19:02:38+01:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.11.0\n" … … 80 80 msgstr "" 81 81 82 #: src/Integrations/Woocommerce.php:17 583 #: src/Integrations/Woocommerce.php:17 684 #: src/Integrations/Woocommerce.php: 20185 #: templates/admin/wc-integration-page.php:5 582 #: src/Integrations/Woocommerce.php:170 83 #: src/Integrations/Woocommerce.php:171 84 #: src/Integrations/Woocommerce.php:196 85 #: templates/admin/wc-integration-page.php:54 86 86 msgid "WooCommerce Integration" 87 87 msgstr "" 88 88 89 #: src/Integrations/Woocommerce.php:35 689 #: src/Integrations/Woocommerce.php:351 90 90 msgid "Order tracking is disabled" 91 91 msgstr "" 92 92 93 #: src/Integrations/Woocommerce.php:359 94 msgid "Order ID is required" 95 msgstr "" 96 93 97 #: src/Integrations/Woocommerce.php:364 94 msgid "Order ID is required"98 msgid "Order not found" 95 99 msgstr "" 96 100 97 101 #: src/Integrations/Woocommerce.php:369 98 msgid " Order not found"102 msgid "Invalid phone number" 99 103 msgstr "" 100 104 101 105 #: src/Integrations/Woocommerce.php:374 102 msgid "Invalid phone number"103 msgstr ""104 105 #: src/Integrations/Woocommerce.php:379106 106 msgid "Invalid email address" 107 107 msgstr "" 108 108 109 #: src/Integrations/Woocommerce.php:5 53110 #: src/Integrations/Woocommerce.php:62 4109 #: src/Integrations/Woocommerce.php:549 110 #: src/Integrations/Woocommerce.php:620 111 111 msgid "Please enter a note." 112 112 msgstr "" 113 113 114 #: src/Integrations/Woocommerce.php:55 4114 #: src/Integrations/Woocommerce.php:550 115 115 msgid "An error occurred while doing the request." 116 116 msgstr "" 117 117 118 #: src/Integrations/Woocommerce.php:55 5118 #: src/Integrations/Woocommerce.php:551 119 119 #: templates/admin/wc-order-notes.php:38 120 120 msgid "Delete note" 121 121 msgstr "" 122 122 123 #: src/Integrations/Woocommerce.php:55 6123 #: src/Integrations/Woocommerce.php:552 124 124 msgid "Are you sure you want to delete this note? This action cannot be undone." 125 125 msgstr "" 126 126 127 #: src/Integrations/Woocommerce.php:57 6127 #: src/Integrations/Woocommerce.php:572 128 128 msgid "Ilachat Order Notes" 129 129 msgstr "" 130 130 131 #: src/Integrations/Woocommerce.php:61 9131 #: src/Integrations/Woocommerce.php:615 132 132 msgid "Invalid order." 133 133 msgstr "" 134 134 135 #: src/Integrations/Woocommerce.php:62 9135 #: src/Integrations/Woocommerce.php:625 136 136 msgid "Failed to add note." 137 137 msgstr "" 138 138 139 #: src/Integrations/Woocommerce.php:69 9139 #: src/Integrations/Woocommerce.php:695 140 140 msgid "Failed to delete note." 141 141 msgstr "" 142 142 143 #: src/Integrations/Woocommerce.php:8 39144 #: src/Integrations/Woocommerce.php:8 50143 #: src/Integrations/Woocommerce.php:876 144 #: src/Integrations/Woocommerce.php:887 145 145 msgid "Failed to sync product with Ilachat." 146 146 msgstr "" 147 147 148 #: src/Integrations/Woocommerce.php:8 59148 #: src/Integrations/Woocommerce.php:896 149 149 msgid "Product synced successfully with Ilachat." 150 150 msgstr "" 151 151 152 #: src/Integrations/Woocommerce.php:888 152 #: src/Integrations/Woocommerce.php:924 153 msgid "Sync with Ilachat" 154 msgstr "" 155 156 #: src/Integrations/Woocommerce.php:926 153 157 msgid "Last synced:" 154 158 msgstr "" … … 198 202 msgstr "" 199 203 200 #: templates/admin/wc-integration-page.php:5 8204 #: templates/admin/wc-integration-page.php:57 201 205 msgid "Enable the integration between Ilachat and WooCommerce." 202 206 msgstr "" 203 207 204 #: templates/admin/wc-integration-page.php:6 2208 #: templates/admin/wc-integration-page.php:61 205 209 msgid "Product Sync" 206 210 msgstr "" 207 211 212 #: templates/admin/wc-integration-page.php:64 213 msgid "Enable product synchronization with Ilachat." 214 msgstr "" 215 208 216 #: templates/admin/wc-integration-page.php:65 209 msgid "Enable product synchronization with Ilachat."210 msgstr ""211 212 #: templates/admin/wc-integration-page.php:66213 217 msgid "This will automatically sync your WooCommerce products with Ilachat whenever a product is updated." 214 218 msgstr "" 215 219 216 #: templates/admin/wc-integration-page.php: 70217 #: templates/admin/wc-integration-page.php:7 3220 #: templates/admin/wc-integration-page.php:69 221 #: templates/admin/wc-integration-page.php:72 218 222 msgid "Order Tracking" 219 223 msgstr "" 220 224 221 #: templates/admin/wc-integration-page.php:7 6225 #: templates/admin/wc-integration-page.php:75 222 226 msgid "Enable order tracking through the REST API." 223 227 msgstr "" 224 228 225 #: templates/admin/wc-integration-page.php: 80229 #: templates/admin/wc-integration-page.php:79 226 230 msgid "Authorizations" 227 231 msgstr "" 228 232 229 #: templates/admin/wc-integration-page.php:8 3233 #: templates/admin/wc-integration-page.php:82 230 234 msgid "Validate the phone number during order tracking." 231 235 msgstr "" 232 236 233 #: templates/admin/wc-integration-page.php:8 5237 #: templates/admin/wc-integration-page.php:84 234 238 msgid "Validate the email address during order tracking." 235 239 msgstr "" 236 240 237 #: templates/admin/wc-integration-page.php: 90241 #: templates/admin/wc-integration-page.php:89 238 242 msgid "Allowed Order Data" 239 243 msgstr "" 240 244 245 #: templates/admin/wc-integration-page.php:93 246 msgid "Billing Information" 247 msgstr "" 248 241 249 #: templates/admin/wc-integration-page.php:94 242 msgid " Billing Information"250 msgid "Shipping Information" 243 251 msgstr "" 244 252 245 253 #: templates/admin/wc-integration-page.php:95 246 msgid " Shipping Information"254 msgid "Purchased Items Details" 247 255 msgstr "" 248 256 249 257 #: templates/admin/wc-integration-page.php:96 250 msgid "Purchased Items Details"251 msgstr ""252 253 #: templates/admin/wc-integration-page.php:97254 258 msgid "Order Notes" 255 259 msgstr "" 256 260 257 #: templates/admin/wc-integration-page.php:10 8261 #: templates/admin/wc-integration-page.php:107 258 262 msgid "Select the user order data fields to expose via the REST API." 259 263 msgstr "" 260 264 261 #: templates/admin/wc-integration-page.php:11 2265 #: templates/admin/wc-integration-page.php:111 262 266 msgid "Special Order Note" 263 267 msgstr "" 264 268 269 #: templates/admin/wc-integration-page.php:114 270 msgid "Enable special order notes functionality." 271 msgstr "" 272 265 273 #: templates/admin/wc-integration-page.php:115 266 msgid "Enable special order notes functionality."267 msgstr ""268 269 #: templates/admin/wc-integration-page.php:116270 274 msgid "This will add a special meta box to the order edit screen for adding additional notes exclusive to Ilachat." 271 275 msgstr "" 272 276 273 #: templates/admin/wc-integration-page.php:1 20274 #: templates/admin/wc-integration-page.php:12 3277 #: templates/admin/wc-integration-page.php:119 278 #: templates/admin/wc-integration-page.php:122 275 279 msgid "Order Statuses Description" 276 280 msgstr "" 277 281 278 #: templates/admin/wc-integration-page.php:12 9282 #: templates/admin/wc-integration-page.php:128 279 283 msgid "Provide a description for each order status." 280 284 msgstr "" -
ilachat/trunk/src/Integrations/Woocommerce.php
r3252285 r3252598 119 119 'ilachat_woocommerce_product_sync_enabled' => [ 120 120 'type' => 'boolean', 121 'default' => true,121 'default' => false, 122 122 'sanitize_callback' => [$this, 'sanitize_boolean'], 123 ],124 'ilachat_woocommerce_secret_key' => [125 'type' => 'string',126 'default' => '',127 'sanitize_callback' => 'sanitize_text_field',128 123 ], 129 124 ]; … … 267 262 'enabled' => $rest_enabled, 268 263 'link' => $registered_route, 269 'sec_key' => $this-> secret_key,264 'sec_key' => $this->get_secret_key(), 270 265 'auth_items' => ['order_id'] 271 266 ]; … … 328 323 'required' => $phone_required, 329 324 'validate_callback' => function ($param) { 330 return is_ numeric($param);325 return is_string($param); 331 326 }, 332 327 ], … … 387 382 'date_of_order_creation' => $this->get_date($order->get_date_created()), 388 383 'date_of_order_completion' => $this->get_date($order->get_date_completed()), 389 'order_total' => $order->get_total() . ' ' . $order->get_currency(),390 'order_status' => $order->get_status(),384 'order_total' => $order->get_total() . ' ' . get_woocommerce_currency_symbol($order->get_currency()), 385 'order_status' => wc_get_order_status_name($order->get_status()), 391 386 ]; 392 387 393 388 $order_status_description = get_option('ilachat_woocommerce_order_statuses_description', []); 394 if (isset($order_status_description[$order->get_status()])) { 395 $data['order_status_description'] = $order_status_description[$order->get_status()]; 389 $status_key = 'wc-' . $order->get_status(); 390 if (isset($order_status_description[$status_key])) { 391 $data['order_status_description'] = $order_status_description[$status_key]; 396 392 } 397 393 … … 435 431 [ 436 432 'item_name' => $item->get_name(), 437 'item_quantity' => '"' . $item->get_quantity() . '"',438 'item_total' => '"' . $item->get_total() . '" ' . $order->get_currency(),433 'item_quantity' => $item->get_quantity(), 434 'item_total' => $item->get_total() . ' ' . get_woocommerce_currency_symbol($order->get_currency()), 439 435 ], 440 436 $item, … … 502 498 { 503 499 $secret_key = $request->get_header('X-ILACHAT-SECRET-KEY') ?: ''; 504 if (! $secret_key || ! hash_equals($this-> secret_key, $secret_key)) {500 if (! $secret_key || ! hash_equals($this->get_secret_key(), $secret_key)) { 505 501 return false; 506 502 } … … 774 770 public function sync_product($post_id, $post) 775 771 { 776 if (! get_option('ilachat_woocommerce_product_sync_enabled')) { 772 if ( 773 ! isset($_POST['ilachat_sync_product_nonce']) || 774 ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['ilachat_sync_product_nonce'])), 'ilachat_sync_product') 775 ) { 776 return; 777 } 778 779 if (! current_user_can('edit_post', $post_id)) { 780 return; 781 } 782 783 if (! isset($_POST['ilachat_sync_product'])) { 777 784 return; 778 785 } … … 795 802 ]; 796 803 804 // Add excerpt to the description. 805 $excerpt = $product->get_short_description(); 806 if ($excerpt) { 807 $body['description'] = $excerpt . "\n" . $body['description']; 808 } 809 810 // Add product attributes to the description. 811 $attributes = $product->get_attributes(); 812 $attributes_str = ''; 813 foreach ($attributes as $attribute) { 814 if ($attribute->is_taxonomy()) { 815 $attr_name = wc_attribute_label($attribute->get_name()); 816 $options_ids = $attribute->get_options(); 817 $attr_options = array(); 818 819 foreach ($options_ids as $option_id) { 820 $term = get_term_by('id', $option_id, $attribute->get_name()); 821 if ($term && ! is_wp_error($term)) { 822 $attr_options[] = $term->name; 823 } 824 } 825 } else { 826 $attr_name = $attribute->get_name(); 827 $attr_options = $attribute->get_options(); 828 } 829 830 $attributes_str .= $attr_name . ': ' . implode(', ', $attr_options) . "\n"; 831 } 832 $body['description'] = $attributes_str . $body['description']; 833 797 834 $parent_available = $product->is_in_stock(); 798 835 … … 803 840 $body['variations'][] = [ 804 841 'name' => $variation->get_name(), 805 'price' => $variation->get_price() ,842 'price' => $variation->get_price() . ' ' . get_woocommerce_currency_symbol(), 806 843 'description' => $variation->get_description() ?: '', 807 844 'available' => $parent_available ? $variation->is_in_stock() : false, … … 813 850 $body['variations'][] = [ 814 851 'name' => $product->get_name(), 815 'price' => $product->get_price() ,852 'price' => $product->get_price() . ' ' . get_woocommerce_currency_symbol(), 816 853 'available' => $parent_available, 817 854 'image' => $product->get_image_id() ? wp_get_attachment_url($product->get_image_id()) : '', … … 860 897 } 861 898 ); 862 update_post_meta($post_id, 'ilachat_synced', time());899 update_post_meta($post_id, 'ilachat_synced', current_time('mysql')); 863 900 } 864 901 … … 881 918 882 919 $last_synced = $product->get_meta('ilachat_synced', true); 920 $sync_active = get_option('ilachat_woocommerce_product_sync_enabled', false); 921 922 echo '<div class="misc-pub-section misc-pub-ilachat">'; 923 wp_nonce_field('ilachat_sync_product', 'ilachat_sync_product_nonce'); 924 echo '<label><input type="checkbox" name="ilachat_sync_product" value="1" ' . checked($sync_active, true, false) . ' /> ' . esc_html__('Sync with Ilachat', 'ilachat') . '</label>'; 883 925 if ($last_synced) { 884 $last_synced = gmdate('Y-m-d H:i:s', $last_synced); 885 } 886 887 echo '<div class="misc-pub-section misc-pub-ilachat-synced">'; 888 echo '<span>' . esc_html__('Last synced:', 'ilachat') . ' ' . esc_html($last_synced) . '</span>'; 926 echo '<p class="description">' . esc_html__('Last synced:', 'ilachat') . ' ' . esc_html($this->get_date($last_synced)) . '</p>'; 927 } 889 928 echo '</div>'; 890 929 } … … 901 940 public function get_secret_key() 902 941 { 903 $secret_key = get_option('ilachat_woocommerce_secret_key' );904 if ( ! $secret_key) {942 $secret_key = get_option('ilachat_woocommerce_secret_key', ''); 943 if (empty($secret_key)) { 905 944 $secret_key = wp_generate_password(32, false); 906 945 update_option('ilachat_woocommerce_secret_key', $secret_key); -
ilachat/trunk/templates/admin/wc-integration-page.php
r3252285 r3252598 47 47 $order_special_note = get_option('ilachat_woocommerce_order_special_note'); 48 48 $product_sync_enabled = get_option('ilachat_woocommerce_product_sync_enabled'); 49 $secret_key = get_option('ilachat_woocommerce_secret_key');50 49 $order_statuses_json = ! empty($order_statuses_description) ? json_encode($order_statuses_description, JSON_PRETTY_PRINT) : ''; 51 50 ?>
Note: See TracChangeset
for help on using the changeset viewer.