Plugin Directory

Changeset 3264425


Ignore:
Timestamp:
03/31/2025 12:16:17 PM (12 months ago)
Author:
extendago
Message:

Version 1.6.5

Location:
extendago-wp-connection/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extendago-wp-connection/trunk/extendago-wp-connection.php

    r3262736 r3264425  
    44Plugin URI:  https://extendago-connect.com/
    55Description: The Wordpress plugin for connecting Woocommerce with Extenda GO / Wallmob. You can manage your products inside Extenda GO or make your webshop as leading foor product manangement. You Stock changes will be two-way binding.
    6 Version:     1.6.4
     6Version:     1.6.5
    77Requires Plugins: woocommerce
    88Author:      Arture B.V.
  • extendago-wp-connection/trunk/includes/admin/class-extendago-wp-connection-admin.php

    r3257883 r3264425  
    2121        add_filter('cron_schedules', array( $this, 'extenda_connect_cron_schedules') );
    2222
    23         if(isset($_POST['btnDownloadLog'])) {
    24             $this->downloadLogFile();
    25         }
    26 
    2723        add_filter('manage_edit-product_cat_columns', array($this, 'add_extenda_custom_product_cat_column'));
    2824        add_filter('manage_product_cat_custom_column', array($this, 'extenda_product_cat_custom_column_value'), 10, 3);
     25        add_action('admin_post_download_log', array($this, 'handle_log_download_request'));
     26    }
     27
     28    public function handle_log_download_request() {
     29        if (
     30            isset($_POST['btnDownloadLog']) &&
     31            current_user_can('manage_options') &&
     32            check_admin_referer('download_log_action', 'download_log_nonce')
     33        ) {
     34            $this->downloadLogFile();
     35        }
     36    }
     37
     38    public function downloadLogFile() {
     39        if ( ! current_user_can( 'manage_options' ) ) {
     40            wp_die( 'Unauthorized', '403 Forbidden', array( 'response' => 403 ) );
     41        }
     42
     43        $filename = isset($_POST['btnDownloadLog']) ? sanitize_file_name($_POST['btnDownloadLog']) : '';
     44
     45        $basedir = wp_upload_dir();
     46        $log_dir = $basedir['basedir'] . '/storecontrl/logs/';
     47        $full_path = realpath( $log_dir . $filename );
     48
     49        if (
     50            ! $full_path ||
     51            strpos($full_path, realpath($log_dir)) !== 0 ||
     52            ! file_exists($full_path)
     53        ) {
     54            wp_die( 'Invalid file requested.', '403 Forbidden', array( 'response' => 403 ) );
     55        }
     56
     57        header('Content-Description: File Transfer');
     58        header('Content-Type: application/octet-stream');
     59        header('Content-Disposition: attachment; filename="' . basename($full_path) . '"');
     60        header('Expires: 0');
     61        header('Cache-Control: must-revalidate');
     62        header('Pragma: public');
     63        header('Content-Length: ' . filesize($full_path));
     64        readfile($full_path);
     65        exit;
    2966    }
    3067
     
    416453        }
    417454        echo "</select>";
    418         echo "<button type='submit' class='button button-primary' id='btnDownloadLog' name='btnDownloadLog' value='" . esc_html($firstReadFile) . "' style='margin-left: 10px;'>".__('Download log', 'extendago-wp-connection-plugin')."</button>";
     455
     456        echo '<input type="hidden" name="action" value="download_log">';
     457        echo '<input id="btnDownloadLog" type="hidden" name="btnDownloadLog" value="' . $firstReadFile . '">';
     458        echo wp_nonce_field( 'download_log_action', 'download_log_nonce' );
     459        echo '<button style="margin-left: 10px;" type="submit" class="button button-primary">Download Log File</button>';
    419460
    420461        // Make some space
     
    9621003                        <label>
    9631004                            <input type="checkbox" name="extendago_skip_order_processing[]" value="<?php echo $wc_payment_gateway->id; ?>" <?php echo $is_checked ? 'checked' : ''; ?>>
    964                             <?php echo $wc_payment_gateway->title; ?>
     1005                            <?php echo ( isset($wc_payment_gateway->title) && !empty($wc_payment_gateway->title) )? $wc_payment_gateway->title : $wc_payment_gateway->id; ?>
    9651006                        </label>
    9661007                        <br>
     
    10891130            echo '<div class="alert alert-warning" role="alert">' . __( 'Woocommerce not activated!', 'extendago-wp-connection-plugin' ) . '</div>';
    10901131        }
    1091     }
    1092 
    1093     public function downloadLogFile() {
    1094         // Get information from the button
    1095         $basedir        = wp_upload_dir();
    1096         $directory  = $basedir['basedir'];
    1097         $directory  = $directory . '/extendago/logs';
    1098         $file = sanitize_text_field($_POST['btnDownloadLog']);
    1099         $file = $directory . "/" . $file;
    1100 
    1101         header('Content-Description: File Transfer');
    1102         header('Content-Type: application/octet-stream');
    1103         header('Content-Disposition: attachment; filename="'.basename($file).'"');
    1104         header('Expires: 0');
    1105         header('Cache-Control: must-revalidate');
    1106         header('Pragma: public');
    1107         header('Content-Length: ' . filesize($file));
    1108         readfile($file);
    1109         exit;
    11101132    }
    11111133
  • extendago-wp-connection/trunk/includes/admin/partials/extendago_wp_connection_settings_page.php

    r3257883 r3264425  
    235235
    236236            <div role="tabpanel" class="tab-pane fade" id="debug_section">
    237                 <form method='post' action='options.php'>
     237                <form method='post' action="<?php echo admin_url('admin-post.php'); ?>">
    238238                    <?php
    239239                    settings_fields( 'extendago_debug_options' );
  • extendago-wp-connection/trunk/includes/class-extendago-wp-connection.php

    r3019318 r3264425  
    6969        $this->loader->add_action( 'wp_ajax_nopriv_check_extendago_voucher', $woocommerce, 'check_extendago_voucher' );
    7070        $this->loader->add_action( 'woocommerce_order_status_changed', $woocommerce, 'create_extendago_new_order' );
     71        $this->loader->add_action( 'add_meta_boxes', $woocommerce, 'register_plugin_metaboxes' );
     72
     73        add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $woocommerce, 'add_extendago_order_returned_column' ) );
     74        add_action( 'manage_woocommerce_page_wc-orders_custom_column', array( $woocommerce, 'add_extendago_order_returned_column_value' ), 10, 2);
    7175        $this->loader->add_action( 'manage_edit-shop_order_columns', $woocommerce, 'add_extendago_order_returned_column' );
    72         $this->loader->add_action( 'manage_shop_order_posts_custom_column', $woocommerce, 'add_extendago_order_returned_column_value' );
    73         $this->loader->add_action( 'add_meta_boxes', $woocommerce, 'register_plugin_metaboxes' );
     76        add_action( 'manage_shop_order_posts_custom_column', array( $woocommerce, 'add_extendago_order_returned_column_value' ), 10, 1);
    7477
    7578        add_action( 'woocommerce_product_after_variable_attributes', array($woocommerce, 'show_size_id_field_variation_data'), 10, 3 );
  • extendago-wp-connection/trunk/includes/woocommerce/class-extendago-woocommerce-functions.php

    r3262736 r3264425  
    788788            }
    789789
    790 
    791790            // SKip order processing for specific payment methods
    792791            $order_payment_method = $order->get_payment_method();
     
    801800                $order_returned_successfully_to_extendago = $order->get_meta('order_returned_successfully_to_extendago');
    802801                if ($order_returned_successfully_to_extendago == '1') {
     802                    $logging->log_file_write('NewOrder | WebOrder already exist inside Extenda GO');
    803803                    return '';
    804804                }
     
    813813
    814814            // Check ones more if order is paid and completed
    815             if( isset($extendago_click_and_collect) && !empty($extendago_click_and_collect) ) {
     815            if (!empty($extendago_click_and_collect) && $extendago_click_and_collect !== 'null' && $extendago_click_and_collect !== '0') {
    816816                $shipping_lines = $order->get_items( 'shipping' );
    817817                foreach( $shipping_lines as $shipping_line ) {
     
    826826                }
    827827            }
    828             elseif( isset($extendago_cash_on_delivery) && !empty($extendago_cash_on_delivery) ) {
     828            elseif (!empty($extendago_cash_on_delivery) && $extendago_cash_on_delivery !== 'null' && $extendago_cash_on_delivery !== '0') {
    829829                $payment_method_id = $order->get_payment_method();
    830830                if( $payment_method_id == $extendago_cash_on_delivery){
     
    840840
    841841            if( $process_order ){
     842
    842843                $data = array();
    843844
     
    910911
    911912                // Extenda gebruikt alleen de laatste 4 cijfers
    912                 $data['register_sequence_number'] = substr($data['sequence_number'], -4);
     913                $data['attributes']['register_sequence_number'] = substr($data['sequence_number'], -4);
    913914
    914915                $data['is_preorder'] = true;
     
    10151016
    10161017                    $order_line_item['vat_rate'] = '0.' . $vat_rate; // 0021 = 21%
    1017 
    1018                     // 23-12-2024
    10191018                    $order_line_item['effective_vat_rate'] = $order_line_item['vat_rate'];
    10201019
     
    11891188                    $order->update_meta_data('order_returned_successfully_to_extendago', '1');
    11901189                    $order->update_meta_data('click_and_collect_order', $click_and_collect_order);
     1190                    $order->save();
    11911191                }
    11921192                $logging->log_file_write('NewOrder | ' . $message);
     
    12051205    }
    12061206
    1207     public function add_extendago_order_returned_column_value($column) {
    1208         global $post;
    1209         if ($column == 'extendago_feedback') {
    1210             $order    = wc_get_order( $post->ID );
    1211             if (strlen(get_post_meta($post->ID, 'order_returned_successfully_to_extendago', true)) > 0) {
    1212                 //ORDER HAS BEEN SENT TO EXTENDAGO
    1213                 if (get_post_meta($post->ID, 'order_returned_successfully_to_extendago', true) == '1') {
    1214 
    1215                     if (get_post_meta($post->ID, 'click_and_collect_order', true) == 'yes') {
    1216                         echo __("Created inside ExtendaGo as Click and Collect order");
    1217                     }
    1218                     else{
    1219                         echo __("Created inside ExtendaGo");
    1220                     }
    1221                 }
    1222                 else if ($order->has_status( 'processing') || $order->has_status( 'completed')) {
    1223                     echo "<button name='resend_new_order_to_extendago' order_id='".esc_html($post->ID)."'>".__( 'Resend order to Extendago', 'extendago-wp-connection-plugin')."</button>";
    1224                 }
    1225                 else {
    1226                     echo __("Waiting for order-status 'processing' or 'completed'");
    1227                 }
    1228             }
    1229             else if ($order->has_status( 'processing') || $order->has_status( 'completed')) {
    1230                 echo "<button name='resend_new_order_to_extendago' order_id='".esc_html($post->ID)."'>".__( 'Resend order to Extendago', 'extendago-wp-connection-plugin')."</button>";
    1231             }
    1232             else {
    1233                 echo __("Order not paid and pending...");
    1234             }
     1207    public function add_extendago_order_returned_column_value($column, $order_id = '') {
     1208        if ($column !== 'extendago_feedback') {
     1209            return;
     1210        }
     1211
     1212        if (empty($order_id)) {
     1213            global $post;
     1214            $order_id = $post->ID ?? 0;
     1215        }
     1216
     1217        $order = is_object($order_id) ? $order_id : wc_get_order($order_id);
     1218        if (!$order instanceof WC_Order) {
     1219            echo __('Invalid order');
     1220            return;
     1221        }
     1222
     1223        $order_id = $order->get_id(); // Make sure it's now an ID
     1224
     1225        $feedback = $order->get_meta('order_returned_successfully_to_extendago');
     1226
     1227        if (!empty($feedback)) {
     1228            if ($feedback === '1') {
     1229                if ($order->get_meta('click_and_collect_order') === 'yes') {
     1230                    echo __("Created inside ExtendaGo as Click and Collect order");
     1231                } else {
     1232                    echo __("Created inside ExtendaGo");
     1233                }
     1234            } elseif ($order->has_status('processing') || $order->has_status('completed')) {
     1235                echo "<button name='resend_new_order_to_extendago' order_id='" . esc_attr($order_id) . "'>" . __('Resend order to Extendago', 'extendago-wp-connection-plugin') . "</button>";
     1236            } else {
     1237                echo __("Waiting for order-status 'processing' or 'completed'");
     1238            }
     1239        } elseif ($order->has_status('processing') || $order->has_status('completed')) {
     1240            echo "<button name='resend_new_order_to_extendago' order_id='" . esc_attr($order_id) . "'>" . __('Resend order to Extendago', 'extendago-wp-connection-plugin') . "</button>";
     1241        } else {
     1242            echo __("Order not paid and pending...");
    12351243        }
    12361244    }
  • extendago-wp-connection/trunk/readme.txt

    r3262736 r3264425  
    55Requires at least: 6.0
    66Tested up to: 6.7.1
    7 Stable tag: 1.6.4
     7Stable tag: 1.6.5
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    3131== Changelog =
    3232
     33= 1.6.5 =
     34* Improved and secure log file download function
     35* Order columns for HPOS
     36
    3337= 1.6.4 =
    3438* Bugfix with imported Extenda categories and unique mapping ID
Note: See TracChangeset for help on using the changeset viewer.