Plugin Directory

Changeset 2019487


Ignore:
Timestamp:
01/26/2019 09:25:52 AM (7 years ago)
Author:
marguspala
Message:

Handle too long addresses

Location:
smartaccounts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • smartaccounts/trunk/SmartAccountsClass.php

    r2001667 r2019487  
    3131            update_post_meta($order_id, 'smartaccounts_invoice_id', $invoice['invoice']['invoiceNumber']);
    3232            error_log("SmartAccounts sales invoice created for order $order_id - " . $invoice['invoice']['invoiceNumber']);
     33            $invoiceIdsString = get_option('sa_failed_orders');
     34            $invoiceIds       = json_decode($invoiceIdsString);
     35            if (is_array($invoiceIds) && array_key_exists($order_id, $invoiceIds)) {
     36                unset($invoiceIds[$order_id]);
     37                update_option('sa_failed_orders', json_encode($invoiceIds));
     38                error_log("Removed $order_id from failed orders array");
     39            }
    3340        } catch (Exception $exception) {
    3441            error_log("SmartAccounts error: " . $exception->getMessage() . " " . $exception->getTraceAsString());
     
    3845            if (is_array($invoiceIds)) {
    3946                error_log("Adding $order_id to failed orders array $invoiceIdsString to be retried later");
    40                 $invoiceIds[] = $order_id;
     47                $invoiceIds[$order_id] = $order_id;
    4148                update_option('sa_failed_orders', json_encode($invoiceIds));
    4249            } else {
    4350                error_log("Adding $order_id to new failed orders array. previously $invoiceIdsString");
    44                 $invoiceIds = [$order_id];
     51                $invoiceIds = [$order_id => $order_id];
    4552                update_option('sa_failed_orders', json_encode($invoiceIds));
    4653            }
  • smartaccounts/trunk/SmartAccountsClient.php

    r2001667 r2019487  
    116116        $postalCode = $this->order->get_billing_postcode() ? $this->order->get_billing_postcode() :
    117117            ($this->order->get_shipping_postcode() ? $this->order->get_shipping_postcode() : "");
    118         $address1   = $this->order->get_billing_address_1() ? $this->order->get_billing_address_1() :
    119             ($this->order->get_shipping_address_1() ? $this->order->get_shipping_address_1() : "");
    120         $address2   = $this->order->get_billing_address_2() ? $this->order->get_billing_address_2() :
    121             ($this->order->get_shipping_address_2() ? $this->order->get_shipping_address_2() : "");
     118        $address1   = substr($this->order->get_billing_address_1() ? $this->order->get_billing_address_1() :
     119            ($this->order->get_shipping_address_1() ? $this->order->get_shipping_address_1() : ""), 0, 64);
     120        $address2   = substr($this->order->get_billing_address_2() ? $this->order->get_billing_address_2() :
     121            ($this->order->get_shipping_address_2() ? $this->order->get_shipping_address_2() : ""), 0, 64);
    122122
    123123        $body          = new stdClass();
  • smartaccounts/trunk/readme.txt

    r2001667 r2019487  
    4747== Changelog ==
    4848
     49= 2.2.1 =
     50If address is longer than 64 characters then it is truncated when sending to SmartAccounts as longer addresses are not supported
     51
    4952= 2.2 =
    5053Import products from SmartAccounts available
  • smartaccounts/trunk/smartaccounts.php

    r2002900 r2019487  
    1010 * License URI:  https://www.gnu.org/licenses/gpl-2.0.html
    1111 * Requires at least: 4.8.0
    12  * Tested up to: 5.0.2
     12 * Tested up to: 5.0.3
    1313 */
    14 
    1514
    1615if ( ! defined('ABSPATH')) {
Note: See TracChangeset for help on using the changeset viewer.