Plugin Directory

Changeset 3252598


Ignore:
Timestamp:
03/08/2025 06:07:17 PM (13 months ago)
Author:
ilachat
Message:

Fix v1.1.0 update

Location:
ilachat/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ilachat/trunk/ilachat.php

    r3252285 r3252598  
    4545
    4646// Define constants
    47 define('ILACHAT_VERSION', '1.0.3');
     47define('ILACHAT_VERSION', '1.1.0');
    4848define('ILACHAT_ROOT', __FILE__);
    4949define('ILACHAT_PATH', plugin_dir_path(ILACHAT_ROOT));
  • ilachat/trunk/languages/ilachat.pot

    r3252285 r3252598  
    33msgid ""
    44msgstr ""
    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"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/ilachat\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2025-03-07T16:58:33+01:00\n"
     12"POT-Creation-Date: 2025-03-08T19:02:38+01:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.11.0\n"
     
    8080msgstr ""
    8181
    82 #: src/Integrations/Woocommerce.php:175
    83 #: src/Integrations/Woocommerce.php:176
    84 #: src/Integrations/Woocommerce.php:201
    85 #: templates/admin/wc-integration-page.php:55
     82#: 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
    8686msgid "WooCommerce Integration"
    8787msgstr ""
    8888
    89 #: src/Integrations/Woocommerce.php:356
     89#: src/Integrations/Woocommerce.php:351
    9090msgid "Order tracking is disabled"
    9191msgstr ""
    9292
     93#: src/Integrations/Woocommerce.php:359
     94msgid "Order ID is required"
     95msgstr ""
     96
    9397#: src/Integrations/Woocommerce.php:364
    94 msgid "Order ID is required"
     98msgid "Order not found"
    9599msgstr ""
    96100
    97101#: src/Integrations/Woocommerce.php:369
    98 msgid "Order not found"
     102msgid "Invalid phone number"
    99103msgstr ""
    100104
    101105#: src/Integrations/Woocommerce.php:374
    102 msgid "Invalid phone number"
    103 msgstr ""
    104 
    105 #: src/Integrations/Woocommerce.php:379
    106106msgid "Invalid email address"
    107107msgstr ""
    108108
    109 #: src/Integrations/Woocommerce.php:553
    110 #: src/Integrations/Woocommerce.php:624
     109#: src/Integrations/Woocommerce.php:549
     110#: src/Integrations/Woocommerce.php:620
    111111msgid "Please enter a note."
    112112msgstr ""
    113113
    114 #: src/Integrations/Woocommerce.php:554
     114#: src/Integrations/Woocommerce.php:550
    115115msgid "An error occurred while doing the request."
    116116msgstr ""
    117117
    118 #: src/Integrations/Woocommerce.php:555
     118#: src/Integrations/Woocommerce.php:551
    119119#: templates/admin/wc-order-notes.php:38
    120120msgid "Delete note"
    121121msgstr ""
    122122
    123 #: src/Integrations/Woocommerce.php:556
     123#: src/Integrations/Woocommerce.php:552
    124124msgid "Are you sure you want to delete this note? This action cannot be undone."
    125125msgstr ""
    126126
    127 #: src/Integrations/Woocommerce.php:576
     127#: src/Integrations/Woocommerce.php:572
    128128msgid "Ilachat Order Notes"
    129129msgstr ""
    130130
    131 #: src/Integrations/Woocommerce.php:619
     131#: src/Integrations/Woocommerce.php:615
    132132msgid "Invalid order."
    133133msgstr ""
    134134
    135 #: src/Integrations/Woocommerce.php:629
     135#: src/Integrations/Woocommerce.php:625
    136136msgid "Failed to add note."
    137137msgstr ""
    138138
    139 #: src/Integrations/Woocommerce.php:699
     139#: src/Integrations/Woocommerce.php:695
    140140msgid "Failed to delete note."
    141141msgstr ""
    142142
    143 #: src/Integrations/Woocommerce.php:839
    144 #: src/Integrations/Woocommerce.php:850
     143#: src/Integrations/Woocommerce.php:876
     144#: src/Integrations/Woocommerce.php:887
    145145msgid "Failed to sync product with Ilachat."
    146146msgstr ""
    147147
    148 #: src/Integrations/Woocommerce.php:859
     148#: src/Integrations/Woocommerce.php:896
    149149msgid "Product synced successfully with Ilachat."
    150150msgstr ""
    151151
    152 #: src/Integrations/Woocommerce.php:888
     152#: src/Integrations/Woocommerce.php:924
     153msgid "Sync with Ilachat"
     154msgstr ""
     155
     156#: src/Integrations/Woocommerce.php:926
    153157msgid "Last synced:"
    154158msgstr ""
     
    198202msgstr ""
    199203
    200 #: templates/admin/wc-integration-page.php:58
     204#: templates/admin/wc-integration-page.php:57
    201205msgid "Enable the integration between Ilachat and WooCommerce."
    202206msgstr ""
    203207
    204 #: templates/admin/wc-integration-page.php:62
     208#: templates/admin/wc-integration-page.php:61
    205209msgid "Product Sync"
    206210msgstr ""
    207211
     212#: templates/admin/wc-integration-page.php:64
     213msgid "Enable product synchronization with Ilachat."
     214msgstr ""
     215
    208216#: templates/admin/wc-integration-page.php:65
    209 msgid "Enable product synchronization with Ilachat."
    210 msgstr ""
    211 
    212 #: templates/admin/wc-integration-page.php:66
    213217msgid "This will automatically sync your WooCommerce products with Ilachat whenever a product is updated."
    214218msgstr ""
    215219
    216 #: templates/admin/wc-integration-page.php:70
    217 #: templates/admin/wc-integration-page.php:73
     220#: templates/admin/wc-integration-page.php:69
     221#: templates/admin/wc-integration-page.php:72
    218222msgid "Order Tracking"
    219223msgstr ""
    220224
    221 #: templates/admin/wc-integration-page.php:76
     225#: templates/admin/wc-integration-page.php:75
    222226msgid "Enable order tracking through the REST API."
    223227msgstr ""
    224228
    225 #: templates/admin/wc-integration-page.php:80
     229#: templates/admin/wc-integration-page.php:79
    226230msgid "Authorizations"
    227231msgstr ""
    228232
    229 #: templates/admin/wc-integration-page.php:83
     233#: templates/admin/wc-integration-page.php:82
    230234msgid "Validate the phone number during order tracking."
    231235msgstr ""
    232236
    233 #: templates/admin/wc-integration-page.php:85
     237#: templates/admin/wc-integration-page.php:84
    234238msgid "Validate the email address during order tracking."
    235239msgstr ""
    236240
    237 #: templates/admin/wc-integration-page.php:90
     241#: templates/admin/wc-integration-page.php:89
    238242msgid "Allowed Order Data"
    239243msgstr ""
    240244
     245#: templates/admin/wc-integration-page.php:93
     246msgid "Billing Information"
     247msgstr ""
     248
    241249#: templates/admin/wc-integration-page.php:94
    242 msgid "Billing Information"
     250msgid "Shipping Information"
    243251msgstr ""
    244252
    245253#: templates/admin/wc-integration-page.php:95
    246 msgid "Shipping Information"
     254msgid "Purchased Items Details"
    247255msgstr ""
    248256
    249257#: templates/admin/wc-integration-page.php:96
    250 msgid "Purchased Items Details"
    251 msgstr ""
    252 
    253 #: templates/admin/wc-integration-page.php:97
    254258msgid "Order Notes"
    255259msgstr ""
    256260
    257 #: templates/admin/wc-integration-page.php:108
     261#: templates/admin/wc-integration-page.php:107
    258262msgid "Select the user order data fields to expose via the REST API."
    259263msgstr ""
    260264
    261 #: templates/admin/wc-integration-page.php:112
     265#: templates/admin/wc-integration-page.php:111
    262266msgid "Special Order Note"
    263267msgstr ""
    264268
     269#: templates/admin/wc-integration-page.php:114
     270msgid "Enable special order notes functionality."
     271msgstr ""
     272
    265273#: templates/admin/wc-integration-page.php:115
    266 msgid "Enable special order notes functionality."
    267 msgstr ""
    268 
    269 #: templates/admin/wc-integration-page.php:116
    270274msgid "This will add a special meta box to the order edit screen for adding additional notes exclusive to Ilachat."
    271275msgstr ""
    272276
    273 #: templates/admin/wc-integration-page.php:120
    274 #: templates/admin/wc-integration-page.php:123
     277#: templates/admin/wc-integration-page.php:119
     278#: templates/admin/wc-integration-page.php:122
    275279msgid "Order Statuses Description"
    276280msgstr ""
    277281
    278 #: templates/admin/wc-integration-page.php:129
     282#: templates/admin/wc-integration-page.php:128
    279283msgid "Provide a description for each order status."
    280284msgstr ""
  • ilachat/trunk/src/Integrations/Woocommerce.php

    r3252285 r3252598  
    119119            'ilachat_woocommerce_product_sync_enabled' => [
    120120                'type'              => 'boolean',
    121                 'default'           => true,
     121                'default'           => false,
    122122                'sanitize_callback' => [$this, 'sanitize_boolean'],
    123             ],
    124             'ilachat_woocommerce_secret_key' => [
    125                 'type'              => 'string',
    126                 'default'           => '',
    127                 'sanitize_callback' => 'sanitize_text_field',
    128123            ],
    129124        ];
     
    267262            'enabled'    => $rest_enabled,
    268263            'link'       => $registered_route,
    269             'sec_key'    => $this->secret_key,
     264            'sec_key'    => $this->get_secret_key(),
    270265            'auth_items' => ['order_id']
    271266        ];
     
    328323                        'required'          => $phone_required,
    329324                        'validate_callback' => function ($param) {
    330                             return is_numeric($param);
     325                            return is_string($param);
    331326                        },
    332327                    ],
     
    387382            'date_of_order_creation'     => $this->get_date($order->get_date_created()),
    388383            '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()),
    391386        ];
    392387
    393388        $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];
    396392        }
    397393
     
    435431                    [
    436432                        '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()),
    439435                    ],
    440436                    $item,
     
    502498    {
    503499        $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)) {
    505501            return false;
    506502        }
     
    774770    public function sync_product($post_id, $post)
    775771    {
    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'])) {
    777784            return;
    778785        }
     
    795802        ];
    796803
     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
    797834        $parent_available = $product->is_in_stock();
    798835
     
    803840                $body['variations'][] = [
    804841                    'name'        => $variation->get_name(),
    805                     'price'       => $variation->get_price(),
     842                    'price'       => $variation->get_price() . ' ' . get_woocommerce_currency_symbol(),
    806843                    'description' => $variation->get_description() ?: '',
    807844                    'available'   => $parent_available ? $variation->is_in_stock() : false,
     
    813850            $body['variations'][] = [
    814851                'name'      => $product->get_name(),
    815                 'price'     => $product->get_price(),
     852                'price'     => $product->get_price() . ' ' . get_woocommerce_currency_symbol(),
    816853                'available' => $parent_available,
    817854                'image'     => $product->get_image_id() ? wp_get_attachment_url($product->get_image_id()) : '',
     
    860897            }
    861898        );
    862         update_post_meta($post_id, 'ilachat_synced', time());
     899        update_post_meta($post_id, 'ilachat_synced', current_time('mysql'));
    863900    }
    864901
     
    881918
    882919        $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>';
    883925        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        }
    889928        echo '</div>';
    890929    }
     
    901940    public function get_secret_key()
    902941    {
    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)) {
    905944            $secret_key = wp_generate_password(32, false);
    906945            update_option('ilachat_woocommerce_secret_key', $secret_key);
  • ilachat/trunk/templates/admin/wc-integration-page.php

    r3252285 r3252598  
    4747        $order_special_note          = get_option('ilachat_woocommerce_order_special_note');
    4848        $product_sync_enabled        = get_option('ilachat_woocommerce_product_sync_enabled');
    49         $secret_key                  = get_option('ilachat_woocommerce_secret_key');
    5049        $order_statuses_json         = ! empty($order_statuses_description) ? json_encode($order_statuses_description, JSON_PRETTY_PRINT) : '';
    5150        ?>
Note: See TracChangeset for help on using the changeset viewer.