Plugin Directory

Changeset 2665761


Ignore:
Timestamp:
01/26/2022 10:54:20 AM (4 years ago)
Author:
manuelschultz
Message:

Updating to version 1.1.0

Location:
kassa-at-for-woocommerce
Files:
31 added
16 edited

Legend:

Unmodified
Added
Removed
  • kassa-at-for-woocommerce/trunk/api-connection.php

    r2604334 r2665761  
    3535        $host = 'https://' . kaw_get_subdomain() . '.kassa.at';
    3636    } elseif ( kaw_get_envirement_mode() === 'dev' ) {
    37         $host = 'http://' . kaw_get_subdomain() . '.kassa.at.10.0.0.3.nip.io:3000';
     37        $host = 'http://' . kaw_get_subdomain() . '.kassa.at.10.0.0.13.nip.io:3000';
    3838    }
    3939    return $host;
     
    7777    $site = kaw_get_api_host() . '/api/' . kaw_get_api_version( 'v1' ) . $action;
    7878
    79     kaw_log_data( 'API-CALL: [' . $method . '] ' . $site );
    80     kaw_log_data( $params );
     79    $args['method']                   = $method;
     80    $args['headers']['Authorization'] = get_option( 'kaw-key' );
     81    if ( 'GET' === $method ) {
     82        $args['headers']['Content-Type'] = 'application/json';
    8183
    82     $args['method']  = $method;
    83     $args['headers'] = array(
    84         'Authorization' => get_option( 'kaw-key' ),
    85         'Content-Type'  => 'application/json',
    86     );
    87     $args['body']    = $params;
    88     $request         = new WP_Http();
    89     $result          = $request->request( $site, $args );
     84    }
     85    $args['body'] = $params;
     86    $request      = new WP_Http();
     87    $result       = $request->request( $site, $args );
    9088
    9189    if ( is_wp_error( $result ) ) {
    92         kaw_log_data( 'API-RESULT: (WP_Error) ' . wp_json_encode( $result ) );
    9390        $result->length = '0';
    9491        $json           = $result;
    9592    } else {
    96         kaw_log_data( 'API-RESULT: ' . $result['body'] );
    9793        $json = json_decode( $result['body'] );
    9894    }
    9995
     96    kaw_log_data(
     97        'API-CALL',
     98        array(
     99            'httpMethod' => $method,
     100            'httpUrl'    => $site,
     101            'paramSting' => $params,
     102            'kawKey'     => get_option( 'kaw-key' ),
     103            'result'     => $json,
     104            'location'   => kaw_get_locationstring(),
     105        )
     106    );
     107
    100108    return $json;
    101109}
  • kassa-at-for-woocommerce/trunk/create-menus.php

    r2604306 r2665761  
    11<?php
    22    /**
    3      * This File is responsible for doing the admin menu section for the KASSA.AT-connection.
     3     * This File is responsible for doing the admin menu
     4     * section for the KASSA.AT-connection.
    45     *
    56     * @package KASSA.AT For WooCommerce
     
    1415 */
    1516function kaw_create_menu() {
    16     $kaw_site = strtoupper( get_option( 'kaw-site' ) );
    1717    add_menu_page(
    18         'KASSA.AT Optionen',                               /* page_title */
    19         'KASSA.AT',                                        /* menu_title */
    20         'administrator',                                   /* capability */
    21         'kaw_options',                                     /* menu_slug */
    22         'kaw_create_kassa_at_options_page',                /* function */
    23         plugins_url( 'kassa-at-for-woocommerce/icon.png' ) /* icon_url */
     18        'KASSA.AT',                                                /* page_title */
     19        'KASSA.AT',                                                /* menu_title */
     20        'administrator',                                           /* capability */
     21        'kaw',                                                     /* menu_slug */
     22        'kaw_create_kassa_at_options_page',                        /* function */
     23        plugins_url( 'kassa-at-for-woocommerce/icon.png' )         /* icon_url */
     24    );
     25
     26    add_submenu_page(
     27        'kaw',                                                     /* parent_slug*/
     28        'KASSA.AT ' . __( 'Options', 'kassa-at-for-woocommerce' ), /* page_title */
     29        __( 'Options', 'kassa-at-for-woocommerce' ),               /* menu_title */
     30        'administrator',                                           /* capability */
     31        'kaw',                                                     /* menu_slug */
     32        'kaw_create_kassa_at_options_page'                         /* function */
     33    );
     34
     35    add_submenu_page(
     36        'kaw',                                                     /* parent_slug*/
     37        'KASSA.AT ' . __( 'Logs', 'kassa-at-for-woocommerce' ),    /* page_title */
     38        __( 'Logs', 'kassa-at-for-woocommerce' ),                  /* menu_title */
     39        'administrator',                                           /* capability */
     40        'kaw_logs',                                                /* menu_slug */
     41        'kaw_get_log_page_content'                                 /* function */
    2442    );
    2543}
     
    3553
    3654    kaw_maybe_save_data();
    37     kaw_maybe_delete_data();
    3855    if ( isset( $_POST['submit_hidden'] ) && 'Z' === sanitize_text_field( wp_unslash( $_POST['submit_hidden'] ) ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) ) ) {
    3956        kaw_synchronize_k_to_w();
    4057    }
    4158
    42     kaw_get_page_content();
     59    kaw_get_main_page_content();
    4360}
    4461
     
    5370
    5471            if ( get_option( 'kaw-warehouse' ) ) {
     72                $old_warehouse = get_option( 'kaw-warehouse' );
    5573                update_option( 'kaw-warehouse', $opt_val );
    5674            } else {
     75                $old_warehouse = '';
    5776                add_option( 'kaw-warehouse', $opt_val );
    5877            }
    59             kaw_log_data( 'DATA-UPDATED: "kaw-warehouse" = ' . $opt_val );
     78            kaw_log_data(
     79                'DATA-UPDATE',
     80                array(
     81                    'message'  => 'Connected warehouse updated',
     82                    'key'      => 'kaw-warehouse',
     83                    'original' => $old_warehouse,
     84                    'updated'  => $opt_val,
     85                    'location' => kaw_get_locationstring(),
     86                )
     87            );
    6088        }
    6189    }
     
    6593
    6694        if ( get_option( 'kaw-subdomain' ) ) {
     95            $old_subdomain = get_option( 'kaw-subdomain' );
    6796            update_option( 'kaw-subdomain', $subdomain_string );
    6897        } else {
     98            $old_subdomain = '';
    6999            add_option( 'kaw-subdomain', $subdomain_string );
    70100        }
    71         kaw_log_data( 'DATA-UPDATED: "kaw-subdomain" = ' . $subdomain_string );
     101        kaw_log_data(
     102            'SYSTEM',
     103            array(
     104                'message'  => 'Connection to KASSA.AT established.',
     105                'location' => kaw_get_locationstring(),
     106            )
     107        );
     108        kaw_log_data(
     109            'DATA-UPDATE',
     110            array(
     111                'message'  => 'Connected subdomain updated',
     112                'key'      => 'kaw-subdomain',
     113                'original' => $old_subdomain,
     114                'updated'  => $subdomain_string,
     115                'location' => kaw_get_locationstring(),
     116            )
     117        );
    72118    }
    73119
     
    89135
    90136/**
    91  * Determine if the user wanted to delete his connection to the KASSA.AT account
    92  * and if so, delete the entries from the database.
     137 * Delete the connection to KASSA.AT and remove
     138 * the most important entries from the database.
    93139 */
    94 function kaw_maybe_delete_data() {
    95     if ( isset( $_GET['delete_kaw'] ) ) {
    96         delete_option( 'kaw-key' );
    97         delete_option( 'kaw-warehouse' );
    98         delete_option( 'kaw-subdomain' );
    99 
    100         if ( get_option( 'kaw-message-active' ) ) {
    101             update_option( 'kaw-message-active', 1 );
    102         } else {
    103             add_option( 'kaw-message-active', 1 );
    104         }
    105         kaw_log_data( 'DATA-DELETED: "kaw-key"' );
    106         kaw_log_data( 'DATA-DELETED: "kaw-subdomain"' );
    107         kaw_log_data( 'DATA-DELETED: "kaw-warehouse"' );
     140function kaw_delete_connection() {
     141    delete_option( 'kaw-key' );
     142    delete_option( 'kaw-warehouse' );
     143    delete_option( 'kaw-subdomain' );
     144
     145    if ( get_option( 'kaw-message-active' ) ) {
     146        update_option( 'kaw-message-active', 1 );
     147    } else {
     148        add_option( 'kaw-message-active', 1 );
    108149    }
     150    kaw_log_data(
     151        'SYSTEM',
     152        array(
     153            'message'  => 'Connection to KASSA.AT removed.',
     154            'location' => kaw_get_locationstring(),
     155        )
     156    );
     157
     158    wp_send_json_success();
    109159}
     160add_action( 'wp_ajax_kaw_delete_connection', 'kaw_delete_connection' );
     161
     162
     163/**
     164 * A function to grab the kaw logfile and return its content as json.
     165 * Meant to be called via ajax.
     166 */
     167function kaw_reload_log_file() {
     168    $logfile     = kaw_check_for_log_file();
     169    $contentstr  = file_get_contents( $logfile ); // phpcs:ignore
     170    $contentjson = json_decode( $contentstr );
     171    wp_send_json_success( $contentjson );
     172}
     173add_action( 'wp_ajax_kaw_reload_log_file', 'kaw_reload_log_file' );
    110174
    111175/**
     
    113177 * Including HTML, JS and a little bit of PHP.
    114178 */
    115 function kaw_get_page_content() {
     179function kaw_get_main_page_content() {
    116180    $key_isset     = get_option( 'kaw-key' );
    117181    $kaw_warehouse = get_option( 'kaw-warehouse' );
     
    126190    <script type="text/javascript">
    127191        window.onload = function () {
    128             if ("<?php echo esc_attr( $key_isset ); ?>") {
    129                 if ("<?php echo esc_attr( $kaw_warehouse ); ?>") {
    130                     document.getElementById("kaw-warehouse").value = "<?php echo esc_attr( $kaw_warehouse ); ?>";
    131                 }
    132             } else {
    133                 if ("<?php echo esc_attr( $state ); ?>" == "dev") {
    134                     var domain = "http://www.kassa.at.10.0.0.3.nip.io:3000";
    135                 } else if ("<?php echo esc_attr( $state ); ?>" == "pro") {
    136                     var domain = "https://wp.kassa.at";
    137                 }
    138                 document.getElementById("connect-to-kaw-form").action = domain + "/api/v1/authentications/authenticate";
    139                 document.getElementById("kaw-create-link").href = domain + "/companies/new";
    140                 document.getElementById("hidden-field-return-path").value = window.location.href.split("&")[0];
    141             }
    142             <?php if ( isset( $_GET['key'] ) ) { ?>
     192            <?php if ( isset( $_GET['key'] /* phpcs:ignore*/ ) ) { ?>
    143193                window.location.href = window.location.href.split("&")[0];
    144194            <?php } ?>
    145             <?php if ( isset( $_GET['delete_kaw'] ) ) { ?>
     195            <?php if ( isset( $_GET['delete_kaw'] /* phpcs:ignore */ ) ) { ?>
    146196                window.location.href = window.location.href.split("&")[0];
    147197            <?php } ?>
    148198        }
     199
     200        function kaw_change_sync_enabeling( checkbox ) {
     201            checkbox = jQuery( checkbox );
     202
     203            let field = checkbox.data( 'field' );
     204            let mode  = checkbox.is( ':checked' );
     205
     206            jQuery.ajax({
     207                type: 'POST',
     208                url: '<?php echo esc_url( get_admin_url() . 'admin-ajax.php' ); ?>',
     209                data: {
     210                    action: 'kaw_activate_synchro_option',
     211                    field: field,
     212                    mode: mode
     213                }
     214            });
     215        }
     216
     217        function kaw_delete_connection() {
     218            jQuery.ajax({
     219                type: 'POST',
     220                url: '<?php echo esc_url( get_admin_url() . 'admin-ajax.php' ); ?>',
     221                data: {
     222                    action: 'kaw_delete_connection'
     223                },
     224                success: function () {
     225                    location.reload();
     226                }
     227            });
     228        }
    149229    </script>
    150230
    151     <div style="height:50px"></div>
     231    <div style="height: 50px"></div>
    152232    <h1><?php esc_attr_e( 'KASSA.AT connection:', 'kassa-at-for-woocommerce' ); ?></h1>
    153233    <?php if ( $key_isset ) : ?>
     
    155235            <?php esc_attr_e( 'You are already connected to a KASSA.AT account.', 'kassa-at-for-woocommerce' ); ?>
    156236            (<?php echo esc_attr( get_option( 'kaw-subdomain' ) ); ?>)<br />
    157             <a href="?page=kaw_options&delete_kaw=true" id="delete_kaw_key">
     237            <a onclick="kaw_delete_connection()" style="cursor: pointer;" id="delete_kaw_key">
    158238                <?php esc_attr_e( 'Remove connection to KASSA.AT.', 'kassa-at-for-woocommerce' ); ?>
    159239            </a>
    160240        </p>
    161241    <?php else : ?>
    162         <form id="connect-to-kaw-form" action="https://www.kassa.at" method="get">
    163             <input id="hidden-field-return-path" name="return_path" type="hidden" value="">
     242        <?php $url = ( isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ) ? 'https://' : 'http://'; ?>
     243        <?php $url .= ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) ? esc_attr( $_SERVER['HTTP_HOST'] ) . esc_attr( $_SERVER['REQUEST_URI'] ) : ''; /* phpcs:ignore */ ?>
     244
     245        <form id="connect-to-kaw-form" action="<?php echo esc_url( preg_replace( '/\/\/[^.]*\./', '//wp.', kaw_get_api_host(), 1 ) ); ?>/api/v1/authentications/authenticate" method="get">
     246            <input id="hidden-field-return-path" name="return_path" type="hidden" value="<?php echo esc_url( $url ); ?>">
    164247            <input name="description" type="hidden" value="Woocommerce Plugin">
    165248            <button type="submit" name="Submit" class="button-primary">
     
    168251        </form>
    169252        <br />
    170         <a id="kaw-create-link" href="https://kassa.at/companies/new" target="_blank">
     253        <a id="kaw-create-link" href="<?php echo esc_url( preg_replace( '/\/\/[^.]*\./', '//wp.', kaw_get_api_host(), 1 ) ); ?>/companies/new" target="_blank">
    171254            <?php esc_attr_e( 'Dont have a KASSA.AT account? Create one!', 'kassa-at-for-woocommerce' ); ?>
    172255        </a>
     
    182265            <select name="kaw-warehouse" id="kaw-warehouse">
    183266            <?php foreach ( $kaw_warehouses->details as &$warehouse ) { ?>
    184                 <option value="<?php echo esc_attr( $warehouse->id ); ?>"><?php echo esc_attr( $warehouse->description ); ?></option>
     267                <option value="<?php echo esc_attr( $warehouse->id ); ?>" <?php echo ( esc_attr( $warehouse->id ) === get_option( 'kaw-warehouse' ) ) ? 'selected' : ''; ?>><?php echo esc_attr( $warehouse->description ); ?></option>
    185268            <?php } ?>
    186269            </select>
     
    206289            </tr>
    207290        </table>
     291        <table>
     292            <tr>
     293                <td>
     294                    <input id="kaw-synchronize-at-singleproduct" type="checkbox" onchange="kaw_change_sync_enabeling( this )" data-field="kaw-synchronize-at-singleproduct" <?php echo ( ! get_option( 'kaw-synchronize-at-singleproduct' ) || get_option( 'kaw-synchronize-at-singleproduct' ) === 'enabled' ) ? 'checked' : ''; ?>>
     295                </td>
     296                <td>
     297                    <label for="kaw-synchronize-at-singleproduct"><?php esc_attr_e( 'Synchronize on the Single Product Page!', 'kassa-at-for-woocommerce' ); ?></label>
     298                </td>
     299            </tr>
     300
     301            <tr>
     302                <td>
     303                    <input id="kaw-synchronize-at-cart" type="checkbox" onchange="kaw_change_sync_enabeling( this )" data-field="kaw-synchronize-at-cart" <?php echo ( ! get_option( 'kaw-synchronize-at-cart' ) || get_option( 'kaw-synchronize-at-cart' ) === 'enabled' ) ? 'checked' : ''; ?>>
     304                </td>
     305                <td>
     306                    <label for="kaw-synchronize-at-cart"><?php esc_attr_e( 'Synchronize on the Cart Page!', 'kassa-at-for-woocommerce' ); ?></label>
     307                </td>
     308            </tr>
     309
     310            <tr style="display: none">
     311                <td>
     312                    <input id="kaw-synchronize-on-order" type="checkbox" onchange="kaw_change_sync_enabeling( this )" data-field="kaw-synchronize-on-order" <?php echo ( ! get_option( 'kaw-synchronize-on-order' ) || get_option( 'kaw-synchronize-on-order' ) === 'enabled' ) ? 'checked' : ''; ?> disabled>
     313                </td>
     314                <td>
     315                    <label for="kaw-synchronize-on-order"><?php esc_attr_e( 'Synchronize when the order is received!', 'kassa-at-for-woocommerce' ); ?></label>
     316                </td>
     317            </tr>
     318        </table>
    208319        <br />
    209320    <?php endif; ?>
    210321<?php } ?>
     322
     323<?php
     324/**
     325 * Creating the HTML code for the log-page in the admin-menu for KASSA.AT.
     326 * Including HTML, JS, css and PHP.
     327 */
     328function kaw_get_log_page_content() {
     329    ?>
     330    <style media="screen">
     331        div.kawlog-lineno {
     332            text-align: center;
     333            background-color: rgba(0,0,0,0.1);
     334            color: #888;
     335        }
     336
     337        div.kawlog-row {
     338            min-height: 25px;
     339        }
     340
     341        div.kawlog-row.kawlog-row-primary {
     342            border-top: rgba(0,0,0,0.1) 1px solid;
     343        }
     344
     345        div#kawlog-container {
     346            display: flex;
     347            flex-direction: column;
     348            height: 400px;
     349            overflow: auto;
     350            width: 99%;
     351            white-space: nowrap;
     352            border: 1px #bbb solid;
     353            padding: 5px;
     354            border-radius: 3px;
     355            max-width: 1280px;
     356            background-color: #fff;
     357        }
     358
     359        table.kaw-option-table thead {
     360            font-weight: bold;
     361        }
     362
     363        table.kaw-option-table td {
     364            padding: 8px 16px;
     365            border: rgba(0,0,0,0.1) 1px solid;
     366        }
     367    </style>
     368
     369    <script type="text/javascript">
     370        function kawlog_reload() {
     371            jQuery.ajax({
     372                type: 'GET',
     373                url: '<?php echo esc_url( get_admin_url() . 'admin-ajax.php' ); ?>',
     374                data: {
     375                    action: 'kaw_reload_log_file'
     376                },
     377                success: function( data ) {
     378                    let currentDate = new Date();
     379                    let refreshDateTime = ( ( currentDate.getDate() < 10 ) ? '0' : '' ) + currentDate.getDate() + '.' + ( ( currentDate.getMonth() < 10 ) ? '0' : '' ) + ( currentDate.getMonth() + 1 ) + '.' + currentDate.getFullYear() + ' ' + ( ( currentDate.getHours() < 10 ) ? '0' : '' ) + currentDate.getHours() + ':' + ( ( currentDate.getMinutes() < 10 ) ? '0' : '' ) + currentDate.getMinutes() + ':' + ( ( currentDate.getSeconds() < 10 ) ? '0' : '' ) + currentDate.getSeconds();
     380                    jQuery( 'span#kawlog-reload-time' ).attr( 'title', refreshDateTime );
     381                    jQuery( 'span#kawlog-reload-time' ).text( refreshDateTime.split( ' ' )[1] );
     382                    document.getElementById( 'kawlog-container' ).innerHTML = '';
     383
     384                    var kawloghtml = '';
     385                    data.data.forEach((log, line) => {
     386                        line = parseInt( line ) + 1;
     387                        kawloghtml += "<div class='kawlog-row kawlog-row-primary' style='display: flex; flex-wrap: nowrap; cursor: pointer;' onclick='jQuery( \"div#kaw_logs_extra_info_" + line + "\" ).slideToggle()'>";
     388                        kawloghtml += "<div class='kawlog-lineno' style='width: 50px;'>" + line + "</div>";
     389                        kawloghtml +=   "<div style='width: 150px'>" + log.datetime + "</div>";
     390                        kawloghtml += "<div style='width: 100px'>" + log.type + "</div>";
     391                        if ( log.type === 'API-CALL' ) {
     392                            kawloghtml += "<div style='width: calc(100% - 300px)'>[" + log.data.httpMethod + "] " + log.data.httpUrl + "</div>";
     393                        } else if ( log.type === 'API-ERROR' ) {
     394                            kawloghtml += "<div style='width: calc(100% - 300px)'>" + log.data.message + "</div>";
     395                        } else if ( log.type === 'DATA-UPDATE' ) {
     396                            kawloghtml += "<div style='width: calc(100% - 300px)'>[" + log.data.message + "] " + log.data.key + "</div>";
     397                        } else if ( log.type === 'SYSTEM' ) {
     398                            kawloghtml += "<div style='width: calc(100% - 300px)'>" + log.data.message + "</div>";
     399                        }
     400                        kawloghtml += "</div>";
     401
     402                        kawloghtml += "<div id='kaw_logs_extra_info_" + line + "' style='display: none;'>";
     403                        kawloghtml += "<div style='display: flex; flex-direction: column;'>";
     404                        let linestart = "<div class='kawlog-row' style='display: flex; flex-direction: auto;'><div class='kawlog-lineno' style='width: 50px;'></div><div style='width: 150px'></div>";
     405                        if ( log.type === 'API-CALL' ) {
     406                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'Parameters', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + JSON.stringify( log.data.params ) + "</div></div>";
     407                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'API-Key', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + log.data.kawKey + "</div></div>";
     408                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'Result', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + JSON.stringify( log.data.result ) + "</div></div>";
     409                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + log.data.location + "</div></div>";
     410                        } else if ( log.type === 'API-ERROR' ) {
     411                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + log.data.location + "</div></div>";
     412                        } else if ( log.type === 'DATA-UPDATE' ) {
     413                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'Changes', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + log.data.original + " => " + log.data.updated + " (" + log.data.key + ")</div></div>";
     414                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + log.data.location + "</div></div>";
     415                        } else if ( log.type === 'SYSTEM' ) {
     416                            kawloghtml += linestart + "<div style='width: 100px'><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style='width: calc(100% - 300px)'>" + log.data.location + "</div></div>";
     417                        }
     418
     419                        kawloghtml += "</div>";
     420                        kawloghtml += "</div>";
     421                    });
     422                    document.getElementById( 'kawlog-container' ).innerHTML = kawloghtml;
     423                }
     424            });
     425        }
     426
     427        function kawlog_enable( btn ) {
     428            btn = jQuery( btn );
     429            var mode = '';
     430            if ( btn.data( 'currentstate' ) === 'enabled' ) {
     431                // disable logs
     432                mode = 'disable';
     433            } else if ( btn.data( 'currentstate' ) === 'disabled' ) {
     434                // enable logs
     435                mode = 'enable';
     436            }
     437
     438            jQuery.ajax({
     439                type: 'POST',
     440                url: '<?php echo esc_url( get_admin_url() . 'admin-ajax.php' ); ?>',
     441                data: {
     442                    action: 'kaw_activate_logging',
     443                    mode: mode
     444                },
     445                success: function( data ) {
     446                    if ( data.data === false ) {
     447                        btn.html( btn.data( 'enabletext' ) );
     448                        btn.data( 'currentstate', 'disabled' );
     449                    } else if ( data.data === true ) {
     450                        btn.html( btn.data( 'disabletext' ) );
     451                        btn.data( 'currentstate', 'enabled' );
     452                    }
     453
     454                    kawlog_reload();
     455                }
     456            });
     457        }
     458
     459        function kawlog_delete() {
     460            jQuery.ajax({
     461                type: 'POST',
     462                url: '<?php echo esc_url( get_admin_url() . 'admin-ajax.php' ); ?>',
     463                data: {
     464                    action: 'kaw_delete_logfile'
     465                },
     466                success: function( data ) {
     467                    if ( data.success === true ) {
     468                        kawlog_reload();
     469                    }
     470                }
     471            });
     472        }
     473
     474        function kawlog_download() {
     475            jQuery.ajax({
     476                type: 'GET',
     477                url: '<?php echo esc_url( get_admin_url() . 'admin-ajax.php' ); ?>',
     478                data: {
     479                    action: 'kaw_reload_log_file'
     480                },
     481                success: function( data ) {
     482                    var dataStr = 'data:text/json;charset=utf-8,' + encodeURIComponent( JSON.stringify( data.data, null, '\t' ) );
     483                    var dlAnchorElem = document.createElement( 'a' );
     484                    dlAnchorElem.setAttribute( 'href', dataStr );
     485                    dlAnchorElem.setAttribute( 'download', 'KAW-Logfile.json' );
     486                    document.body.appendChild( dlAnchorElem );
     487                    dlAnchorElem.click();
     488                    dlAnchorElem.remove();
     489                }
     490            });
     491        }
     492
     493        function kawlog_size_save() {
     494            let select = jQuery( 'select#kawlog-size-select' )
     495            jQuery.ajax({
     496                type: 'POST',
     497                url: '<?php echo esc_url( get_admin_url() . 'admin-ajax.php' ); ?>',
     498                data: {
     499                    action: 'kaw_logfile_change_size',
     500                    size: select.val()
     501                },
     502                success: function( data ) {
     503                    if ( data.success === true ) {
     504                        kawlog_reload();
     505                    }
     506                }
     507            });
     508        }
     509    </script>
     510
     511    <h1><?php esc_attr_e( 'Plugin Logs:', 'kassa-at-for-woocommerce' ); ?></h1>
     512    <div style="display: flex; justify-content: space-between; width: 99%; max-width: 1280px;">
     513        <div style="width: calc((100% / 3) - 50px); min-width:230px; text-align: left;">
     514            <button class="button-secondary" type="button" onclick="kawlog_reload()"><?php esc_attr_e( 'Reload logfile', 'kassa-at-for-woocommerce' ); ?></button>
     515            <span id="kawlog-reload-title"><?php esc_attr_e( 'Refreshed', 'kassa-at-for-woocommerce' ); ?>: </span>
     516            <span id="kawlog-reload-time">-</span>
     517        </div>
     518
     519        <div style="width: calc((100% / 3) + 100px); min-width:350px; text-align: center;">
     520            <button id="kawlog_enable_btn" class="button-secondary" onclick="kawlog_enable( this )" data-currentstate="<?php echo kaw_enable_log() ? 'enabled' : 'disabled'; ?>" data-enabletext="<?php esc_attr_e( 'Enable Logging', 'kassa-at-for-woocommerce' ); ?>" data-disabletext="<?php esc_attr_e( 'Disable Logging', 'kassa-at-for-woocommerce' ); ?>">
     521                <?php kaw_enable_log() ? esc_attr_e( 'Disable Logging', 'kassa-at-for-woocommerce' ) : esc_attr_e( 'Enable Logging', 'kassa-at-for-woocommerce' ); ?>
     522            </button>
     523            <button id="kawlog_delete_btn" class="button-secondary" type="button" onclick="kawlog_delete()"><?php esc_attr_e( 'Delete logfile', 'kassa-at-for-woocommerce' ); ?></button>
     524            <button id="kawlog_download_btn" class="button-secondary" type="button" onclick="kawlog_download()"><?php esc_attr_e( 'Download logfile', 'kassa-at-for-woocommerce' ); ?></button>
     525        </div>
     526
     527        <div style="width: calc((100% / 3) - 50px); min-width:175px; text-align: right;">
     528            <select id="kawlog-size-select" name="kawlog-size" title="<?php esc_html_e( 'Limit kaw-log length', 'kassa-at-for-woocommerce' ); ?>">
     529                <option value="500" <?php echo ( intval( get_option( 'kaw-logging-size' ) ) === 500 ) ? 'selected' : ''; ?>>500 <?php esc_attr_e( 'lines', 'kassa-at-for-woocommerce' ); ?></option>
     530                <option value="1000" <?php echo ( ! get_option( 'kaw-logging-size' ) || intval( get_option( 'kaw-logging-size' ) ) === 1000 ) ? 'selected' : ''; ?>>1000 <?php esc_attr_e( 'lines', 'kassa-at-for-woocommerce' ); ?></option>
     531                <option value="2000" <?php echo ( intval( get_option( 'kaw-logging-size' ) ) === 2000 ) ? 'selected' : ''; ?>>2000 <?php esc_attr_e( 'lines', 'kassa-at-for-woocommerce' ); ?></option>
     532                <option value="5000" <?php echo ( intval( get_option( 'kaw-logging-size' ) ) === 5000 ) ? 'selected' : ''; ?>>5000 <?php esc_attr_e( 'lines', 'kassa-at-for-woocommerce' ); ?></option>
     533                <?php if ( get_option( 'kaw-logging-size' ) && ( ! in_array( strval( get_option( 'kaw-logging-size' ) ), array( '500', '1000', '2000', '5000' ), true ) ) ) : ?>
     534                    <option value="<?php echo esc_html( get_option( 'kaw-logging-size' ) ); ?>" selected><?php echo esc_html( get_option( 'kaw-logging-size' ) ); ?> <?php esc_attr_e( 'lines', 'kassa-at-for-woocommerce' ); ?></option>
     535                <?php endif; ?>
     536            </select>
     537            <button id="kawlog_size_save_btn" class="button-secondary" onclick="kawlog_size_save()" title="<?php esc_attr_e( 'Limit kaw-log length', 'kassa-at-for-woocommerce' ); ?>"><?php esc_attr_e( 'Save', 'kassa-at-for-woocommerce' ); ?></button>
     538        </div>
     539    </div>
     540
     541    <?php $logfile = kaw_check_for_log_file(); ?>
     542    <?php $json_logdata = json_decode( file_get_contents( $logfile ) ); /* phpcs:ignore */ ?>
     543    <div id="kawlog-container" style="margin: 10px 0px 50px 0px;">
     544        <?php foreach ( $json_logdata as $line => $log ) { ?>
     545            <div class="kawlog-row kawlog-row-primary" style="display: flex; flex-wrap: nowrap; cursor: pointer;" onclick="jQuery( 'div#kaw_logs_extra_info_<?php echo esc_html( $line + 1 ); ?>' ).slideToggle()">
     546                <div class="kawlog-lineno" style="width: 50px;" ><?php echo esc_attr( $line + 1 ); ?></div>
     547                <div style="width: 150px"><?php echo esc_attr( $log->datetime ); ?></div>
     548                <div style="width: 100px"><?php echo esc_attr( $log->type ); ?></div>
     549                <?php if ( 'API-CALL' === $log->type ) : ?>
     550                    <div style="width: calc(100% - 300px)">[<?php echo esc_attr( $log->data->httpMethod ); ?>] <?php echo esc_attr( $log->data->httpUrl ); ?></div>
     551                <?php elseif ( 'API-ERROR' === $log->type ) : ?>
     552                    <div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->message ); ?></div>
     553                <?php elseif ( 'DATA-UPDATE' === $log->type ) : ?>
     554                    <div style="width: calc(100% - 300px)">[<?php echo esc_attr( $log->data->message ); ?>] <?php echo esc_attr( $log->data->key ); ?></div>
     555                <?php elseif ( 'SYSTEM' === $log->type ) : ?>
     556                    <div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->message ); ?></div>
     557                <?php endif; ?>
     558            </div>
     559            <div id="kaw_logs_extra_info_<?php echo esc_html( $line + 1 ); ?>" style="display: none;">
     560                <div style="display: flex; flex-direction: column;">
     561                    <?php if ( 'API-CALL' === $log->type ) : ?>
     562                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'Parameters', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_html( wp_json_encode( (array) $log->data->params ) ); ?></div></div>
     563                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'API-Key', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->kawKey ); ?></div></div>
     564                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'Result', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_html( wp_json_encode( (array) $log->data->result ) ); ?></div></div>
     565                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->location ); ?></div></div>
     566                    <?php elseif ( 'API-ERROR' === $log->type ) : ?>
     567                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->location ); ?></div></div>
     568                    <?php elseif ( 'DATA-UPDATE' === $log->type ) : ?>
     569                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'Changes', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->original ); ?> => <?php echo esc_attr( $log->data->updated ); ?> (<?php echo esc_attr( $log->data->key ); ?>)</div></div>
     570                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->location ); ?></div></div>
     571                    <?php elseif ( 'SYSTEM' === $log->type ) : ?>
     572                        <div class="kawlog-row" style="display: flex; flex-direction: auto;"><div class="kawlog-lineno" style="width: 50px;"></div><div style="width: 150px"></div><div style="width: 100px"><?php esc_attr_e( 'Location', 'kassa-at-for-woocommerce' ); ?>: </div><div style="width: calc(100% - 300px)"><?php echo esc_attr( $log->data->location ); ?></div></div>
     573                    <?php endif; ?>
     574                </div>
     575            </div>
     576        <?php } ?>
     577    </div>
     578
     579    <h1><?php esc_attr_e( 'Database options', 'kassa-at-for-woocommerce' ); ?></h1>
     580    <table class="kaw-option-table">
     581        <thead>
     582            <tr>
     583                <td><?php esc_attr_e( 'Creator', 'kassa-at-for-woocommerce' ); ?></td>
     584                <td><?php esc_attr_e( 'Option-name', 'kassa-at-for-woocommerce' ); ?></td>
     585                <td><?php esc_attr_e( 'Option-value', 'kassa-at-for-woocommerce' ); ?></td>
     586            </tr>
     587        </thead>
     588        <tbody>
     589            <tr>
     590                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     591                <td>kaw-subdomain</td>
     592                <td><?php echo get_option( 'kaw-subdomain' ) ? esc_attr( get_option( 'kaw-subdomain' ) ) : 'not set'; ?></td>
     593            </tr>
     594            <tr>
     595                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     596                <td>kaw-key</td>
     597                <td><?php echo get_option( 'kaw-key' ) ? esc_attr( get_option( 'kaw-key' ) ) : 'not set'; ?></td>
     598            </tr>
     599            <tr>
     600                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     601                <td>kaw-warehouse</td>
     602                <td><?php echo get_option( 'kaw-warehouse' ) ? esc_attr( get_option( 'kaw-warehouse' ) ) : 'not set'; ?></td>
     603            </tr>
     604            <tr>
     605                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     606                <td>kaw-message-active</td>
     607                <td><?php echo get_option( 'kaw-message-active' ) ? esc_attr( get_option( 'kaw-message-active' ) ) : 'not set'; ?></td>
     608            </tr>
     609            <tr>
     610                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     611                <td>kaw-logging</td>
     612                <td><?php echo get_option( 'kaw-logging' ) ? esc_attr( get_option( 'kaw-logging' ) ) : 'not set'; ?></td>
     613            </tr>
     614            <tr>
     615                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     616                <td>kaw-logging-size</td>
     617                <td><?php echo get_option( 'kaw-logging-size' ) ? esc_attr( get_option( 'kaw-logging-size' ) ) : 'not set'; ?></td>
     618            </tr>
     619            <tr>
     620                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     621                <td>kaw-synchronize-at-singleproduct</td>
     622                <td><?php echo get_option( 'kaw-synchronize-at-singleproduct' ) ? esc_attr( get_option( 'kaw-synchronize-at-singleproduct' ) ) : 'not set'; ?></td>
     623            </tr>
     624            <tr>
     625                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     626                <td>kaw-synchronize-at-cart</td>
     627                <td><?php echo get_option( 'kaw-synchronize-at-cart' ) ? esc_attr( get_option( 'kaw-synchronize-at-cart' ) ) : 'not set'; ?></td>
     628            </tr>
     629            <tr>
     630                <td><?php esc_attr_e( 'KASSA.AT For WooCommerce', 'kassa-at-for-woocommerce' ); ?></td>
     631                <td>kaw-synchronize-on-order</td>
     632                <td><?php echo get_option( 'kaw-synchronize-on-order' ) ? esc_attr( get_option( 'kaw-synchronize-on-order' ) ) : 'not set'; ?></td>
     633            </tr>
     634            <tr>
     635                <td>WooCommerce</td>
     636                <td>woocommerce_manage_stock</td>
     637                <td><?php echo get_option( 'woocommerce_manage_stock' ) ? esc_attr( get_option( 'woocommerce_manage_stock' ) ) : 'not set'; ?></td>
     638            </tr>
     639        </tbody>
     640    </table>
     641<?php } ?>
  • kassa-at-for-woocommerce/trunk/kassa-at-for-woocommerce.php

    r2611428 r2665761  
    55     * Domain Path: /languages
    66     * Description: An API Plugin which corresponds with a KASSA.AT account to synchronize online and offline stock-changes.
    7      * Version:     1.0.2
     7     * Version:     1.1.0
    88     * Author:      Faxonline GmbH
    99     * Author URI:  https://www.kassa.at
     
    1111     * @package     KASSA.AT For WooCommerce
    1212     *
    13      * WC requires at least: 4.0.1
    14      * WC tested up to: 5.7.0
     13     * WC requires at least: 5.4.0
     14     * WC tested up to: 6.1.1
    1515     */
    1616
     
    2323/**
    2424 * Maybe create the custom logging folder and file.
    25  * Returning the log_file
     25 * Returning the log_file path.
     26 *
     27 * @return string
    2628 */
    2729function kaw_check_for_log_file() {
     30
    2831    $uploads  = wp_upload_dir( null, false );
    2932    $logs_dir = $uploads['basedir'] . '/kaw-logs';
     
    3336    }
    3437
    35     $file = fopen( $logs_dir . '/log.log', 'a+' );
    36     return $file;
    37 }
    38 
    39 /**
    40  * Return a boolean value to indicate if the log_file should blur out data.
    41  *
    42  * @return bool
    43  */
    44 function kaw_get_api_log_crypto() {
    45     return false;
     38    if ( ! file_exists( $logs_dir . '/log.json' ) ) {
     39        $file = fopen( $logs_dir . '/log.json', 'a+' ); /* phpcs:ignore */
     40        fwrite( $file, wp_json_encode( array() ) ); /* phpcs:ignore */
     41        fclose( $file ); /* phpcs:ignore */
     42    }
     43
     44    $filename = $logs_dir . '/log.json';
     45    return $filename;
    4646}
    4747
     
    4949 * Asks for the log file and writes whatever is in $data to it.
    5050 *
    51  * @param mixed $data The things that should be written in the log_file.
    52  */
    53 function kaw_log_data( $data ) {
    54     if ( kaw_enable_log() ) {
    55         $file         = kaw_check_for_log_file();
    56         $written_data = kaw_check_log_text( $data );
    57         $written_data = gmdate( 'd-m-Y H:i:s' ) . ' ' . $written_data . PHP_EOL;
    58         fwrite( $file, $written_data );
    59         fclose( $file );
    60     }
    61 }
    62 
    63 /**
    64  * Converts other datatypes to a string and maybe blurs out data if wanted.
    65  *
    66  * @param mixed $data The things that should be written in the log_file.
    67  * @return string
    68  */
    69 function kaw_check_log_text( $data ) {
    70     switch ( gettype( $data ) ) {
    71         case 'string':
    72             break;
    73         case 'array':
    74             $data = '[' . implode(
    75                 ', ',
    76                 array_map(
    77                     function ( $v, $k ) {
    78                         return sprintf( "'%s'='%s'", $k, $v );
    79                     },
    80                     $data,
    81                     array_keys( $data )
    82                 )
    83             ) . ']';
    84             break;
    85         case 'boolean':
    86             $data = $data ? 'true' : 'false';
    87             break;
    88         case 'integer':
    89             $data = strval( $data );
    90             break;
    91         case 'double':
    92             $data = strval( $data );
    93             break;
    94         case 'NULL':
    95             $data = 'NULL';
    96             break;
    97         default:
    98             $data = 'Error: Unable to print the value.';
    99             break;
    100     }
    101 
    102     if ( kaw_get_api_log_crypto() ) {
    103         $data = preg_replace( '/"details":\[{.*}\]/', '"details":[***]', $data );
    104         $data = preg_replace( '/:\/\/.+\.kassa.at/', '://***.kassa.at', $data );
    105     }
    106 
    107     return $data;
    108 }
    109 
    110 /**
    111  * Enable / Disable the kaw_logs!
     51 * @param string  $type The type of log-entry. Can be 'API-CALL', 'API-ERROR', 'DATA-UPDATE' or 'SYSTEM'.
     52 * @param array   $data The things that should be written in the log_file.
     53 * @param boolean $force Forces logging to be written to logfile even if logging is disabled.
     54 */
     55function kaw_log_data( $type, $data, $force = false ) {
     56    if ( kaw_enable_log() || $force ) {
     57        $logfile    = kaw_check_for_log_file();
     58        $filestring = file_get_contents( $logfile ); /* phpcs:ignore */
     59        $filejson   = json_decode( $filestring );
     60        array_unshift(
     61            $filejson,
     62            array(
     63                'datetime' => gmdate( 'd-m-Y H:i:s' ),
     64                'type'     => $type,
     65                'data'     => kaw_log_data_formating( $type, $data ),
     66            )
     67        );
     68        $filejson   = kaw_cut_log( $filejson );
     69        $fileresult = wp_json_encode( $filejson );
     70        file_put_contents( $logfile, $fileresult ); /* phpcs:ignore */
     71    }
     72}
     73
     74/**
     75 * Brings the data in the correct Format for writing it into the logfile.
     76 *
     77 * @param  string $type The type of log-entry. Can be 'API-CALL', 'API-ERROR', 'DATA-UPDATE' or 'SYSTEM'.
     78 * @param  array  $data The values that should be written in the log_file.
     79 * @return array
     80 */
     81function kaw_log_data_formating( $type, $data ) {
     82    switch ( $type ) {
     83        case 'API-CALL':
     84            return array(
     85                'httpMethod' => $data['httpMethod'],
     86                'httpUrl'    => $data['httpUrl'],
     87                'params'     => $data['paramSting'],
     88                'kawKey'     => $data['kawKey'],
     89                'result'     => $data['result'],
     90                'location'   => $data['location'],
     91            );
     92
     93        case 'API-ERROR':
     94            return array(
     95                'message'  => $data['message'],
     96                'location' => $data['location'],
     97            );
     98
     99        case 'DATA-UPDATE':
     100            return array(
     101                'message'  => $data['message'],
     102                'key'      => $data['key'],
     103                'original' => $data['original'],
     104                'updated'  => $data['updated'],
     105                'location' => $data['location'],
     106            );
     107
     108        case 'SYSTEM':
     109            return array(
     110                'message'  => $data['message'],
     111                'location' => $data['location'],
     112            );
     113    }
     114}
     115
     116/**
     117 * Performing the act of trimming the logfile to the correct length before
     118 * saving its content back to the file. The default length is 1000 entries
     119 * but it can be a different length whitch would be
     120 * stored in the wp_option 'kaw-logging-size'!
     121 *
     122 * @param  array $json The content of the logfile that should be trimmed.
     123 * @return array
     124 */
     125function kaw_cut_log( $json ) {
     126    $requested_size = get_option( 'kaw-logging-size' );
     127    if ( ! $requested_size ) {
     128        $requested_size = 1000;
     129    }
     130
     131    update_option( 'logging-info', count( $json ) );
     132
     133    if ( count( $json ) > $requested_size ) {
     134        $json = array_slice( $json, 0, $requested_size );
     135    }
     136
     137    return $json;
     138}
     139
     140/**
     141 * Checking if the kaw logging is enabled or disabled. Default is enabled,
     142 * but the user can change that with value stored in the wp_option 'kaw-logging'!
     143 *
     144 * This function is overruled if the function
     145 * kaw_log_data (which calls this function) got $force as true!
     146 *
     147 * @return boolean
    112148 */
    113149function kaw_enable_log() {
     150    if ( get_option( 'kaw-logging' ) ) {
     151        if ( get_option( 'kaw-logging' ) === 'enabled' ) {
     152            return true;
     153        } elseif ( get_option( 'kaw-logging' ) === 'disabled' ) {
     154            return false;
     155        }
     156    }
     157
    114158    return true;
    115159}
     160
     161/**
     162 * Enabling or disabling the logging of kaw logs.
     163 * Called via ajax this function updates (or creates) the wp_option 'kaw-logging'
     164 * to stop or start again logging all non-forced loggings.
     165 * In the end it forces a log-entry to keep track of activating and deactivating the logging.
     166 */
     167function kaw_activate_logging() {
     168    $mode = ( isset( $_POST['mode'] ) ) ? sanitize_text_field( wp_unslash( $_POST['mode'] ) ) : 'disable'; /* phpcs:ignore */
     169
     170    if ( 'enable' === $mode ) {
     171        $val = 'enabled';
     172    } else {
     173        $val = 'disabled';
     174    }
     175
     176    if ( get_option( 'kaw-logging' ) ) {
     177        update_option( 'kaw-logging', $val );
     178    } else {
     179        add_option( 'kaw-logging', $val );
     180    }
     181    kaw_log_data(
     182        'SYSTEM',
     183        array(
     184            'message'  => 'Logging ' . $val . '.',
     185            'location' => kaw_get_locationstring(),
     186        ),
     187        true
     188    );
     189
     190    wp_send_json_success( kaw_enable_log() );
     191}
     192add_action( 'wp_ajax_kaw_activate_logging', 'kaw_activate_logging' );
     193
     194/**
     195 * Called via ajax this function gets a number and stores that number in the
     196 * wp_option 'kaw-logging-size'. This value is used to
     197 * trim the logfile in the process of writing to it.
     198 * In the end it forces a log-entry to save the updating of the logging-size.
     199 */
     200function kaw_logfile_change_size() {
     201    $val = ( isset( $_POST['size'] ) ) ? sanitize_text_field( wp_unslash( $_POST['size'] ) ) : '1000'; /* phpcs:ignore */
     202
     203    if ( get_option( 'kaw-logging-size' ) ) {
     204        update_option( 'kaw-logging-size', $val );
     205    } else {
     206        add_option( 'kaw-logging-size', $val );
     207    }
     208
     209    kaw_log_data(
     210        'SYSTEM',
     211        array(
     212            'message'  => 'Logging length changed to: ' . $val,
     213            'location' => kaw_get_locationstring(),
     214        ),
     215        true
     216    );
     217
     218    wp_send_json_success();
     219}
     220add_action( 'wp_ajax_kaw_logfile_change_size', 'kaw_logfile_change_size' );
     221
     222/**
     223 * Deletes the kaw-logfile, deletes the kaw-log folder,
     224 * then creates both of them again and
     225 * forces a log-entry, that says that the logfile was cleared.
     226 */
     227function kaw_delete_logfile() {
     228    $uploads  = wp_upload_dir( null, false );
     229    $logs_dir = $uploads['basedir'] . '/kaw-logs';
     230
     231    if ( file_exists( $logs_dir . '/log.json' ) ) {
     232        unlink( $logs_dir . '/log.json' );
     233    }
     234
     235    if ( is_dir( $logs_dir ) ) {
     236        rmdir( $logs_dir );
     237    }
     238    kaw_log_data(
     239        'SYSTEM',
     240        array(
     241            'message'  => 'Logfile cleared.',
     242            'location' => kaw_get_locationstring(),
     243        ),
     244        true
     245    );
     246
     247    wp_send_json_success();
     248}
     249add_action( 'wp_ajax_kaw_delete_logfile', 'kaw_delete_logfile' );
    116250
    117251/**
     
    128262 */
    129263function kaw_plugin_activate() {
    130     kaw_log_data( '######################################################################' );
    131     kaw_log_data( '############################### Plugin ###############################' );
    132     kaw_log_data( '##################### "KASSA.AT Für Woocommerce" #####################' );
    133     kaw_log_data( '############################# activated ##############################' );
    134     kaw_log_data( '######################################################################' );
     264    kaw_log_data(
     265        'SYSTEM',
     266        array(
     267            'message'  => 'Plugin KASSA.AT For WooCommerce activated.',
     268            'location' => kaw_get_locationstring(),
     269        ),
     270        true
     271    );
    135272    add_option( 'kaw-message-active', 1 );
    136273}
     
    141278 */
    142279function kaw_plugin_deactivate() {
    143     kaw_log_data( '######################################################################' );
    144     kaw_log_data( '############################### Plugin ###############################' );
    145     kaw_log_data( '##################### "KASSA.AT Für Woocommerce" #####################' );
    146     kaw_log_data( '############################ deactivated #############################' );
    147     kaw_log_data( '######################################################################' );
     280    kaw_log_data(
     281        'SYSTEM',
     282        array(
     283            'message'  => 'Plugin KASSA.AT For WooCommerce deactivated.',
     284            'location' => kaw_get_locationstring(),
     285        ),
     286        true
     287    );
    148288    delete_option( 'kaw-message-active' );
    149289}
     
    209349add_action( 'wp_ajax_my_dismiss_notice', 'kaw_update_kaw_message_active' );
    210350
     351/**
     352 * Get the current Filename and Linenumber!
     353 */
     354function kaw_get_locationstring() {
     355    $bt     = debug_backtrace(); /* phpcs:ignore */
     356    $caller = array_shift( $bt );
     357    if ( count( explode( 'wp-content', $caller['file'] ) ) === 2 ) {
     358        $path = '/wp-content' . explode( 'wp-content', $caller['file'] )[1];
     359    } else {
     360        $path = $caller['file'];
     361    }
     362    return $path . ':' . $caller['line'];
     363}
     364
    211365require 'api-connection.php';
    212366require 'create-menus.php';
  • kassa-at-for-woocommerce/trunk/languages/kassa-at-for-woocommerce-de_AT.po

    r2450545 r2665761  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: KASSA.AT For WooCommerce 1.0.0\n"
    4 "POT-Creation-Date: 2020-12-29 09:23+0100\n"
    5 "PO-Revision-Date: 2020-12-29 09:24+0100\n"
     3"Project-Id-Version: KASSA.AT For WooCommerce 1.1.0\n"
     4"POT-Creation-Date: 2022-01-24 10:34+0100\n"
     5"PO-Revision-Date: 2022-01-24 20:58+0100\n"
    66"Last-Translator: manuelschultz\n"
    77"Language-Team: KASSA.AT\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.4.2\n"
     12"X-Generator: Poedit 3.0\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    1919"X-Poedit-SearchPath-3: stock-syncro.php\n"
    2020
    21 #: create-menus.php:33
     21#: create-menus.php:28 create-menus.php:29
     22msgid "Options"
     23msgstr "Optionen"
     24
     25#: create-menus.php:37 create-menus.php:38
     26msgid "Logs"
     27msgstr "Logs"
     28
     29#: create-menus.php:51
    2230msgid "You do not have sufficient permissions to access this page."
    2331msgstr ""
    2432"Sie haben nicht die nötigen Berechtigungen um auf die Seite zuzugreifen."
    2533
    26 #: create-menus.php:152
     34#: create-menus.php:232
    2735msgid "KASSA.AT connection:"
    2836msgstr "Verbindung zu KASSA.AT:"
    2937
    30 #: create-menus.php:155
     38#: create-menus.php:235
    3139msgid "You are already connected to a KASSA.AT account."
    32 msgstr "Sie sind bereits mit einer KASSA.AT-Konto. verbunden."
    33 
    34 #: create-menus.php:158
     40msgstr "Sie sind bereits mit einem KASSA.AT-Konto verbunden."
     41
     42#: create-menus.php:238
    3543msgid "Remove connection to KASSA.AT."
    3644msgstr "Entfernen Sie die Verbindung zu KASSA.AT."
    3745
    38 #: create-menus.php:166
     46#: create-menus.php:248
    3947msgid "Connect with KASSA.AT account"
    4048msgstr "Mit KASSA.AT Verbinden"
    4149
    42 #: create-menus.php:171
     50#: create-menus.php:253
    4351msgid "Dont have a KASSA.AT account? Create one!"
    4452msgstr "Haben Sie kein KASSA.AT-Konto? Erstellen Sie eines!"
    4553
    46 #: create-menus.php:177
     54#: create-menus.php:259
    4755msgid "Synchronize Stocks:"
    4856msgstr "Synchronisieren Sie den Lagerstand:"
    4957
    50 #: create-menus.php:178
     58#: create-menus.php:260
    5159msgid "Choose warehouse:"
    5260msgstr "Wählen Sie ein Lager:"
    5361
    54 #: create-menus.php:188
     62#: create-menus.php:270
    5563msgid "Save changes!"
    5664msgstr "Änderungen speichern!"
    5765
    58 #: create-menus.php:195
     66#: create-menus.php:277
    5967msgid "Synchronize stocks with KASSA.AT."
    6068msgstr "Lagerstände mit KASSA.AT synchronisieren."
    6169
    62 #: create-menus.php:196
     70#: create-menus.php:278
    6371msgid "Use KASSA.AT-data"
    6472msgstr "KASSA.AT-Daten als Master verwenden"
    6573
    66 #: create-menus.php:203
     74#: create-menus.php:285
    6775msgid "Synchronize!"
    6876msgstr "Synchronisieren!"
    6977
    70 #: kassa-at-for-woocommerce.php:167
     78#: create-menus.php:296
     79msgid "Synchronize on the Single Product Page!"
     80msgstr "Synchronisieren auf der Produktseite!"
     81
     82#: create-menus.php:305
     83msgid "Synchronize on the Cart Page!"
     84msgstr "Synchronisieren im Einkaufswagen!"
     85
     86#: create-menus.php:314
     87msgid "Synchronize when the order is received!"
     88msgstr "Synchronisieren wenn eine Bestellung eingeht!"
     89
     90#: create-menus.php:404 create-menus.php:560
     91msgid "Parameters"
     92msgstr "Parameter"
     93
     94#: create-menus.php:405 create-menus.php:561
     95msgid "API-Key"
     96msgstr "API-Schlüssel"
     97
     98#: create-menus.php:406 create-menus.php:562
     99msgid "Result"
     100msgstr "Ergebnis"
     101
     102#: create-menus.php:407 create-menus.php:409 create-menus.php:412
     103#: create-menus.php:414 create-menus.php:563 create-menus.php:565
     104#: create-menus.php:568 create-menus.php:570
     105msgid "Location"
     106msgstr "Ort"
     107
     108#: create-menus.php:411 create-menus.php:567
     109msgid "Changes"
     110msgstr "Änderungen"
     111
     112#: create-menus.php:509
     113msgid "Plugin Logs:"
     114msgstr "Plugin Logs:"
     115
     116#: create-menus.php:512
     117msgid "Reload logfile"
     118msgstr "Logdatei neu laden"
     119
     120#: create-menus.php:513
     121msgid "Refreshed"
     122msgstr "Aktualisiert"
     123
     124#: create-menus.php:518 create-menus.php:519
     125msgid "Enable Logging"
     126msgstr "Logging aktivieren"
     127
     128#: create-menus.php:518 create-menus.php:519
     129msgid "Disable Logging"
     130msgstr "Logging deaktivieren"
     131
     132#: create-menus.php:521
     133msgid "Delete logfile"
     134msgstr "Logdatei leeren"
     135
     136#: create-menus.php:522
     137msgid "Download logfile"
     138msgstr "Logdatei herunterladen"
     139
     140#: create-menus.php:527 create-menus.php:528 create-menus.php:529
     141#: create-menus.php:530 create-menus.php:532
     142msgid "lines"
     143msgstr "Zeilen"
     144
     145#: create-menus.php:535
     146msgid "Limit kaw-log length"
     147msgstr "Länge der Logdatei begrenzen"
     148
     149#: create-menus.php:535
     150msgid "Save"
     151msgstr "Speichern"
     152
     153#: create-menus.php:577
     154msgid "Database options"
     155msgstr "Datenbank Optionen"
     156
     157#: create-menus.php:581
     158msgid "Creator"
     159msgstr "Ersteller"
     160
     161#: create-menus.php:582
     162msgid "Option-name"
     163msgstr "Name der Option"
     164
     165#: create-menus.php:583
     166msgid "Option-value"
     167msgstr "Wert der Option"
     168
     169#: create-menus.php:588 create-menus.php:593 create-menus.php:598
     170#: create-menus.php:603 create-menus.php:608 create-menus.php:613
     171#: create-menus.php:618 create-menus.php:623 create-menus.php:628
     172msgid "KASSA.AT For WooCommerce"
     173msgstr "KASSA.AT Für WooCommerce"
     174
     175#: kassa-at-for-woocommerce.php:316
    71176msgid "Please follow these instructions to use the plugin:"
    72177msgstr "Bitte folgen Sie den Anweisungen, um das Plugin einzurichten:"
    73178
    74 #: kassa-at-for-woocommerce.php:171
     179#: kassa-at-for-woocommerce.php:320
    75180#, php-format
    76181msgid ""
     
    81186"a>."
    82187
    83 #: kassa-at-for-woocommerce.php:172
     188#: kassa-at-for-woocommerce.php:321
    84189msgid ""
    85190"Use the Button \"Connect with KASSA.AT account\" to connect to the register-"
     
    89194"herzustellen."
    90195
    91 #: kassa-at-for-woocommerce.php:176
     196#: kassa-at-for-woocommerce.php:325
    92197msgid ""
    93198"Login the KASSA.AT site and create your articles. Note that in order to have "
     
    99204"später noch wichtig)."
    100205
    101 #: kassa-at-for-woocommerce.php:177
     206#: kassa-at-for-woocommerce.php:326
    102207msgid ""
    103208"In your KASSA.AT account, create a warehouse and assign the articles to it."
     
    106211"mit Ihren Artikeln."
    107212
    108 #: kassa-at-for-woocommerce.php:178
     213#: kassa-at-for-woocommerce.php:327
    109214msgid ""
    110215"Go back to your WordPress page, choose your register-warehouse from your "
     
    114219"das Sie eben befüllt haben."
    115220
    116 #: kassa-at-for-woocommerce.php:179
     221#: kassa-at-for-woocommerce.php:328
    117222msgid ""
    118223"Go to your woocommerce-article section and create or edit your articles, use "
     
    125230"eintragen und aktivieren Sie \"Lagerbestand verwalten\"."
    126231
    127 #: kassa-at-for-woocommerce.php:180
     232#: kassa-at-for-woocommerce.php:329
    128233msgid ""
    129234"Go to the KASSA.AT-menu in your wordpress-site and press the \"Synchronize!"
     
    133238"Sie auf den \"Synchronisieren!\"-Knopf."
    134239
    135 #: kassa-at-for-woocommerce.php:182
     240#: kassa-at-for-woocommerce.php:331
    136241msgid ""
    137242"And here we go. Whenever a customer buys anything in your local store or a "
     
    145250"Blick haben können."
    146251
    147 #: kassa-at-for-woocommerce.php:188
     252#: kassa-at-for-woocommerce.php:337
    148253#, php-format
    149254msgid "If you have any questions with the setting up, feel free to %s."
    150255msgstr "Wenn Sie irgendwelche Fragen haben, %s."
    151256
    152 #: kassa-at-for-woocommerce.php:192
     257#: kassa-at-for-woocommerce.php:341
    153258msgid "contact us"
    154259msgstr "kontaktieren Sie uns"
    155260
    156 #: stock-syncro.php:96
     261#: stock-syncro.php:149
    157262#, php-format
    158263msgid "Woocommerce Invoice: %s"
  • kassa-at-for-woocommerce/trunk/languages/kassa-at-for-woocommerce-de_CH.po

    r2450545 r2665761  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: KASSA.AT For WooCommerce 1.0.0\n"
    4 "POT-Creation-Date: 2020-12-29 09:25+0100\n"
    5 "PO-Revision-Date: 2020-12-29 09:25+0100\n"
     3"Project-Id-Version: KASSA.AT For WooCommerce 1.1.0\n"
     4"POT-Creation-Date: 2022-01-24 12:52+0100\n"
     5"PO-Revision-Date: 2022-01-24 20:59+0100\n"
    66"Last-Translator: manuelschultz\n"
    77"Language-Team: KASSA.AT\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.4.2\n"
     12"X-Generator: Poedit 3.0\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    1919"X-Poedit-SearchPath-3: stock-syncro.php\n"
    2020
    21 #: create-menus.php:33
     21#: create-menus.php:28 create-menus.php:29
     22msgid "Options"
     23msgstr "Optionen"
     24
     25#: create-menus.php:37 create-menus.php:38
     26msgid "Logs"
     27msgstr "Logs"
     28
     29#: create-menus.php:51
    2230msgid "You do not have sufficient permissions to access this page."
    2331msgstr ""
    2432"Sie haben nicht die nötigen Berechtigungen um auf die Seite zuzugreifen."
    2533
    26 #: create-menus.php:152
     34#: create-menus.php:232
    2735msgid "KASSA.AT connection:"
    2836msgstr "Verbindung zu KASSA.AT:"
    2937
    30 #: create-menus.php:155
     38#: create-menus.php:235
    3139msgid "You are already connected to a KASSA.AT account."
    32 msgstr "Sie sind bereits mit einer KASSA.AT-Konto. verbunden."
    33 
    34 #: create-menus.php:158
     40msgstr "Sie sind bereits mit einem KASSA.AT-Konto verbunden."
     41
     42#: create-menus.php:238
    3543msgid "Remove connection to KASSA.AT."
    3644msgstr "Entfernen Sie die Verbindung zu KASSA.AT."
    3745
    38 #: create-menus.php:166
     46#: create-menus.php:248
    3947msgid "Connect with KASSA.AT account"
    4048msgstr "Mit KASSA.AT Verbinden"
    4149
    42 #: create-menus.php:171
     50#: create-menus.php:253
    4351msgid "Dont have a KASSA.AT account? Create one!"
    4452msgstr "Haben Sie kein KASSA.AT-Konto? Erstellen Sie eines!"
    4553
    46 #: create-menus.php:177
     54#: create-menus.php:259
    4755msgid "Synchronize Stocks:"
    4856msgstr "Synchronisieren Sie den Lagerstand:"
    4957
    50 #: create-menus.php:178
     58#: create-menus.php:260
    5159msgid "Choose warehouse:"
    5260msgstr "Wählen Sie ein Lager:"
    5361
    54 #: create-menus.php:188
     62#: create-menus.php:270
    5563msgid "Save changes!"
    5664msgstr "Änderungen speichern!"
    5765
    58 #: create-menus.php:195
     66#: create-menus.php:277
    5967msgid "Synchronize stocks with KASSA.AT."
    6068msgstr "Lagerstände mit KASSA.AT synchronisieren."
    6169
    62 #: create-menus.php:196
     70#: create-menus.php:278
    6371msgid "Use KASSA.AT-data"
    6472msgstr "KASSA.AT-Daten als Master verwenden"
    6573
    66 #: create-menus.php:203
     74#: create-menus.php:285
    6775msgid "Synchronize!"
    6876msgstr "Synchronisieren!"
    6977
    70 #: kassa-at-for-woocommerce.php:167
     78#: create-menus.php:296
     79msgid "Synchronize on the Single Product Page!"
     80msgstr "Synchronisieren auf der Produktseite!"
     81
     82#: create-menus.php:305
     83msgid "Synchronize on the Cart Page!"
     84msgstr "Synchronisieren im Einkaufswagen!"
     85
     86#: create-menus.php:314
     87msgid "Synchronize when the order is received!"
     88msgstr "Synchronisieren wenn eine Bestellung eingeht!"
     89
     90#: create-menus.php:404 create-menus.php:560
     91msgid "Parameters"
     92msgstr "Parameter"
     93
     94#: create-menus.php:405 create-menus.php:561
     95msgid "API-Key"
     96msgstr "API-Schlüssel"
     97
     98#: create-menus.php:406 create-menus.php:562
     99msgid "Result"
     100msgstr "Ergebnis"
     101
     102#: create-menus.php:407 create-menus.php:409 create-menus.php:412
     103#: create-menus.php:414 create-menus.php:563 create-menus.php:565
     104#: create-menus.php:568 create-menus.php:570
     105msgid "Location"
     106msgstr "Ort"
     107
     108#: create-menus.php:411 create-menus.php:567
     109msgid "Changes"
     110msgstr "Änderungen"
     111
     112#: create-menus.php:509
     113msgid "Plugin Logs:"
     114msgstr "Plugin Logs:"
     115
     116#: create-menus.php:512
     117msgid "Reload logfile"
     118msgstr "Logdatei neu laden"
     119
     120#: create-menus.php:513
     121msgid "Refreshed"
     122msgstr "Aktualisiert"
     123
     124#: create-menus.php:518 create-menus.php:519
     125msgid "Enable Logging"
     126msgstr "Logging aktivieren"
     127
     128#: create-menus.php:518 create-menus.php:519
     129msgid "Disable Logging"
     130msgstr "Logging deaktivieren"
     131
     132#: create-menus.php:521
     133msgid "Delete logfile"
     134msgstr "Logdatei leeren"
     135
     136#: create-menus.php:522
     137msgid "Download logfile"
     138msgstr "Logdatei herunterladen"
     139
     140#: create-menus.php:527 create-menus.php:528 create-menus.php:529
     141#: create-menus.php:530 create-menus.php:532
     142msgid "lines"
     143msgstr "Zeilen"
     144
     145#: create-menus.php:535
     146msgid "Limit kaw-log length"
     147msgstr "Länge der Logdatei begrenzen"
     148
     149#: create-menus.php:535
     150msgid "Save"
     151msgstr "Speichern"
     152
     153#: create-menus.php:577
     154msgid "Database options"
     155msgstr "Datenbank Optionen"
     156
     157#: create-menus.php:581
     158msgid "Creator"
     159msgstr "Ersteller"
     160
     161#: create-menus.php:582
     162msgid "Option-name"
     163msgstr "Name der Option"
     164
     165#: create-menus.php:583
     166msgid "Option-value"
     167msgstr "Wert der Option"
     168
     169#: create-menus.php:588 create-menus.php:593 create-menus.php:598
     170#: create-menus.php:603 create-menus.php:608 create-menus.php:613
     171#: create-menus.php:618 create-menus.php:623 create-menus.php:628
     172msgid "KASSA.AT For WooCommerce"
     173msgstr "KASSA.AT Für WooCommerce"
     174
     175#: kassa-at-for-woocommerce.php:316
    71176msgid "Please follow these instructions to use the plugin:"
    72177msgstr "Bitte folgen Sie den Anweisungen, um das Plugin einzurichten:"
    73178
    74 #: kassa-at-for-woocommerce.php:171
     179#: kassa-at-for-woocommerce.php:320
    75180#, php-format
    76181msgid ""
     
    81186"a>."
    82187
    83 #: kassa-at-for-woocommerce.php:172
     188#: kassa-at-for-woocommerce.php:321
    84189msgid ""
    85190"Use the Button \"Connect with KASSA.AT account\" to connect to the register-"
     
    89194"herzustellen."
    90195
    91 #: kassa-at-for-woocommerce.php:176
     196#: kassa-at-for-woocommerce.php:325
    92197msgid ""
    93198"Login the KASSA.AT site and create your articles. Note that in order to have "
     
    99204"später noch wichtig)."
    100205
    101 #: kassa-at-for-woocommerce.php:177
     206#: kassa-at-for-woocommerce.php:326
    102207msgid ""
    103208"In your KASSA.AT account, create a warehouse and assign the articles to it."
     
    106211"mit Ihren Artikeln."
    107212
    108 #: kassa-at-for-woocommerce.php:178
     213#: kassa-at-for-woocommerce.php:327
    109214msgid ""
    110215"Go back to your WordPress page, choose your register-warehouse from your "
     
    114219"das Sie eben befüllt haben."
    115220
    116 #: kassa-at-for-woocommerce.php:179
     221#: kassa-at-for-woocommerce.php:328
    117222msgid ""
    118223"Go to your woocommerce-article section and create or edit your articles, use "
     
    125230"eintragen und aktivieren Sie \"Lagerbestand verwalten\"."
    126231
    127 #: kassa-at-for-woocommerce.php:180
     232#: kassa-at-for-woocommerce.php:329
    128233msgid ""
    129234"Go to the KASSA.AT-menu in your wordpress-site and press the \"Synchronize!"
     
    133238"Sie auf den \"Synchronisieren!\"-Knopf."
    134239
    135 #: kassa-at-for-woocommerce.php:182
     240#: kassa-at-for-woocommerce.php:331
    136241msgid ""
    137242"And here we go. Whenever a customer buys anything in your local store or a "
     
    145250"Blick haben können."
    146251
    147 #: kassa-at-for-woocommerce.php:188
     252#: kassa-at-for-woocommerce.php:337
    148253#, php-format
    149254msgid "If you have any questions with the setting up, feel free to %s."
    150255msgstr "Wenn Sie irgendwelche Fragen haben, %s."
    151256
    152 #: kassa-at-for-woocommerce.php:192
     257#: kassa-at-for-woocommerce.php:341
    153258msgid "contact us"
    154259msgstr "kontaktieren Sie uns"
    155260
    156 #: stock-syncro.php:96
     261#: stock-syncro.php:149
    157262#, php-format
    158263msgid "Woocommerce Invoice: %s"
  • kassa-at-for-woocommerce/trunk/languages/kassa-at-for-woocommerce-de_CH_formal.po

    r2450545 r2665761  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: KASSA.AT For WooCommerce 1.0.0\n"
    4 "POT-Creation-Date: 2020-12-29 09:26+0100\n"
    5 "PO-Revision-Date: 2020-12-29 09:26+0100\n"
     3"Project-Id-Version: KASSA.AT For WooCommerce 1.1.0\n"
     4"POT-Creation-Date: 2022-01-24 10:36+0100\n"
     5"PO-Revision-Date: 2022-01-24 20:59+0100\n"
    66"Last-Translator: manuelschultz\n"
    77"Language-Team: KASSA.AT\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.4.2\n"
     12"X-Generator: Poedit 3.0\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    1919"X-Poedit-SearchPath-3: stock-syncro.php\n"
    2020
    21 #: create-menus.php:33
     21#: create-menus.php:28 create-menus.php:29
     22msgid "Options"
     23msgstr "Optionen"
     24
     25#: create-menus.php:37 create-menus.php:38
     26msgid "Logs"
     27msgstr "Logs"
     28
     29#: create-menus.php:51
    2230msgid "You do not have sufficient permissions to access this page."
    2331msgstr ""
    2432"Sie haben nicht die nötigen Berechtigungen um auf die Seite zuzugreifen."
    2533
    26 #: create-menus.php:152
     34#: create-menus.php:232
    2735msgid "KASSA.AT connection:"
    2836msgstr "Verbindung zu KASSA.AT:"
    2937
    30 #: create-menus.php:155
     38#: create-menus.php:235
    3139msgid "You are already connected to a KASSA.AT account."
    32 msgstr "Sie sind bereits mit einer KASSA.AT-Konto. verbunden."
    33 
    34 #: create-menus.php:158
     40msgstr "Sie sind bereits mit einem KASSA.AT-Konto verbunden."
     41
     42#: create-menus.php:238
    3543msgid "Remove connection to KASSA.AT."
    3644msgstr "Entfernen Sie die Verbindung zu KASSA.AT."
    3745
    38 #: create-menus.php:166
     46#: create-menus.php:248
    3947msgid "Connect with KASSA.AT account"
    4048msgstr "Mit KASSA.AT Verbinden"
    4149
    42 #: create-menus.php:171
     50#: create-menus.php:253
    4351msgid "Dont have a KASSA.AT account? Create one!"
    4452msgstr "Haben Sie kein KASSA.AT-Konto? Erstellen Sie eines!"
    4553
    46 #: create-menus.php:177
     54#: create-menus.php:259
    4755msgid "Synchronize Stocks:"
    4856msgstr "Synchronisieren Sie den Lagerstand:"
    4957
    50 #: create-menus.php:178
     58#: create-menus.php:260
    5159msgid "Choose warehouse:"
    5260msgstr "Wählen Sie ein Lager:"
    5361
    54 #: create-menus.php:188
     62#: create-menus.php:270
    5563msgid "Save changes!"
    5664msgstr "Änderungen speichern!"
    5765
    58 #: create-menus.php:195
     66#: create-menus.php:277
    5967msgid "Synchronize stocks with KASSA.AT."
    6068msgstr "Lagerstände mit KASSA.AT synchronisieren."
    6169
    62 #: create-menus.php:196
     70#: create-menus.php:278
    6371msgid "Use KASSA.AT-data"
    6472msgstr "KASSA.AT-Daten als Master verwenden"
    6573
    66 #: create-menus.php:203
     74#: create-menus.php:285
    6775msgid "Synchronize!"
    6876msgstr "Synchronisieren!"
    6977
    70 #: kassa-at-for-woocommerce.php:167
     78#: create-menus.php:296
     79msgid "Synchronize on the Single Product Page!"
     80msgstr "Synchronisieren auf der Produktseite!"
     81
     82#: create-menus.php:305
     83msgid "Synchronize on the Cart Page!"
     84msgstr "Synchronisieren im Einkaufswagen!"
     85
     86#: create-menus.php:314
     87msgid "Synchronize when the order is received!"
     88msgstr "Synchronisieren wenn eine Bestellung eingeht!"
     89
     90#: create-menus.php:404 create-menus.php:560
     91msgid "Parameters"
     92msgstr "Parameter"
     93
     94#: create-menus.php:405 create-menus.php:561
     95msgid "API-Key"
     96msgstr "API-Schlüssel"
     97
     98#: create-menus.php:406 create-menus.php:562
     99msgid "Result"
     100msgstr "Ergebnis"
     101
     102#: create-menus.php:407 create-menus.php:409 create-menus.php:412
     103#: create-menus.php:414 create-menus.php:563 create-menus.php:565
     104#: create-menus.php:568 create-menus.php:570
     105msgid "Location"
     106msgstr "Ort"
     107
     108#: create-menus.php:411 create-menus.php:567
     109msgid "Changes"
     110msgstr "Änderungen"
     111
     112#: create-menus.php:509
     113msgid "Plugin Logs:"
     114msgstr "Plugin Logs:"
     115
     116#: create-menus.php:512
     117msgid "Reload logfile"
     118msgstr "Logdatei neu laden"
     119
     120#: create-menus.php:513
     121msgid "Refreshed"
     122msgstr "Aktualisiert"
     123
     124#: create-menus.php:518 create-menus.php:519
     125msgid "Enable Logging"
     126msgstr "Logging aktivieren"
     127
     128#: create-menus.php:518 create-menus.php:519
     129msgid "Disable Logging"
     130msgstr "Logging deaktivieren"
     131
     132#: create-menus.php:521
     133msgid "Delete logfile"
     134msgstr "Logdatei leeren"
     135
     136#: create-menus.php:522
     137msgid "Download logfile"
     138msgstr "Logdatei herunterladen"
     139
     140#: create-menus.php:527 create-menus.php:528 create-menus.php:529
     141#: create-menus.php:530 create-menus.php:532
     142msgid "lines"
     143msgstr "Zeilen"
     144
     145#: create-menus.php:535
     146msgid "Limit kaw-log length"
     147msgstr "Länge der Logdatei begrenzen"
     148
     149#: create-menus.php:535
     150msgid "Save"
     151msgstr "Speichern"
     152
     153#: create-menus.php:577
     154msgid "Database options"
     155msgstr "Datenbank Optionen"
     156
     157#: create-menus.php:581
     158msgid "Creator"
     159msgstr "Ersteller"
     160
     161#: create-menus.php:582
     162msgid "Option-name"
     163msgstr "Name der Option"
     164
     165#: create-menus.php:583
     166msgid "Option-value"
     167msgstr "Wert der Option"
     168
     169#: create-menus.php:588 create-menus.php:593 create-menus.php:598
     170#: create-menus.php:603 create-menus.php:608 create-menus.php:613
     171#: create-menus.php:618 create-menus.php:623 create-menus.php:628
     172msgid "KASSA.AT For WooCommerce"
     173msgstr "KASSA.AT Für WooCommerce"
     174
     175#: kassa-at-for-woocommerce.php:316
    71176msgid "Please follow these instructions to use the plugin:"
    72177msgstr "Bitte folgen Sie den Anweisungen, um das Plugin einzurichten:"
    73178
    74 #: kassa-at-for-woocommerce.php:171
     179#: kassa-at-for-woocommerce.php:320
    75180#, php-format
    76181msgid ""
     
    81186"a>."
    82187
    83 #: kassa-at-for-woocommerce.php:172
     188#: kassa-at-for-woocommerce.php:321
    84189msgid ""
    85190"Use the Button \"Connect with KASSA.AT account\" to connect to the register-"
     
    89194"herzustellen."
    90195
    91 #: kassa-at-for-woocommerce.php:176
     196#: kassa-at-for-woocommerce.php:325
    92197msgid ""
    93198"Login the KASSA.AT site and create your articles. Note that in order to have "
     
    99204"später noch wichtig)."
    100205
    101 #: kassa-at-for-woocommerce.php:177
     206#: kassa-at-for-woocommerce.php:326
    102207msgid ""
    103208"In your KASSA.AT account, create a warehouse and assign the articles to it."
     
    106211"mit Ihren Artikeln."
    107212
    108 #: kassa-at-for-woocommerce.php:178
     213#: kassa-at-for-woocommerce.php:327
    109214msgid ""
    110215"Go back to your WordPress page, choose your register-warehouse from your "
     
    114219"das Sie eben befüllt haben."
    115220
    116 #: kassa-at-for-woocommerce.php:179
     221#: kassa-at-for-woocommerce.php:328
    117222msgid ""
    118223"Go to your woocommerce-article section and create or edit your articles, use "
     
    125230"eintragen und aktivieren Sie \"Lagerbestand verwalten\"."
    126231
    127 #: kassa-at-for-woocommerce.php:180
     232#: kassa-at-for-woocommerce.php:329
    128233msgid ""
    129234"Go to the KASSA.AT-menu in your wordpress-site and press the \"Synchronize!"
     
    133238"Sie auf den \"Synchronisieren!\"-Knopf."
    134239
    135 #: kassa-at-for-woocommerce.php:182
     240#: kassa-at-for-woocommerce.php:331
    136241msgid ""
    137242"And here we go. Whenever a customer buys anything in your local store or a "
     
    145250"Blick haben können."
    146251
    147 #: kassa-at-for-woocommerce.php:188
     252#: kassa-at-for-woocommerce.php:337
    148253#, php-format
    149254msgid "If you have any questions with the setting up, feel free to %s."
    150255msgstr "Wenn Sie irgendwelche Fragen haben, %s."
    151256
    152 #: kassa-at-for-woocommerce.php:192
     257#: kassa-at-for-woocommerce.php:341
    153258msgid "contact us"
    154259msgstr "kontaktieren Sie uns"
    155260
    156 #: stock-syncro.php:96
     261#: stock-syncro.php:149
    157262#, php-format
    158263msgid "Woocommerce Invoice: %s"
  • kassa-at-for-woocommerce/trunk/languages/kassa-at-for-woocommerce-de_DE.po

    r2450545 r2665761  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: KASSA.AT For WooCommerce 1.0.0\n"
    4 "POT-Creation-Date: 2020-12-29 09:27+0100\n"
    5 "PO-Revision-Date: 2020-12-29 09:27+0100\n"
     3"Project-Id-Version: KASSA.AT For WooCommerce 1.1.0\n"
     4"POT-Creation-Date: 2022-01-24 10:36+0100\n"
     5"PO-Revision-Date: 2022-01-24 21:00+0100\n"
    66"Last-Translator: manuelschultz\n"
    77"Language-Team: KASSA.AT\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.4.2\n"
     12"X-Generator: Poedit 3.0\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    1919"X-Poedit-SearchPath-3: stock-syncro.php\n"
    2020
    21 #: create-menus.php:33
     21#: create-menus.php:28 create-menus.php:29
     22msgid "Options"
     23msgstr "Optionen"
     24
     25#: create-menus.php:37 create-menus.php:38
     26msgid "Logs"
     27msgstr "Logs"
     28
     29#: create-menus.php:51
    2230msgid "You do not have sufficient permissions to access this page."
    2331msgstr ""
    2432"Sie haben nicht die nötigen Berechtigungen um auf die Seite zuzugreifen."
    2533
    26 #: create-menus.php:152
     34#: create-menus.php:232
    2735msgid "KASSA.AT connection:"
    2836msgstr "Verbindung zu KASSA.AT:"
    2937
    30 #: create-menus.php:155
     38#: create-menus.php:235
    3139msgid "You are already connected to a KASSA.AT account."
    32 msgstr "Sie sind bereits mit einer KASSA.AT-Konto. verbunden."
    33 
    34 #: create-menus.php:158
     40msgstr "Sie sind bereits mit einem KASSA.AT-Konto verbunden."
     41
     42#: create-menus.php:238
    3543msgid "Remove connection to KASSA.AT."
    3644msgstr "Entfernen Sie die Verbindung zu KASSA.AT."
    3745
    38 #: create-menus.php:166
     46#: create-menus.php:248
    3947msgid "Connect with KASSA.AT account"
    4048msgstr "Mit KASSA.AT Verbinden"
    4149
    42 #: create-menus.php:171
     50#: create-menus.php:253
    4351msgid "Dont have a KASSA.AT account? Create one!"
    4452msgstr "Haben Sie kein KASSA.AT-Konto? Erstellen Sie eines!"
    4553
    46 #: create-menus.php:177
     54#: create-menus.php:259
    4755msgid "Synchronize Stocks:"
    4856msgstr "Synchronisieren Sie den Lagerstand:"
    4957
    50 #: create-menus.php:178
     58#: create-menus.php:260
    5159msgid "Choose warehouse:"
    5260msgstr "Wählen Sie ein Lager:"
    5361
    54 #: create-menus.php:188
     62#: create-menus.php:270
    5563msgid "Save changes!"
    5664msgstr "Änderungen speichern!"
    5765
    58 #: create-menus.php:195
     66#: create-menus.php:277
    5967msgid "Synchronize stocks with KASSA.AT."
    6068msgstr "Lagerstände mit KASSA.AT synchronisieren."
    6169
    62 #: create-menus.php:196
     70#: create-menus.php:278
    6371msgid "Use KASSA.AT-data"
    6472msgstr "KASSA.AT-Daten als Master verwenden"
    6573
    66 #: create-menus.php:203
     74#: create-menus.php:285
    6775msgid "Synchronize!"
    6876msgstr "Synchronisieren!"
    6977
    70 #: kassa-at-for-woocommerce.php:167
     78#: create-menus.php:296
     79msgid "Synchronize on the Single Product Page!"
     80msgstr "Synchronisieren auf der Produktseite!"
     81
     82#: create-menus.php:305
     83msgid "Synchronize on the Cart Page!"
     84msgstr "Synchronisieren im Einkaufswagen!"
     85
     86#: create-menus.php:314
     87msgid "Synchronize when the order is received!"
     88msgstr "Synchronisieren wenn eine Bestellung eingeht!"
     89
     90#: create-menus.php:404 create-menus.php:560
     91msgid "Parameters"
     92msgstr "Parameter"
     93
     94#: create-menus.php:405 create-menus.php:561
     95msgid "API-Key"
     96msgstr "API-Schlüssel"
     97
     98#: create-menus.php:406 create-menus.php:562
     99msgid "Result"
     100msgstr "Ergebnis"
     101
     102#: create-menus.php:407 create-menus.php:409 create-menus.php:412
     103#: create-menus.php:414 create-menus.php:563 create-menus.php:565
     104#: create-menus.php:568 create-menus.php:570
     105msgid "Location"
     106msgstr "Ort"
     107
     108#: create-menus.php:411 create-menus.php:567
     109msgid "Changes"
     110msgstr "Änderungen"
     111
     112#: create-menus.php:509
     113msgid "Plugin Logs:"
     114msgstr "Plugin Logs:"
     115
     116#: create-menus.php:512
     117msgid "Reload logfile"
     118msgstr "Logdatei neu laden"
     119
     120#: create-menus.php:513
     121msgid "Refreshed"
     122msgstr "Aktualisiert"
     123
     124#: create-menus.php:518 create-menus.php:519
     125msgid "Enable Logging"
     126msgstr "Logging aktivieren"
     127
     128#: create-menus.php:518 create-menus.php:519
     129msgid "Disable Logging"
     130msgstr "Logging deaktivieren"
     131
     132#: create-menus.php:521
     133msgid "Delete logfile"
     134msgstr "Logdatei leeren"
     135
     136#: create-menus.php:522
     137msgid "Download logfile"
     138msgstr "Logdatei herunterladen"
     139
     140#: create-menus.php:527 create-menus.php:528 create-menus.php:529
     141#: create-menus.php:530 create-menus.php:532
     142msgid "lines"
     143msgstr "Zeilen"
     144
     145#: create-menus.php:535
     146msgid "Limit kaw-log length"
     147msgstr "Länge der Logdatei begrenzen"
     148
     149#: create-menus.php:535
     150msgid "Save"
     151msgstr "Speichern"
     152
     153#: create-menus.php:577
     154msgid "Database options"
     155msgstr "Datenbank Optionen"
     156
     157#: create-menus.php:581
     158msgid "Creator"
     159msgstr "Ersteller"
     160
     161#: create-menus.php:582
     162msgid "Option-name"
     163msgstr "Name der Option"
     164
     165#: create-menus.php:583
     166msgid "Option-value"
     167msgstr "Wert der Option"
     168
     169#: create-menus.php:588 create-menus.php:593 create-menus.php:598
     170#: create-menus.php:603 create-menus.php:608 create-menus.php:613
     171#: create-menus.php:618 create-menus.php:623 create-menus.php:628
     172msgid "KASSA.AT For WooCommerce"
     173msgstr "KASSA.AT Für WooCommerce"
     174
     175#: kassa-at-for-woocommerce.php:316
    71176msgid "Please follow these instructions to use the plugin:"
    72177msgstr "Bitte folgen Sie den Anweisungen, um das Plugin einzurichten:"
    73178
    74 #: kassa-at-for-woocommerce.php:171
     179#: kassa-at-for-woocommerce.php:320
    75180#, php-format
    76181msgid ""
     
    81186"a>."
    82187
    83 #: kassa-at-for-woocommerce.php:172
     188#: kassa-at-for-woocommerce.php:321
    84189msgid ""
    85190"Use the Button \"Connect with KASSA.AT account\" to connect to the register-"
     
    89194"herzustellen."
    90195
    91 #: kassa-at-for-woocommerce.php:176
     196#: kassa-at-for-woocommerce.php:325
    92197msgid ""
    93198"Login the KASSA.AT site and create your articles. Note that in order to have "
     
    99204"später noch wichtig)."
    100205
    101 #: kassa-at-for-woocommerce.php:177
     206#: kassa-at-for-woocommerce.php:326
    102207msgid ""
    103208"In your KASSA.AT account, create a warehouse and assign the articles to it."
     
    106211"mit Ihren Artikeln."
    107212
    108 #: kassa-at-for-woocommerce.php:178
     213#: kassa-at-for-woocommerce.php:327
    109214msgid ""
    110215"Go back to your WordPress page, choose your register-warehouse from your "
     
    114219"das Sie eben befüllt haben."
    115220
    116 #: kassa-at-for-woocommerce.php:179
     221#: kassa-at-for-woocommerce.php:328
    117222msgid ""
    118223"Go to your woocommerce-article section and create or edit your articles, use "
     
    125230"eintragen und aktivieren Sie \"Lagerbestand verwalten\"."
    126231
    127 #: kassa-at-for-woocommerce.php:180
     232#: kassa-at-for-woocommerce.php:329
    128233msgid ""
    129234"Go to the KASSA.AT-menu in your wordpress-site and press the \"Synchronize!"
     
    133238"Sie auf den \"Synchronisieren!\"-Knopf."
    134239
    135 #: kassa-at-for-woocommerce.php:182
     240#: kassa-at-for-woocommerce.php:331
    136241msgid ""
    137242"And here we go. Whenever a customer buys anything in your local store or a "
     
    145250"Blick haben können."
    146251
    147 #: kassa-at-for-woocommerce.php:188
     252#: kassa-at-for-woocommerce.php:337
    148253#, php-format
    149254msgid "If you have any questions with the setting up, feel free to %s."
    150255msgstr "Wenn Sie irgendwelche Fragen haben, %s."
    151256
    152 #: kassa-at-for-woocommerce.php:192
     257#: kassa-at-for-woocommerce.php:341
    153258msgid "contact us"
    154259msgstr "kontaktieren Sie uns"
    155260
    156 #: stock-syncro.php:96
     261#: stock-syncro.php:149
    157262#, php-format
    158263msgid "Woocommerce Invoice: %s"
  • kassa-at-for-woocommerce/trunk/languages/kassa-at-for-woocommerce-de_DE_formal.po

    r2450545 r2665761  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: KASSA.AT For WooCommerce 1.0.0\n"
    4 "POT-Creation-Date: 2020-12-29 09:28+0100\n"
    5 "PO-Revision-Date: 2020-12-29 09:28+0100\n"
     3"Project-Id-Version: KASSA.AT For WooCommerce 1.1.0\n"
     4"POT-Creation-Date: 2022-01-20 09:32+0100\n"
     5"PO-Revision-Date: 2022-01-24 21:00+0100\n"
    66"Last-Translator: manuelschultz\n"
    77"Language-Team: KASSA.AT\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.4.2\n"
     12"X-Generator: Poedit 3.0\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    1919"X-Poedit-SearchPath-3: stock-syncro.php\n"
    2020
    21 #: create-menus.php:33
     21#: create-menus.php:28 create-menus.php:29
     22msgid "Options"
     23msgstr "Optionen"
     24
     25#: create-menus.php:37 create-menus.php:38
     26msgid "Logs"
     27msgstr "Logs"
     28
     29#: create-menus.php:51
    2230msgid "You do not have sufficient permissions to access this page."
    2331msgstr ""
    2432"Sie haben nicht die nötigen Berechtigungen um auf die Seite zuzugreifen."
    2533
    26 #: create-menus.php:152
     34#: create-menus.php:232
    2735msgid "KASSA.AT connection:"
    2836msgstr "Verbindung zu KASSA.AT:"
    2937
    30 #: create-menus.php:155
     38#: create-menus.php:235
    3139msgid "You are already connected to a KASSA.AT account."
    32 msgstr "Sie sind bereits mit einer KASSA.AT-Konto. verbunden."
    33 
    34 #: create-menus.php:158
     40msgstr "Sie sind bereits mit einem KASSA.AT-Konto verbunden."
     41
     42#: create-menus.php:238
    3543msgid "Remove connection to KASSA.AT."
    3644msgstr "Entfernen Sie die Verbindung zu KASSA.AT."
    3745
    38 #: create-menus.php:166
     46#: create-menus.php:248
    3947msgid "Connect with KASSA.AT account"
    4048msgstr "Mit KASSA.AT Verbinden"
    4149
    42 #: create-menus.php:171
     50#: create-menus.php:253
    4351msgid "Dont have a KASSA.AT account? Create one!"
    4452msgstr "Haben Sie kein KASSA.AT-Konto? Erstellen Sie eines!"
    4553
    46 #: create-menus.php:177
     54#: create-menus.php:259
    4755msgid "Synchronize Stocks:"
    4856msgstr "Synchronisieren Sie den Lagerstand:"
    4957
    50 #: create-menus.php:178
     58#: create-menus.php:260
    5159msgid "Choose warehouse:"
    5260msgstr "Wählen Sie ein Lager:"
    5361
    54 #: create-menus.php:188
     62#: create-menus.php:270
    5563msgid "Save changes!"
    5664msgstr "Änderungen speichern!"
    5765
    58 #: create-menus.php:195
     66#: create-menus.php:277
    5967msgid "Synchronize stocks with KASSA.AT."
    6068msgstr "Lagerstände mit KASSA.AT synchronisieren."
    6169
    62 #: create-menus.php:196
     70#: create-menus.php:278
    6371msgid "Use KASSA.AT-data"
    6472msgstr "KASSA.AT-Daten als Master verwenden"
    6573
    66 #: create-menus.php:203
     74#: create-menus.php:285
    6775msgid "Synchronize!"
    6876msgstr "Synchronisieren!"
    6977
    70 #: kassa-at-for-woocommerce.php:167
     78#: create-menus.php:296
     79msgid "Synchronize on the Single Product Page!"
     80msgstr "Synchronisieren auf der Produktseite!"
     81
     82#: create-menus.php:305
     83msgid "Synchronize on the Cart Page!"
     84msgstr "Synchronisieren im Einkaufswagen!"
     85
     86#: create-menus.php:314
     87msgid "Synchronize when the order is received!"
     88msgstr "Synchronisieren wenn eine Bestellung eingeht!"
     89
     90#: create-menus.php:404 create-menus.php:560
     91msgid "Parameters"
     92msgstr "Parameter"
     93
     94#: create-menus.php:405 create-menus.php:561
     95msgid "API-Key"
     96msgstr "API-Schlüssel"
     97
     98#: create-menus.php:406 create-menus.php:562
     99msgid "Result"
     100msgstr "Ergebnis"
     101
     102#: create-menus.php:407 create-menus.php:409 create-menus.php:412
     103#: create-menus.php:414 create-menus.php:563 create-menus.php:565
     104#: create-menus.php:568 create-menus.php:570
     105msgid "Location"
     106msgstr "Ort"
     107
     108#: create-menus.php:411 create-menus.php:567
     109msgid "Changes"
     110msgstr "Änderungen"
     111
     112#: create-menus.php:509
     113msgid "Plugin Logs:"
     114msgstr "Plugin Logs:"
     115
     116#: create-menus.php:512
     117msgid "Reload logfile"
     118msgstr "Logdatei neu laden"
     119
     120#: create-menus.php:513
     121msgid "Refreshed"
     122msgstr "Aktualisiert"
     123
     124#: create-menus.php:518 create-menus.php:519
     125msgid "Enable Logging"
     126msgstr "Logging aktivieren"
     127
     128#: create-menus.php:518 create-menus.php:519
     129msgid "Disable Logging"
     130msgstr "Logging deaktivieren"
     131
     132#: create-menus.php:521
     133msgid "Delete logfile"
     134msgstr "Logdatei leeren"
     135
     136#: create-menus.php:522
     137msgid "Download logfile"
     138msgstr "Logdatei herunterladen"
     139
     140#: create-menus.php:527 create-menus.php:528 create-menus.php:529
     141#: create-menus.php:530 create-menus.php:532
     142msgid "lines"
     143msgstr "Zeilen"
     144
     145#: create-menus.php:535
     146msgid "Limit kaw-log length"
     147msgstr "Länge der Logdatei begrenzen"
     148
     149#: create-menus.php:535
     150msgid "Save"
     151msgstr "Speichern"
     152
     153#: create-menus.php:581
     154msgid "Creator"
     155msgstr "Ersteller"
     156
     157#: create-menus.php:582
     158msgid "Option-name"
     159msgstr "Name der Option"
     160
     161#: create-menus.php:583
     162msgid "Option-value"
     163msgstr "Wert der Option"
     164
     165#: create-menus.php:588 create-menus.php:593 create-menus.php:598
     166#: create-menus.php:603 create-menus.php:608 create-menus.php:613
     167#: create-menus.php:618 create-menus.php:623 create-menus.php:628
     168msgid "KASSA.AT For WooCommerce"
     169msgstr "KASSA.AT Für WooCommerce"
     170
     171#: kassa-at-for-woocommerce.php:315
    71172msgid "Please follow these instructions to use the plugin:"
    72173msgstr "Bitte folgen Sie den Anweisungen, um das Plugin einzurichten:"
    73174
    74 #: kassa-at-for-woocommerce.php:171
     175#: kassa-at-for-woocommerce.php:319
    75176#, php-format
    76177msgid ""
     
    81182"a>."
    82183
    83 #: kassa-at-for-woocommerce.php:172
     184#: kassa-at-for-woocommerce.php:320
    84185msgid ""
    85186"Use the Button \"Connect with KASSA.AT account\" to connect to the register-"
     
    89190"herzustellen."
    90191
    91 #: kassa-at-for-woocommerce.php:176
     192#: kassa-at-for-woocommerce.php:324
    92193msgid ""
    93194"Login the KASSA.AT site and create your articles. Note that in order to have "
     
    99200"später noch wichtig)."
    100201
    101 #: kassa-at-for-woocommerce.php:177
     202#: kassa-at-for-woocommerce.php:325
    102203msgid ""
    103204"In your KASSA.AT account, create a warehouse and assign the articles to it."
     
    106207"mit Ihren Artikeln."
    107208
    108 #: kassa-at-for-woocommerce.php:178
     209#: kassa-at-for-woocommerce.php:326
    109210msgid ""
    110211"Go back to your WordPress page, choose your register-warehouse from your "
     
    114215"das Sie eben befüllt haben."
    115216
    116 #: kassa-at-for-woocommerce.php:179
     217#: kassa-at-for-woocommerce.php:327
    117218msgid ""
    118219"Go to your woocommerce-article section and create or edit your articles, use "
     
    125226"eintragen und aktivieren Sie \"Lagerbestand verwalten\"."
    126227
    127 #: kassa-at-for-woocommerce.php:180
     228#: kassa-at-for-woocommerce.php:328
    128229msgid ""
    129230"Go to the KASSA.AT-menu in your wordpress-site and press the \"Synchronize!"
     
    133234"Sie auf den \"Synchronisieren!\"-Knopf."
    134235
    135 #: kassa-at-for-woocommerce.php:182
     236#: kassa-at-for-woocommerce.php:330
    136237msgid ""
    137238"And here we go. Whenever a customer buys anything in your local store or a "
     
    145246"Blick haben können."
    146247
    147 #: kassa-at-for-woocommerce.php:188
     248#: kassa-at-for-woocommerce.php:336
    148249#, php-format
    149250msgid "If you have any questions with the setting up, feel free to %s."
    150251msgstr "Wenn Sie irgendwelche Fragen haben, %s."
    151252
    152 #: kassa-at-for-woocommerce.php:192
     253#: kassa-at-for-woocommerce.php:340
    153254msgid "contact us"
    154255msgstr "kontaktieren Sie uns"
    155256
    156 #: stock-syncro.php:96
     257#: stock-syncro.php:149
    157258#, php-format
    158259msgid "Woocommerce Invoice: %s"
  • kassa-at-for-woocommerce/trunk/languages/kassa-at-for-woocommerce.pot

    r2450545 r2665761  
    22msgid ""
    33msgstr ""
    4 "Project-Id-Version: KASSA.AT For WooCommerce 1.0.0\n"
    5 "POT-Creation-Date: 2020-12-29 09:22+0100\n"
     4"Project-Id-Version: KASSA.AT For WooCommerce 1.1.0\n"
     5"POT-Creation-Date: 2022-01-24 12:51+0100\n"
    66"PO-Revision-Date: 2020-09-22 15:49+0200\n"
    77"Last-Translator: manuelschultz\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 2.4.2\n"
     12"X-Generator: Poedit 3.0\n"
    1313"X-Poedit-Basepath: ..\n"
    1414"Plural-Forms: nplurals=2; plural=(n != 1);\n"
     
    2020"X-Poedit-SearchPath-3: stock-syncro.php\n"
    2121
    22 #: create-menus.php:33
     22#: create-menus.php:28 create-menus.php:29
     23msgid "Options"
     24msgstr ""
     25
     26#: create-menus.php:37 create-menus.php:38
     27msgid "Logs"
     28msgstr ""
     29
     30#: create-menus.php:51
    2331msgid "You do not have sufficient permissions to access this page."
    2432msgstr ""
    2533
    26 #: create-menus.php:152
     34#: create-menus.php:232
    2735msgid "KASSA.AT connection:"
    2836msgstr ""
    2937
    30 #: create-menus.php:155
     38#: create-menus.php:235
    3139msgid "You are already connected to a KASSA.AT account."
    3240msgstr ""
    3341
    34 #: create-menus.php:158
     42#: create-menus.php:238
    3543msgid "Remove connection to KASSA.AT."
    3644msgstr ""
    3745
    38 #: create-menus.php:166
     46#: create-menus.php:248
    3947msgid "Connect with KASSA.AT account"
    4048msgstr ""
    4149
    42 #: create-menus.php:171
     50#: create-menus.php:253
    4351msgid "Dont have a KASSA.AT account? Create one!"
    4452msgstr ""
    4553
    46 #: create-menus.php:177
     54#: create-menus.php:259
    4755msgid "Synchronize Stocks:"
    4856msgstr ""
    4957
    50 #: create-menus.php:178
     58#: create-menus.php:260
    5159msgid "Choose warehouse:"
    5260msgstr ""
    5361
    54 #: create-menus.php:188
     62#: create-menus.php:270
    5563msgid "Save changes!"
    5664msgstr ""
    5765
    58 #: create-menus.php:195
     66#: create-menus.php:277
    5967msgid "Synchronize stocks with KASSA.AT."
    6068msgstr ""
    6169
    62 #: create-menus.php:196
     70#: create-menus.php:278
    6371msgid "Use KASSA.AT-data"
    6472msgstr ""
    6573
    66 #: create-menus.php:203
     74#: create-menus.php:285
    6775msgid "Synchronize!"
    6876msgstr ""
    6977
    70 #: kassa-at-for-woocommerce.php:167
     78#: create-menus.php:296
     79msgid "Synchronize on the Single Product Page!"
     80msgstr ""
     81
     82#: create-menus.php:305
     83msgid "Synchronize on the Cart Page!"
     84msgstr ""
     85
     86#: create-menus.php:314
     87msgid "Synchronize when the order is received!"
     88msgstr ""
     89
     90#: create-menus.php:404 create-menus.php:560
     91msgid "Parameters"
     92msgstr ""
     93
     94#: create-menus.php:405 create-menus.php:561
     95msgid "API-Key"
     96msgstr ""
     97
     98#: create-menus.php:406 create-menus.php:562
     99msgid "Result"
     100msgstr ""
     101
     102#: create-menus.php:407 create-menus.php:409 create-menus.php:412
     103#: create-menus.php:414 create-menus.php:563 create-menus.php:565
     104#: create-menus.php:568 create-menus.php:570
     105msgid "Location"
     106msgstr ""
     107
     108#: create-menus.php:411 create-menus.php:567
     109msgid "Changes"
     110msgstr ""
     111
     112#: create-menus.php:509
     113msgid "Plugin Logs:"
     114msgstr ""
     115
     116#: create-menus.php:512
     117msgid "Reload logfile"
     118msgstr ""
     119
     120#: create-menus.php:513
     121msgid "Refreshed"
     122msgstr ""
     123
     124#: create-menus.php:518 create-menus.php:519
     125msgid "Enable Logging"
     126msgstr ""
     127
     128#: create-menus.php:518 create-menus.php:519
     129msgid "Disable Logging"
     130msgstr ""
     131
     132#: create-menus.php:521
     133msgid "Delete logfile"
     134msgstr ""
     135
     136#: create-menus.php:522
     137msgid "Download logfile"
     138msgstr ""
     139
     140#: create-menus.php:527 create-menus.php:528 create-menus.php:529
     141#: create-menus.php:530 create-menus.php:532
     142msgid "lines"
     143msgstr ""
     144
     145#: create-menus.php:535
     146msgid "Limit kaw-log length"
     147msgstr ""
     148
     149#: create-menus.php:535
     150msgid "Save"
     151msgstr ""
     152
     153#: create-menus.php:577
     154msgid "Database options"
     155msgstr ""
     156
     157#: create-menus.php:581
     158msgid "Creator"
     159msgstr ""
     160
     161#: create-menus.php:582
     162msgid "Option-name"
     163msgstr ""
     164
     165#: create-menus.php:583
     166msgid "Option-value"
     167msgstr ""
     168
     169#: create-menus.php:588 create-menus.php:593 create-menus.php:598
     170#: create-menus.php:603 create-menus.php:608 create-menus.php:613
     171#: create-menus.php:618 create-menus.php:623 create-menus.php:628
     172msgid "KASSA.AT For WooCommerce"
     173msgstr ""
     174
     175#: kassa-at-for-woocommerce.php:316
    71176msgid "Please follow these instructions to use the plugin:"
    72177msgstr ""
    73178
    74 #: kassa-at-for-woocommerce.php:171
     179#: kassa-at-for-woocommerce.php:320
    75180#, php-format
    76181msgid "If you don't have a KASSA.AT account please create one <a href=\"%s\">here</a>."
    77182msgstr ""
    78183
    79 #: kassa-at-for-woocommerce.php:172
     184#: kassa-at-for-woocommerce.php:321
    80185msgid "Use the Button \"Connect with KASSA.AT account\" to connect to the register-service."
    81186msgstr ""
    82187
    83 #: kassa-at-for-woocommerce.php:176
     188#: kassa-at-for-woocommerce.php:325
    84189msgid "Login the KASSA.AT site and create your articles. Note that in order to have connect the WP-site and the KASSA.AT-account, you need to fill in the \"Artikelnummer\"-field with your article numbers."
    85190msgstr ""
    86191
    87 #: kassa-at-for-woocommerce.php:177
     192#: kassa-at-for-woocommerce.php:326
    88193msgid "In your KASSA.AT account, create a warehouse and assign the articles to it."
    89194msgstr ""
    90195
    91 #: kassa-at-for-woocommerce.php:178
     196#: kassa-at-for-woocommerce.php:327
    92197msgid "Go back to your WordPress page, choose your register-warehouse from your KASSA.AT's warehouses."
    93198msgstr ""
    94199
    95 #: kassa-at-for-woocommerce.php:179
     200#: kassa-at-for-woocommerce.php:328
    96201msgid "Go to your woocommerce-article section and create or edit your articles, use the article-number from your KASSA.AT-articles in the \"SKU\"-field and activate stock-management."
    97202msgstr ""
    98203
    99 #: kassa-at-for-woocommerce.php:180
     204#: kassa-at-for-woocommerce.php:329
    100205msgid "Go to the KASSA.AT-menu in your wordpress-site and press the \"Synchronize!\" Button."
    101206msgstr ""
    102207
    103 #: kassa-at-for-woocommerce.php:182
     208#: kassa-at-for-woocommerce.php:331
    104209msgid "And here we go. Whenever a customer buys anything in your local store or a customer orders something in your online-store, your KASSA.AT-service will have trace of that and will always check, that the onlineshop displays the correct amount of items in stock."
    105210msgstr ""
    106211
    107 #: kassa-at-for-woocommerce.php:188
     212#: kassa-at-for-woocommerce.php:337
    108213#, php-format
    109214msgid "If you have any questions with the setting up, feel free to %s."
    110215msgstr ""
    111216
    112 #: kassa-at-for-woocommerce.php:192
     217#: kassa-at-for-woocommerce.php:341
    113218msgid "contact us"
    114219msgstr ""
    115220
    116 #: stock-syncro.php:96
     221#: stock-syncro.php:149
    117222#, php-format
    118223msgid "Woocommerce Invoice: %s"
  • kassa-at-for-woocommerce/trunk/readme.txt

    r2611428 r2665761  
    33Tags: woocommerce, stock-management, stock, kassa.at, kasse.pro, lager, lagerhaltung
    44Donate link: http://kassa.at
    5 Requires at least: 5.4
    6 Tested up to: 5.8.1
     5Requires at least: 5.7
     6Tested up to: 5.9
    77Requires PHP: 7.0.33
    8 Stable tag: 1.0.2
     8Stable tag: 1.1.0
    99License: GPLv3 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515This Plugin is only useable with an account for KASSA.AT!
    1616If you dont have one, you can get one inside of the plugin.
     17The plugin synchronizes automatically the stock amounts between the onlineshop and the KASSA.AT System.
    1718
    1819= Features =
    1920* Logging in to KASSA.AT
    2021* Choosing a warehouse, the stocks should synchronize with.
    21 * Stock amounts are queried whenever a visitor enters the Site of an article to have the correct numbers here.
     22* Stock amounts are queried whenever a visitor enters the Page of an article to have the correct numbers here.
    2223* Stock amounts are queried whenever a visitor enters his cart, so we have the right amount of stock here too.
    2324* Whenever a customer completes an order your KASSA.AT account will register that and will adapt to the new stock amounts.
     
    2627This plugin only works with a KASSA.AT account and requires WooCommerce.
    2728The serialnumber in WC-products must equal articlenumber in KASSA.AT-articles
     29You can find a detailed handbook for this plugin on [our website](https://kassa.at/plugin-fuer-woocommerce/).
    2830
    2931= Supported languages =
    3032* German (de_AT, de_DE, de_DE_formal, de_CH, de_CH_formal)
    3133* English (Default language)
    32 * Turkish (automatic translation)
    33 * Hungarian (automatic translation)
    34 * Slovenian (automatic translation)
    35 * Croatian (automatic translation)
    36 * Polish (automatic translation)
     34* Turkish (automatic translation) (< 100%)
     35* Hungarian (automatic translation) (< 100%)
     36* Slovenian (automatic translation) (< 100%)
     37* Croatian (automatic translation) (< 100%)
     38* Polish (automatic translation) (< 100%)
    3739
    3840== Installation ==
     
    40421. Upload and extract the "kassa-at-for-woocommerce" archive to the "/wp-content/plugins/" directory (inside a folder named after the archive).
    41432. Activate the plugin through the "Plugins" menu in WordPress.
     44
     45= Automatic installation =
     461. Find the Plugin in the "Plugins" > "Add new" section of your wordpress site.
     472. Click on "Install now".
     483. Wait until the plugin is installed.
     494. Activate the plugin.
    4250
    4351== Set up ==
     
    5866No. The plugin is based on a woocommerce-shop.
    5967
    60 = What should I do when I'm selling from germany? =
     68= I don't need the synchronization every time, and it slows down my server, how can I limit the synchronization attempts? =
    6169
    62 The plugin "KASSA.AT for WooCommerce" is only for austrian shops (for the austrian financialdepartment).
    63 If you are located in germany try out our similar product for german customers: "KASSE.PRO for WooCommerce"
     70There are options for disabling the synchronization at different pages. Read more about that in the handbook.
    6471
    6572== Changelog ==
     73
     74= 1.1.0 (2022-01-26) =
     75* Added Functions to disable synchronization on single product page and cart individually.
     76* Added Logging for debugging and error-management purposes.
     77Added functions to customize the logs (Log disabling; Log deleting; Log downloading; Log length defining)
     78* Displaying importent database entries beneath the logs.
    6679
    6780= 1.0.2 (2021-10-08) =
     
    8093== Upgrade Notice ==
    8194
     95= 1.1.0 =
     96* You can disable specific synchronizations now.
     97* There are error logs helping in finding the error if one occurs.
     98
    8299= 1.0.2 =
    83100* Site doesn't require reload to synchronize stocks.
  • kassa-at-for-woocommerce/trunk/stock-syncro.php

    r2611428 r2665761  
    1111    exit; // Exit if accessed directly!
    1212}
     13
     14/**
     15 * Activates or deactivates different parts of the Code so the user
     16 * can decide when he want the stocks to synchronize.
     17 *
     18 * There are three times that he can enable or disable individually (
     19 * - 'kaw-synchronize-at-singleproduct',
     20 * - 'kaw-synchronize-at-cart',
     21 * - 'kaw-synchronize-on-order'.
     22 *
     23 * The function writes eighter 'enabled' or 'disabled' in the correct wp_option
     24 * and forces a logentry about the change.
     25 */
     26function kaw_activate_synchro_option() {
     27    if ( ! isset( $_POST['mode'] ) || ! isset( $_POST['field'] ) ) { /* phpcs:ignore */
     28        wp_send_json_error();
     29    }
     30
     31    if ( $_POST['mode'] == 'true' ) { /* phpcs:ignore */
     32        $val = 'enabled';
     33    } else {
     34        $val = 'disabled';
     35    }
     36
     37    $field = $_POST['field']; /* phpcs:ignore */
     38
     39    if ( get_option( $field ) ) {
     40        update_option( $field, $val );
     41    } else {
     42        add_option( $field, $val );
     43    }
     44
     45    kaw_log_data(
     46        'SYSTEM',
     47        array(
     48            'message'  => $val . ' the synchronization: ' . $field,
     49            'location' => kaw_get_locationstring(),
     50        ),
     51        true
     52    );
     53
     54    wp_send_json_success();
     55}
     56add_action( 'wp_ajax_kaw_activate_synchro_option', 'kaw_activate_synchro_option' );
    1357
    1458/**
     
    3074    );
    3175    if ( 1 !== $inventory->length ) {
    32         kaw_log_data( 'STOCK-UPDATE-ERROR: Wrong number of found entries {' . strval( $inventory->length ) . '}' );
     76        kaw_log_data(
     77            'API-ERROR',
     78            array(
     79                'message'  => 'Wrong number of found entries {' . strval( $inventory->length ) . '}',
     80                'location' => kaw_get_locationstring(),
     81            )
     82        );
    3383        return false;
    3484    } else {
     
    4898
    4999    if ( ! $order || get_option( 'woocommerce_manage_stock' ) !== 'yes' ) {
     100        return;
     101    }
     102
     103    if ( get_option( 'kaw-synchronize-on-order' ) === 'disabled' ) {
    50104        return;
    51105    }
     
    89143            'POST',
    90144            $inventories_path . '/' . $inventory_id . '/movements',
    91             wp_json_encode(
    92                 array(
    93                     'quantity' => $qty,
    94                     /* translators: The placeholder %s is to send the order-id! */
    95                     'text'     => sprintf( esc_attr( __( 'Woocommerce Invoice: %s', 'kassa-at-for-woocommerce' ) ), esc_attr( $order->id ) ),
    96                     'type'     => 'decrease',
    97                 )
     145            array(
     146                'quantity' => $qty,
     147                /* translators: The placeholder %s is to send the order-id! */
     148                'text'     => sprintf( esc_attr( __( 'Woocommerce Invoice: %s', 'kassa-at-for-woocommerce' ) ), esc_attr( $order->id ) ),
     149                'type'     => 'decrease',
    98150            )
    99151        );
     
    107159 */
    108160function kaw_synchronize_k_to_w() {
    109     kaw_log_data( 'MANUAL-STOCK-UPDATE' );
    110161    $args = array(
    111162        'post_type'  => array( 'product', 'product_variation' ),
    112         'meta_query' => array(
     163        'meta_query' => array( /* phpcs:ignore */
    113164            array(
    114165                'key'     => '_manage_stock',
     
    125176        global $product;
    126177        $stock_amount = kaw_get_stock_amount( $product );
    127         echo '-';
    128         echo $stock_amount;
    129         echo '-';
    130178        $old_stock    = get_post_meta( $product->get_id(), '_stock' );
    131         echo implode( ", ", $old_stock );
    132         // echo $old_stock;
    133179
    134180        if ( $stock_amount ) {
    135181            update_post_meta( $product->get_id(), '_stock', $stock_amount );
    136             kaw_log_data( 'STOCK-UPDATED: article{' . $product->get_name() . ' (' . $product->get_sku() . ')}, stock_change{' . strval( $old_stock[0] ) . ' -> ' . strval( $stock_amount ) . '}' );
     182            kaw_log_data(
     183                'DATA-UPDATE',
     184                array(
     185                    'message'  => 'Stock amount updated ',
     186                    'key'      => $product->get_name() . ' (' . $product->get_sku() . ')',
     187                    'original' => strval( $old_stock[0] ),
     188                    'updated'  => strval( $stock_amount ),
     189                    'location' => kaw_get_locationstring(),
     190                )
     191            );
    137192            kaw_update_stock_status( $product, $old_stock[0], $stock_amount );
    138193        }
     
    150205    global $product;
    151206
    152     if ( ! isset( $_GET['sync'] ) ) {
    153         $actual_link = ( true === isset( $_SERVER['HTTP_HOST'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '' )
    154                                     . ( true === isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' );
    155         if ( strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '?' ) !== false ) {
    156             $actual_link .= '&sync=true';
    157         } else {
    158             $actual_link .= '?sync=true';
    159         }
    160 
    161         $stock_amount = kaw_get_stock_amount( $product );
    162         $old_stock    = get_post_meta( $product->get_id(), '_stock' );
    163 
    164         if ( $stock_amount ) {
    165             $product->set_stock( $stock_amount );
    166             kaw_log_data( 'STOCK-UPDATED: article{' . $product->get_name() . ' (' . $product->get_sku() . ')}, stock_change{' . strval( $old_stock[0] ) . ' -> ' . strval( $stock_amount ) . '}' );
    167             kaw_update_stock_status( $product, $old_stock[0], $stock_amount );
    168         }
    169 
    170         $variations = $product->get_children();
    171         foreach ( $variations as $value ) {
    172             $variation = new WC_Product_Variation( $value );
    173             if ( get_post_meta( $variation->get_id(), '_manage_stock' ) ) {
    174                 $stock_amount = kaw_get_stock_amount( $variation );
    175                 $old_stock    = get_post_meta( $variation->get_id(), '_stock' );
    176 
    177                 if ( $stock_amount ) {
    178                     $variation->set_stock( $stock_amount );
    179                     update_post_meta( $variation->get_id(), '_stock', $stock_amount );
    180                     kaw_log_data( 'STOCK-UPDATED: article{' . $variation->get_name() . ' (' . $variation->get_sku() . ')}, stock_change{' . strval( $old_stock[0] ) . ' -> ' . strval( $stock_amount ) . '}' );
    181                     kaw_update_stock_status( $variation, $old_stock[0], $stock_amount );
    182                 }
     207    if ( get_option( 'kaw-synchronize-at-singleproduct' ) === 'disabled' ) {
     208        return;
     209    }
     210
     211    $stock_amount = kaw_get_stock_amount( $product );
     212    $old_stock    = get_post_meta( $product->get_id(), '_stock' );
     213
     214    if ( $stock_amount ) {
     215        $product->set_stock( $stock_amount );
     216        kaw_log_data(
     217            'DATA-UPDATE',
     218            array(
     219                'message'  => 'Stock amount updated ',
     220                'key'      => $product->get_name() . ' (' . $product->get_sku() . ')',
     221                'original' => strval( $old_stock[0] ),
     222                'updated'  => strval( $stock_amount ),
     223                'location' => kaw_get_locationstring(),
     224            )
     225        );
     226        kaw_update_stock_status( $product, $old_stock[0], $stock_amount );
     227    }
     228
     229    $variations = $product->get_children();
     230    foreach ( $variations as $value ) {
     231        $variation = new WC_Product_Variation( $value );
     232        if ( get_post_meta( $variation->get_id(), '_manage_stock' ) ) {
     233            $stock_amount = kaw_get_stock_amount( $variation );
     234            $old_stock    = get_post_meta( $variation->get_id(), '_stock' );
     235
     236            if ( $stock_amount ) {
     237                $variation->set_stock( $stock_amount );
     238                update_post_meta( $variation->get_id(), '_stock', $stock_amount );
     239                kaw_log_data(
     240                    'DATA-UPDATE',
     241                    array(
     242                        'message'  => 'Stock amount updated ',
     243                        'key'      => $variation->get_name() . ' (' . $variation->get_sku() . ')',
     244                        'original' => strval( $old_stock[0] ),
     245                        'updated'  => strval( $stock_amount ),
     246                        'location' => kaw_get_locationstring(),
     247                    )
     248                );
     249                kaw_update_stock_status( $variation, $old_stock[0], $stock_amount );
    183250            }
    184251        }
     
    198265
    199266    if ( get_option( 'woocommerce_manage_stock' ) !== 'yes' ) {
     267        return;
     268    }
     269
     270    if ( get_option( 'kaw-synchronize-at-cart' ) === 'disabled' ) {
    200271        return;
    201272    }
     
    215286        if ( $stock_amount ) {
    216287            $product->set_stock( $stock_amount );
    217             kaw_log_data( 'STOCK-UPDATED: article{' . $product->get_name() . ' (' . $product->get_sku() . ')}, stock_change{' . strval( $old_stock[0] ) . ' -> ' . strval( $stock_amount ) . '}' );
     288            kaw_log_data(
     289                'DATA-UPDATE',
     290                array(
     291                    'message'  => 'Stock amount updated ',
     292                    'key'      => $product->get_name() . ' (' . $product->get_sku() . ')',
     293                    'original' => strval( $old_stock[0] ),
     294                    'updated'  => strval( $stock_amount ),
     295                    'location' => kaw_get_locationstring(),
     296                )
     297            );
    218298            kaw_update_stock_status( $product, $old_stock[0], $stock_amount );
    219299        }
     
    251331    if ( isset( $status ) ) {
    252332        $old_status = $product->get_stock_status();
    253         // update_post_meta( $product->get_id(), '_stock_status', $status );
    254333        $product->set_stock_status( $status );
    255         kaw_log_data( 'STOCK-STATUS-UPDATED: article{' . $product->get_name() . ' (' . $product->get_sku() . ')}, status{' . $old_status . ' -> ' . $status . '}' );
    256     }
    257 }
     334        kaw_log_data(
     335            'DATA-UPDATE',
     336            array(
     337                'message'  => 'Stock status updated',
     338                'key'      => $product->get_name() . ' (' . $product->get_sku() . ')',
     339                'original' => $old_status,
     340                'updated'  => $status,
     341                'location' => kaw_get_locationstring(),
     342            )
     343        );
     344    }
     345}
Note: See TracChangeset for help on using the changeset viewer.