Plugin Directory

Changeset 3448855


Ignore:
Timestamp:
01/28/2026 04:21:28 PM (2 months ago)
Author:
wntcloud
Message:

Bugs fix

Location:
wintouch-cloud
Files:
7 edited
12 copied

Legend:

Unmodified
Added
Removed
  • wintouch-cloud/tags/0.0.5/README.md

    r3447688 r3448855  
    88**Requires at least:** 5.0 
    99**Tested up to:** 6.9 
    10 **Stable tag:** 0.0.4 
     10**Stable tag:** 0.0.5 
    1111**Requires PHP:** 7.2 
    1212**License:** GPLv2 or later 
  • wintouch-cloud/tags/0.0.5/readme.txt

    r3447688 r3448855  
    44Requires at least: 5.0
    55Tested up to: 6.9
    6 Stable tag: 0.0.4
     6Stable tag: 0.0.5
    77Requires PHP: 7.2
    88License: GPLv2 or later
  • wintouch-cloud/tags/0.0.5/src/Authentication.php

    r3447688 r3448855  
    1919            try {
    2020                $response = (new Api())->Login($email, $password);
     21
     22                $userid = $response['value']['userId'];
     23                $token = $response['value']['token'];
     24
     25                update_option('wintouch_userid', $userid, false);
     26                update_option('wintouch_usertoken', $token, false);
    2127            } catch (ApiException $ex) {
    22                 echo esc_html($ex->getMessage());
    23                 return false;
     28                add_settings_error('wintouch', 'wt', $ex->getMessage(), 'error');
    2429            }
    25 
    26             $userid = $response['value']['userId'];
    27             $token = $response['value']['token'];
    28 
    29             update_option('wintouch_userid', $userid, false);
    30             update_option('wintouch_usertoken', $token, false);
    3130        }
    3231
  • wintouch-cloud/tags/0.0.5/src/Order.php

    r3447688 r3448855  
    2525            'OrderId' => $order->get_id(),
    2626            'OrderNumber' => $order->get_order_number(),
    27             'IsStockSyncActive' => $stocksync
     27            'IsStockSyncActive' => $stocksync,
    2828        ];
    2929
     
    6565                    'Title' => $product->get_name(),
    6666                    'SKU' => $product->get_sku(),
    67                     'Price' => $item->get_subtotal() + $item->get_subtotal_tax() / $item->get_quantity(),
     67                    'Price' => ($item->get_subtotal() + $item->get_subtotal_tax()) / $item->get_quantity(),
    6868                    'Quantity' => $item->get_quantity(),
    6969                    'TaxRate' => round(($item->get_subtotal_tax() / $item->get_subtotal()) * 100)
  • wintouch-cloud/tags/0.0.5/src/Stock.php

    r3443376 r3448855  
    3232            }
    3333
    34             $data['CodePrefix'] = get_option('wintouch_setting_codeprefix');
    35             $data['CodeDigits'] = intval(get_option('wintouch_setting_codedigits'));
     34            $prices_with_tax = wc_prices_include_tax();
    3635
    3736            $data['Products'] = [];
    3837            foreach ($products as $product) {
    39                 if ($product->get_manage_stock()) {
    40                     $tax_class = $product->get_tax_class();
    41                     if (empty($tax_class)) {
    42                         $tax_class = '';
    43                     }
     38                if ($product->is_type('variable')) {
     39                    $variations_id = $product->get_children();
    4440
    45                     $tax_rates = \WC_Tax::get_rates($tax_class);
    46                     $tax_rate_value = 0;
     41                    foreach ($variations_id as $variation_id) {
     42                        $variation = wc_get_product($variation_id);
    4743
    48                     if (is_array($tax_rates) && !empty($tax_rates)) {
    49                         $first_rate = reset($tax_rates);
    50                         if (isset($first_rate['rate'])) {
    51                             $tax_rate_value = floatval($first_rate['rate']);
    52                         } else {
    53                             $tax_rate_value = floatval(23);
     44                        if ($variation->get_manage_stock()) {
     45                            $tax_rates = \WC_Tax::get_base_tax_rates($variation->get_tax_class());
     46                            $first_rate = reset($tax_rates);
     47                            $tax_rate_value = isset($first_rate['rate']) ? floatval($first_rate['rate']) : floatval(23);
     48
     49                            if ($prices_with_tax) {
     50                                $price = $variation->get_price();
     51                                $taxes = \WC_Tax::calc_tax($price, $tax_rates, false);
     52                                $price_with_tax = $price + array_sum($taxes);
     53                            } else {
     54                                $price_with_tax = $variation->get_price();
     55                            }
     56
     57                            $data['Products'][] = [
     58                                'Id' => strval($variation->get_id()),
     59                                'Name' => $variation->get_name(),
     60                                'TaxRate' => $tax_rate_value,
     61                                'Price' => $price_with_tax,
     62                                'BuyPrice' => 0,
     63                                'Quantity' => $variation->get_stock_quantity()
     64                            ];
    5465                        }
    5566                    }
     67                } else {
     68                    if ($product->get_manage_stock()) {
     69                        $tax_rates = \WC_Tax::get_base_tax_rates($product->get_tax_class());
     70                        $first_rate = reset($tax_rates);
     71                        $tax_rate_value = isset($first_rate['rate']) ? floatval($first_rate['rate']) : floatval(23);
    5672
    57                     $data['Products'][] = [
    58                         'Id' => strval($product->get_id()),
    59                         'Name' => $product->get_name(),
    60                         'TaxRate' => $tax_rate_value,
    61                         'Price' => $product->get_price(),
    62                         'BuyPrice' => 0,
    63                         'Quantity' => $product->get_stock_quantity()
    64                     ];
     73                        if ($prices_with_tax) {
     74                            $price = $product->get_price();
     75                            $taxes = \WC_Tax::calc_tax($price, $tax_rates, false);
     76                            $price_with_tax = $price + array_sum($taxes);
     77                        } else {
     78                            $price_with_tax = $product->get_price();
     79                        }
     80
     81                        $data['Products'][] = [
     82                            'Id' => strval($product->get_id()),
     83                            'Name' => $product->get_name(),
     84                            'TaxRate' => $tax_rate_value,
     85                            'Price' => $price_with_tax,
     86                            'BuyPrice' => 0,
     87                            'Quantity' => $product->get_stock_quantity()
     88                        ];
     89                    }
    6590                }
    6691            }
  • wintouch-cloud/tags/0.0.5/wintouch-cloud.php

    r3447688 r3448855  
    33 * Plugin Name: WINTOUCH Cloud
    44 * Description: Uma ferramenta de faturação para o seu negócio.
    5  * Version: 0.0.4
     5 * Version: 0.0.5
    66 * Author: WINTOUCH
    77 * Author URI: https://wintouchcloud.com
  • wintouch-cloud/trunk/README.md

    r3447688 r3448855  
    88**Requires at least:** 5.0 
    99**Tested up to:** 6.9 
    10 **Stable tag:** 0.0.4 
     10**Stable tag:** 0.0.5 
    1111**Requires PHP:** 7.2 
    1212**License:** GPLv2 or later 
  • wintouch-cloud/trunk/readme.txt

    r3447688 r3448855  
    44Requires at least: 5.0
    55Tested up to: 6.9
    6 Stable tag: 0.0.4
     6Stable tag: 0.0.5
    77Requires PHP: 7.2
    88License: GPLv2 or later
  • wintouch-cloud/trunk/src/Authentication.php

    r3447688 r3448855  
    1919            try {
    2020                $response = (new Api())->Login($email, $password);
     21
     22                $userid = $response['value']['userId'];
     23                $token = $response['value']['token'];
     24
     25                update_option('wintouch_userid', $userid, false);
     26                update_option('wintouch_usertoken', $token, false);
    2127            } catch (ApiException $ex) {
    22                 echo esc_html($ex->getMessage());
    23                 return false;
     28                add_settings_error('wintouch', 'wt', $ex->getMessage(), 'error');
    2429            }
    25 
    26             $userid = $response['value']['userId'];
    27             $token = $response['value']['token'];
    28 
    29             update_option('wintouch_userid', $userid, false);
    30             update_option('wintouch_usertoken', $token, false);
    3130        }
    3231
  • wintouch-cloud/trunk/src/Order.php

    r3447688 r3448855  
    2525            'OrderId' => $order->get_id(),
    2626            'OrderNumber' => $order->get_order_number(),
    27             'IsStockSyncActive' => $stocksync
     27            'IsStockSyncActive' => $stocksync,
    2828        ];
    2929
     
    6565                    'Title' => $product->get_name(),
    6666                    'SKU' => $product->get_sku(),
    67                     'Price' => $item->get_subtotal() + $item->get_subtotal_tax() / $item->get_quantity(),
     67                    'Price' => ($item->get_subtotal() + $item->get_subtotal_tax()) / $item->get_quantity(),
    6868                    'Quantity' => $item->get_quantity(),
    6969                    'TaxRate' => round(($item->get_subtotal_tax() / $item->get_subtotal()) * 100)
  • wintouch-cloud/trunk/src/Stock.php

    r3443376 r3448855  
    3232            }
    3333
    34             $data['CodePrefix'] = get_option('wintouch_setting_codeprefix');
    35             $data['CodeDigits'] = intval(get_option('wintouch_setting_codedigits'));
     34            $prices_with_tax = wc_prices_include_tax();
    3635
    3736            $data['Products'] = [];
    3837            foreach ($products as $product) {
    39                 if ($product->get_manage_stock()) {
    40                     $tax_class = $product->get_tax_class();
    41                     if (empty($tax_class)) {
    42                         $tax_class = '';
    43                     }
     38                if ($product->is_type('variable')) {
     39                    $variations_id = $product->get_children();
    4440
    45                     $tax_rates = \WC_Tax::get_rates($tax_class);
    46                     $tax_rate_value = 0;
     41                    foreach ($variations_id as $variation_id) {
     42                        $variation = wc_get_product($variation_id);
    4743
    48                     if (is_array($tax_rates) && !empty($tax_rates)) {
    49                         $first_rate = reset($tax_rates);
    50                         if (isset($first_rate['rate'])) {
    51                             $tax_rate_value = floatval($first_rate['rate']);
    52                         } else {
    53                             $tax_rate_value = floatval(23);
     44                        if ($variation->get_manage_stock()) {
     45                            $tax_rates = \WC_Tax::get_base_tax_rates($variation->get_tax_class());
     46                            $first_rate = reset($tax_rates);
     47                            $tax_rate_value = isset($first_rate['rate']) ? floatval($first_rate['rate']) : floatval(23);
     48
     49                            if ($prices_with_tax) {
     50                                $price = $variation->get_price();
     51                                $taxes = \WC_Tax::calc_tax($price, $tax_rates, false);
     52                                $price_with_tax = $price + array_sum($taxes);
     53                            } else {
     54                                $price_with_tax = $variation->get_price();
     55                            }
     56
     57                            $data['Products'][] = [
     58                                'Id' => strval($variation->get_id()),
     59                                'Name' => $variation->get_name(),
     60                                'TaxRate' => $tax_rate_value,
     61                                'Price' => $price_with_tax,
     62                                'BuyPrice' => 0,
     63                                'Quantity' => $variation->get_stock_quantity()
     64                            ];
    5465                        }
    5566                    }
     67                } else {
     68                    if ($product->get_manage_stock()) {
     69                        $tax_rates = \WC_Tax::get_base_tax_rates($product->get_tax_class());
     70                        $first_rate = reset($tax_rates);
     71                        $tax_rate_value = isset($first_rate['rate']) ? floatval($first_rate['rate']) : floatval(23);
    5672
    57                     $data['Products'][] = [
    58                         'Id' => strval($product->get_id()),
    59                         'Name' => $product->get_name(),
    60                         'TaxRate' => $tax_rate_value,
    61                         'Price' => $product->get_price(),
    62                         'BuyPrice' => 0,
    63                         'Quantity' => $product->get_stock_quantity()
    64                     ];
     73                        if ($prices_with_tax) {
     74                            $price = $product->get_price();
     75                            $taxes = \WC_Tax::calc_tax($price, $tax_rates, false);
     76                            $price_with_tax = $price + array_sum($taxes);
     77                        } else {
     78                            $price_with_tax = $product->get_price();
     79                        }
     80
     81                        $data['Products'][] = [
     82                            'Id' => strval($product->get_id()),
     83                            'Name' => $product->get_name(),
     84                            'TaxRate' => $tax_rate_value,
     85                            'Price' => $price_with_tax,
     86                            'BuyPrice' => 0,
     87                            'Quantity' => $product->get_stock_quantity()
     88                        ];
     89                    }
    6590                }
    6691            }
  • wintouch-cloud/trunk/wintouch-cloud.php

    r3447688 r3448855  
    33 * Plugin Name: WINTOUCH Cloud
    44 * Description: Uma ferramenta de faturação para o seu negócio.
    5  * Version: 0.0.4
     5 * Version: 0.0.5
    66 * Author: WINTOUCH
    77 * Author URI: https://wintouchcloud.com
Note: See TracChangeset for help on using the changeset viewer.