Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit 2b5a6a9

Browse files
Upload version 2.0.24
1 parent 368c38f commit 2b5a6a9

10 files changed

+43
-206
lines changed

Observer/AddSendCloudCheckoutServicePointVariable.php

-55
This file was deleted.

Observer/AddSendCloudExpectedDateVariable.php

-55
This file was deleted.

Observer/AddSendCloudVariable.php

+37-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ public function execute(Observer $observer)
2727
if ($transportObject === null) {
2828
return;
2929
}
30+
3031
$this->order = $transportObject->getOrder();
32+
if ($this->order === null) {
33+
return;
34+
}
3135

32-
if ($this->order !== null && $this->order->getSendcloudServicePointId()) {
36+
if ($this->order->getSendcloudServicePointId()) {
3337
$this->getServicePointVariables($transportObject);
38+
} else if ($this->order->getSendcloudCheckoutData()) {
39+
$this->getCheckoutData($transportObject);
3440
}
3541
}
3642

@@ -48,4 +54,34 @@ private function getServicePointVariables($transportObject)
4854
$transportObject['sc_servicepoint_city'] = $order->getSendcloudServicePointCity();
4955
$transportObject['sc_servicepoint_post_no'] = $order->getSendcloudServicePointPostnumber();
5056
}
57+
58+
private function getCheckoutData($transportObject)
59+
{
60+
/** @var OrderInterface $order */
61+
$order = $this->order;
62+
63+
$checkoutData = $this->serializer->unserialize($order->getSendcloudData());
64+
65+
if (empty($checkoutData)) {
66+
return;
67+
}
68+
69+
if ($checkoutData['delivery_method_type'] === 'nominated_day_delivery' ||
70+
$checkoutData['delivery_method_type'] === 'same_day_delivery'
71+
) {
72+
$transportObject['sc_carrier'] = $checkoutData['carrier'] ? $checkoutData['carrier']['name'] : null;
73+
$transportObject['sc_expected_delivery_date'] =
74+
$checkoutData['delivery_method_data'] ?
75+
$checkoutData['delivery_method_data']['formatted_delivery_date'] :
76+
null;
77+
} else if ($checkoutData['delivery_method_type'] === 'service_point_delivery') {
78+
$transportObject['sc_servicepoint_id'] = $checkoutData['delivery_method_data']['service_point']['id'];
79+
$transportObject['sc_servicepoint_name'] = $checkoutData['delivery_method_data']['service_point']['name'];
80+
$transportObject['sc_servicepoint_street'] = $checkoutData['delivery_method_data']['service_point']['street'];
81+
$transportObject['sc_servicepoint_house_no'] = $checkoutData['delivery_method_data']['service_point']['house_number'];
82+
$transportObject['sc_servicepoint_zipcode'] = $checkoutData['delivery_method_data']['service_point']['postal_code'];
83+
$transportObject['sc_servicepoint_city'] = $checkoutData['delivery_method_data']['service_point']['city'];
84+
$transportObject['sc_servicepoint_post_no'] = $checkoutData['delivery_method_data']['post_number'];
85+
}
86+
}
5187
}

Observer/SaveCheckoutData.php

-39
This file was deleted.

Observer/SaveServicePointsData.php

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function execute(Observer $observer)
3939
$order->setSendcloudServicePointCity($quote->getSendcloudServicePointCity());
4040
$order->setSendcloudServicePointCountry($quote->getSendcloudServicePointCountry());
4141
$order->setSendcloudServicePointPostnumber($quote->getSendcloudServicePointPostnumber());
42+
} else if ($order->getShippingMethod() && strpos($order->getShippingMethod(), 'sendcloudcheckout') !== false && !$order->getSendcloudData()) {
43+
$order->setSendcloudData($quote->getSendcloudCheckoutData());
4244
}
4345

4446
return $this;

Observer/SetOrderAttributes.php

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function execute(Observer $observer)
4747
$order->setSendcloudServicePointCity($quote->getSendcloudServicePointCity());
4848
$order->setSendcloudServicePointCountry($quote->getSendcloudServicePointCountry());
4949
$order->setSendcloudServicePointPostnumber($quote->getSendcloudServicePointPostnumber());
50+
} else if ($order->getShippingMethod() && strpos($order->getShippingMethod(), 'sendcloudcheckout') !== false && !$order->getSendcloudData()) {
51+
$order->setSendcloudData($quote->getSendcloudCheckoutData());
5052
}
5153

5254
return $this;

Observer/SetOrderCheckoutAttributes.php

-47
This file was deleted.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "magento2-module",
55
"homepage": "https://www.sendcloud.com/",
66
"license": "Apache-2.0",
7-
"version": "2.0.23",
7+
"version": "2.0.24",
88
"require": {
99
"php": "~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.1.0|~8.2.0"
1010
},

etc/events.xml

-7
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,18 @@
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
33
<event name="sales_model_service_quote_submit_before">
44
<observer name="sendcloud_sendcloud_servicepointdata" instance="SendCloud\SendCloud\Observer\SaveServicePointsData"/>
5-
<observer name="sendcloud_sendcloud_checkout_data" instance="SendCloud\SendCloud\Observer\SaveCheckoutData"/>
65
</event>
76

87
<event name="sales_order_save_before">
98
<observer name="setOrderAttributes" instance="SendCloud\SendCloud\Observer\SetOrderAttributes"/>
10-
<observer name="setCheckoutOrderAttributes" instance="SendCloud\SendCloud\Observer\SetOrderCheckoutAttributes"/>
119
</event>
1210

1311
<event name="email_order_set_template_vars_before">
1412
<observer name="add_sendcloud_variable_to_order" instance="SendCloud\SendCloud\Observer\AddSendCloudVariable"/>
15-
<observer name="add_sendcloudcheckout_service_point_variable_to_order" instance="SendCloud\SendCloud\Observer\AddSendCloudCheckoutServicePointVariable"/>
16-
<observer name="add_sendcloudcheckout_expected_date_variable_to_order" instance="SendCloud\SendCloud\Observer\AddSendCloudExpectedDateVariable"/>
1713
</event>
1814

1915
<event name="email_shipment_set_template_vars_before">
2016
<observer name="add_sendcloud_variable_to_shipment" instance="SendCloud\SendCloud\Observer\AddSendCloudVariable"/>
21-
<observer name="add_sendcloudcheckout_service_point_variable_to_shipment" instance="SendCloud\SendCloud\Observer\AddSendCloudCheckoutServicePointVariable"/>
22-
<observer name="add_sendcloudcheckout_expected_date_variable_to_shipment" instance="SendCloud\SendCloud\Observer\AddSendCloudExpectedDateVariable"/>
23-
2417
</event>
2518

2619
<event name="checkout_controller_multishipping_shipping_post">

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="SendCloud_SendCloud" setup_version="2.0.23">
3+
<module name="SendCloud_SendCloud" setup_version="2.0.24">
44
<sequence>
55
<module name="Magento_Shipping"/>
66
<module name="Magento_Multishipping"/>

0 commit comments

Comments
 (0)