Plugin Directory

Changeset 2561842


Ignore:
Timestamp:
07/10/2021 12:26:01 PM (5 years ago)
Author:
marguspala
Message:

Version 3.6

Location:
smartaccounts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • smartaccounts/trunk/SmartAccountsArticleAsync.php

    r2465911 r2561842  
    180180            // Sale price is set. Update only regular price and keep actual sale price what it is.
    181181            update_post_meta($post_id, '_regular_price', $data['price']);
     182        } elseif (!$salePrice && ($data['price'] != $finalPrice && $regularPrice === $finalPrice)) {
     183            // if no sale price and price in SmartAccounts has changed then change also in the WooCommerce
     184            update_post_meta($post_id, '_regular_price', $data['price']);
     185            update_post_meta($post_id, '_price', $data['price']);
    182186        }
    183187
  • smartaccounts/trunk/SmartAccountsClient.php

    r2328274 r2561842  
    8080        }
    8181
    82         $clients = $this->api->sendRequest(null, $apiUrl,
    83             "fetchAddresses=true&fetchContacts=true&nameOrRegCode=" . $client);
     82        $clients        = $this->api->sendRequest(null, $apiUrl, "fetchAddresses=true&fetchContacts=true&nameOrRegCode=" . $client);
     83        $hasMoreEntries = isset($clients['hasMoreEntries']) && $clients['hasMoreEntries'] ? "YES" : "NO";
     84        error_log("Found " . count($clients['clients']) . " SA clients. hasMoreEntries: $hasMoreEntries");
    8485
    8586        if ($this->isAnonymous) {
     
    101102        }
    102103
     104        error_log("Create anonymous customer for country $country to SmartAccounts");
    103105        return $this->addNewSaClient(null, $name, $country);
    104106    }
     
    189191    {
    190192        if (!is_array($clients) || count($clients) == 0) {
     193            error_log("No SA customers found, creating new with name $name");
    191194            return $this->addNewSaClient($email, $name, $country);
    192195        }
    193196
     197        $clientNames = [];
    194198        foreach ($clients as $client) {
    195             //match client if name matches and is company or email also matches
    196             if (($this->isCompany || $this->hasEmail($client,
    197                         $email)) && strtolower($this->name) == strtolower($client["name"])) {
     199            //match client if name matches and (is company or email also matches)
     200            if (($this->isCompany || $this->hasEmail($client, $email)) &&
     201                strtolower(trim($this->name)) === strtolower(trim($client["name"]))) {
    198202                return $client;
    199203            }
    200         }
    201 
     204            $clientNames[] = $client['name'];
     205        }
     206
     207        error_log("No good match found for $name, creating new company. Found names " . json_encode($clientNames));
    202208        return $this->addNewSaClient($email, $name, $country);
    203209    }
  • smartaccounts/trunk/readme.txt

    r2540725 r2561842  
    5959== Changelog ==
    6060
     61= 3.6 =
     62Price update improvements and more detailed logging for existing customer matching.
     63
    6164= 3.5 =
    6265Filter for editing SmartAccounts body data
  • smartaccounts/trunk/smartaccounts.php

    r2540725 r2561842  
    44 * Plugin URI: https://github.com/smartman/woocommerce_smartaccounts
    55 * Description: This plugin creates sales invoices in the smartaccounts.ee Online Accounting Software after Woocommerce order creation
    6  * Version: 3.5
     6 * Version: 3.6
    77 * Author: Margus Pala
    88 * Author URI: https://marguspala.com
Note: See TracChangeset for help on using the changeset viewer.