Skip to content

Commit

Permalink
Merge pull request #38 from dingo-d/develop
Browse files Browse the repository at this point in the history
2.0.4 update
  • Loading branch information
dingo-d authored Nov 28, 2020
2 parents 785e96a + 2e4f896 commit 5049a7b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 30 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,28 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

_No documentation available about unreleased changes as of yet._

## [2.0.4] - 2020-11-28

### Added

* Clear error log message if order is manually triggered and succeeds.

### Changed

* Priority changed on the on completed WooCommerce hook.

### Fixed

* Remove shipping from all the variables, fix shipping tax calculation
*The shipping does not concern us really, so no need to pull any fields from there.
* Shipping was a bit changed, so it didn't pick anything up and reported 0 tax on taxable shipping.
* Fix the defaults in the settings (languages, checkout settings) in PHP.

## [2.0.3] - 2020-11-25

### Fixed

* * Add a default fallback on save in case a settings is undefined or null in settings
* Add a default fallback on save in case a settings is undefined or null in settings

## [2.0.2] - 2020-11-24

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
**Requires at least**: 5.1
**Requires PHP**: 7.3
**Tested up to**: 5.5
**Stable tag**: 2.0.3
**Stable tag**: 2.0.4
**WC requires at least**: 4.0.0
**WC tested up to**: 4.7.0
**License**: MIT
Expand Down
20 changes: 19 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: woocommerce, api, solo api, solo, api integration, shop, payment, woo
Requires at least: 5.2
Requires PHP: 7.3
Tested up to: 5.5
Stable tag: 2.0.3
Stable tag: 2.0.4
WC requires at least: 4.0.0
WC tested up to: 4.7.0
License: MIT
Expand Down Expand Up @@ -66,6 +66,24 @@ Be sure you have WooCommerce plugin installed first, otherwise you'll get an err

== Changelog ==

= 2.0.4 =
Release Date: November 28th, 2020

Added:

* Clear error log message if order is manually triggered and succeeds.

Changed:

* Priority changed on the on completed WooCommerce hook.

Fixed:

* Remove shipping from all the variables, fix shipping tax calculation
*The shipping does not concern us really, so no need to pull any fields from there.
* Shipping was a bit changed, so it didn't pick anything up and reported 0 tax on taxable shipping.
* Fix the defaults in the settings (languages, checkout settings) in PHP.

= 2.0.3 =
Release Date: November 25th, 2020

Expand Down
2 changes: 1 addition & 1 deletion src/ECommerce/WooCommerce/MakeApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct(SoloOrdersTable $ordersTable, ApiRequest $soloReques
public function register(): void
{
add_action('woocommerce_email_order_details', [$this, 'sendApiRequestOnCheckout'], 15, 4);
add_action('woocommerce_order_status_completed', [$this, 'sendApiRequestOnOrderCompleted'], 10, 1);
add_action('woocommerce_order_status_completed', [$this, 'sendApiRequestOnOrderCompleted'], 30, 1);
}

/**
Expand Down
36 changes: 14 additions & 22 deletions src/Request/SoloApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,10 @@ public function executeApiCall($order): void

$orderData = $order->get_data(); // The Order data.

// Check if billing or shipping.
$field = 'shipping';

if (!empty($orderData['billing']['first_name'])) {
$field = 'billing';
}

// The bill data (invoice or offer) must be from billing fields!
$firstName = $orderData['billing']['first_name'] ?? '';
$lastName = $orderData['billing']['last_name'] ?? '';
$companyName = $orderData['billing']['billing_company'] ?? ''; // Used for R1.
$companyName = $orderData['billing']['company'] ?? ''; // Used for R1.
$address1 = $orderData['billing']['address_1'] ?? '';
$address2 = $orderData['billing']['address_2'] ?? '';
$city = $orderData['billing']['city'] ?? '';
Expand All @@ -123,29 +116,19 @@ public function executeApiCall($order): void
foreach ($metaData as $data => $metaValue) {
$data = $metaValue->get_data();

if ($data['key'] === '_shipping_pin_number') {
if ($data['key'] === '_billing_pin_number') {
$pinNumber = $data['value'] ?? '';
}

if ($data['key'] === '_shipping_iban_number') {
if ($data['key'] === '_billing_iban_number') {
$ibanNumber = $data['value'] ?? '';
}

if ($field === 'billing') {
if ($data['key'] === '_billing_pin_number') {
$pinNumber = $data['value'] ?? '';
}

if ($data['key'] === '_billing_iban_number') {
$ibanNumber = $data['value'] ?? '';
}
}
}

$orderBuyer = "$firstName $lastName";

// If the invoice is R1 the company name is required and used instead of first name and last name.
if (get_option('solo_api_invoice_type') !== '2') {
if (get_option('solo_api_invoice_type') === '2') {
$orderBuyer = $companyName;
}

Expand Down Expand Up @@ -263,9 +246,10 @@ public function executeApiCall($order): void
$shippingItems = $order->get_items('shipping');

foreach ($shippingItems as $shippingObject) {
$shippingTaxRates = array_values(WC_Tax::get_base_tax_rates($shippingObject->get_tax_class()));
$shippingTaxRates = array_values(WC_Tax::get_base_tax_rates());
}

// We're fetching the first value always.
$shippingTaxRate = !empty($shippingTaxRates) ? (float)$shippingTaxRates[0]['rate'] : 0;

$shippingPrice = number_format($totalShipping, 2, ',', '.');
Expand Down Expand Up @@ -429,6 +413,14 @@ public function executeApiCall($order): void
*/
SoloOrdersTable::updateOrdersTable($orderId, $soloOrderId, true, false, true);

/**
* Clear the previous errors
*
* If curl error happened, for whatever reason, and you try to resend the order manually
* the error should be removed if the API call was successful.
*/
SoloOrdersTable::addApiResponseError($orderId, '');

// Send mail to the customer with the PDF of the invoice.
$sendPdf = get_option('solo_api_send_pdf');

Expand Down
6 changes: 3 additions & 3 deletions src/Settings/PluginSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function registerPluginSettings(): void
esc_html__('Language of the bill or the invoice', 'woo-solo-api'),
'sanitize_text_field',
true,
''
'1'
)
);

Expand Down Expand Up @@ -207,7 +207,7 @@ public function registerPluginSettings(): void
esc_html__('Specify the due date on the bill or the invoice', 'woo-solo-api'),
'sanitize_text_field',
true,
''
'1'
)
);

Expand Down Expand Up @@ -243,7 +243,7 @@ public function registerPluginSettings(): void
esc_html__('When to send the PDF - on checkout or order confirmation', 'woo-solo-api'),
'sanitize_text_field',
true,
''
'checkout'
)
);

Expand Down
2 changes: 1 addition & 1 deletion woo-solo-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Woo Solo Api
* Plugin URI: https://madebydenis.com/woo-solo-api
* Description: This plugin provides integration of the SOLO API service with WooCommerce.
* Version: 2.0.3
* Version: 2.0.4
* Author: Denis Žoljom
* Author URI: https://madebydenis.com
* License: MIT
Expand Down

0 comments on commit 5049a7b

Please sign in to comment.