Skip to content

Commit 5049a7b

Browse files
authored
Merge pull request #38 from dingo-d/develop
2.0.4 update
2 parents 785e96a + 2e4f896 commit 5049a7b

File tree

7 files changed

+57
-30
lines changed

7 files changed

+57
-30
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,28 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
1313

1414
_No documentation available about unreleased changes as of yet._
1515

16+
## [2.0.4] - 2020-11-28
17+
18+
### Added
19+
20+
* Clear error log message if order is manually triggered and succeeds.
21+
22+
### Changed
23+
24+
* Priority changed on the on completed WooCommerce hook.
25+
26+
### Fixed
27+
28+
* Remove shipping from all the variables, fix shipping tax calculation
29+
*The shipping does not concern us really, so no need to pull any fields from there.
30+
* Shipping was a bit changed, so it didn't pick anything up and reported 0 tax on taxable shipping.
31+
* Fix the defaults in the settings (languages, checkout settings) in PHP.
32+
1633
## [2.0.3] - 2020-11-25
1734

1835
### Fixed
1936

20-
* * Add a default fallback on save in case a settings is undefined or null in settings
37+
* Add a default fallback on save in case a settings is undefined or null in settings
2138

2239
## [2.0.2] - 2020-11-24
2340

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
**Requires at least**: 5.1
1717
**Requires PHP**: 7.3
1818
**Tested up to**: 5.5
19-
**Stable tag**: 2.0.3
19+
**Stable tag**: 2.0.4
2020
**WC requires at least**: 4.0.0
2121
**WC tested up to**: 4.7.0
2222
**License**: MIT

README.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: woocommerce, api, solo api, solo, api integration, shop, payment, woo
44
Requires at least: 5.2
55
Requires PHP: 7.3
66
Tested up to: 5.5
7-
Stable tag: 2.0.3
7+
Stable tag: 2.0.4
88
WC requires at least: 4.0.0
99
WC tested up to: 4.7.0
1010
License: MIT
@@ -66,6 +66,24 @@ Be sure you have WooCommerce plugin installed first, otherwise you'll get an err
6666

6767
== Changelog ==
6868

69+
= 2.0.4 =
70+
Release Date: November 28th, 2020
71+
72+
Added:
73+
74+
* Clear error log message if order is manually triggered and succeeds.
75+
76+
Changed:
77+
78+
* Priority changed on the on completed WooCommerce hook.
79+
80+
Fixed:
81+
82+
* Remove shipping from all the variables, fix shipping tax calculation
83+
*The shipping does not concern us really, so no need to pull any fields from there.
84+
* Shipping was a bit changed, so it didn't pick anything up and reported 0 tax on taxable shipping.
85+
* Fix the defaults in the settings (languages, checkout settings) in PHP.
86+
6987
= 2.0.3 =
7088
Release Date: November 25th, 2020
7189

src/ECommerce/WooCommerce/MakeApiRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(SoloOrdersTable $ordersTable, ApiRequest $soloReques
6464
public function register(): void
6565
{
6666
add_action('woocommerce_email_order_details', [$this, 'sendApiRequestOnCheckout'], 15, 4);
67-
add_action('woocommerce_order_status_completed', [$this, 'sendApiRequestOnOrderCompleted'], 10, 1);
67+
add_action('woocommerce_order_status_completed', [$this, 'sendApiRequestOnOrderCompleted'], 30, 1);
6868
}
6969

7070
/**

src/Request/SoloApiRequest.php

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,10 @@ public function executeApiCall($order): void
9999

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

102-
// Check if billing or shipping.
103-
$field = 'shipping';
104-
105-
if (!empty($orderData['billing']['first_name'])) {
106-
$field = 'billing';
107-
}
108-
109102
// The bill data (invoice or offer) must be from billing fields!
110103
$firstName = $orderData['billing']['first_name'] ?? '';
111104
$lastName = $orderData['billing']['last_name'] ?? '';
112-
$companyName = $orderData['billing']['billing_company'] ?? ''; // Used for R1.
105+
$companyName = $orderData['billing']['company'] ?? ''; // Used for R1.
113106
$address1 = $orderData['billing']['address_1'] ?? '';
114107
$address2 = $orderData['billing']['address_2'] ?? '';
115108
$city = $orderData['billing']['city'] ?? '';
@@ -123,29 +116,19 @@ public function executeApiCall($order): void
123116
foreach ($metaData as $data => $metaValue) {
124117
$data = $metaValue->get_data();
125118

126-
if ($data['key'] === '_shipping_pin_number') {
119+
if ($data['key'] === '_billing_pin_number') {
127120
$pinNumber = $data['value'] ?? '';
128121
}
129122

130-
if ($data['key'] === '_shipping_iban_number') {
123+
if ($data['key'] === '_billing_iban_number') {
131124
$ibanNumber = $data['value'] ?? '';
132125
}
133-
134-
if ($field === 'billing') {
135-
if ($data['key'] === '_billing_pin_number') {
136-
$pinNumber = $data['value'] ?? '';
137-
}
138-
139-
if ($data['key'] === '_billing_iban_number') {
140-
$ibanNumber = $data['value'] ?? '';
141-
}
142-
}
143126
}
144127

145128
$orderBuyer = "$firstName $lastName";
146129

147130
// If the invoice is R1 the company name is required and used instead of first name and last name.
148-
if (get_option('solo_api_invoice_type') !== '2') {
131+
if (get_option('solo_api_invoice_type') === '2') {
149132
$orderBuyer = $companyName;
150133
}
151134

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

265248
foreach ($shippingItems as $shippingObject) {
266-
$shippingTaxRates = array_values(WC_Tax::get_base_tax_rates($shippingObject->get_tax_class()));
249+
$shippingTaxRates = array_values(WC_Tax::get_base_tax_rates());
267250
}
268251

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

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

416+
/**
417+
* Clear the previous errors
418+
*
419+
* If curl error happened, for whatever reason, and you try to resend the order manually
420+
* the error should be removed if the API call was successful.
421+
*/
422+
SoloOrdersTable::addApiResponseError($orderId, '');
423+
432424
// Send mail to the customer with the PDF of the invoice.
433425
$sendPdf = get_option('solo_api_send_pdf');
434426

src/Settings/PluginSettings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function registerPluginSettings(): void
8787
esc_html__('Language of the bill or the invoice', 'woo-solo-api'),
8888
'sanitize_text_field',
8989
true,
90-
''
90+
'1'
9191
)
9292
);
9393

@@ -207,7 +207,7 @@ public function registerPluginSettings(): void
207207
esc_html__('Specify the due date on the bill or the invoice', 'woo-solo-api'),
208208
'sanitize_text_field',
209209
true,
210-
''
210+
'1'
211211
)
212212
);
213213

@@ -243,7 +243,7 @@ public function registerPluginSettings(): void
243243
esc_html__('When to send the PDF - on checkout or order confirmation', 'woo-solo-api'),
244244
'sanitize_text_field',
245245
true,
246-
''
246+
'checkout'
247247
)
248248
);
249249

woo-solo-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: Woo Solo Api
1111
* Plugin URI: https://madebydenis.com/woo-solo-api
1212
* Description: This plugin provides integration of the SOLO API service with WooCommerce.
13-
* Version: 2.0.3
13+
* Version: 2.0.4
1414
* Author: Denis Žoljom
1515
* Author URI: https://madebydenis.com
1616
* License: MIT

0 commit comments

Comments
 (0)