diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php
index d72df6b..eae5ad4 100644
--- a/Block/Checkout/LayoutProcessor.php
+++ b/Block/Checkout/LayoutProcessor.php
@@ -51,40 +51,56 @@ public function __construct(
public function process($jsLayout)
{
if ($this->carrierFactory->getIfActive($this->methodCode)) {
- // @codingStandardsIgnoreStart
- $storeDelivery = $jsLayout['components']['checkout']['children']['steps']['children']
- ['shipping-step']['children']['shippingAddress']['children']['address-list']
- ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
- ['children']['store-delivery'];
- // @codingStandardsIgnoreEnd
-
- $storeDelivery['provider'] = $this->map->getIdentifier();
- $storeDelivery['markers'] = $this->getStores();
- $storeDelivery = array_merge($storeDelivery, $this->map->getConfig());
-
- // @codingStandardsIgnoreStart
- $jsLayout['components']['checkout']['children']['steps']['children']
- ['shipping-step']['children']['shippingAddress']['children']['address-list']
- ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
- ['children']['store-delivery'] = $storeDelivery;
- // @codingStandardsIgnoreEnd
-
- // @codingStandardsIgnoreStart
- $geocoder = $jsLayout['components']['checkout']['children']['steps']['children']
- ['shipping-step']['children']['shippingAddress']['children']['address-list']
- ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
- ['children']['store-delivery']['children']['geocoder'];
- // @codingStandardsIgnoreEnd
-
- $geocoder['provider'] = $this->map->getIdentifier();
- $geocoder = array_merge($geocoder, $this->map->getConfig());
-
- // @codingStandardsIgnoreStart
- $jsLayout['components']['checkout']['children']['steps']['children']
- ['shipping-step']['children']['shippingAddress']['children']['address-list']
- ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
- ['children']['store-delivery']['children']['geocoder'] = $geocoder;
- // @codingStandardsIgnoreEnd
+ $markers = $this->getStores();
+
+ if ($markers) {
+ // @codingStandardsIgnoreStart
+ $storeDelivery = $jsLayout['components']['checkout']['children']['steps']['children']
+ ['shipping-step']['children']['shippingAddress']['children']['address-list']
+ ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
+ ['children']['store-delivery'];
+ // @codingStandardsIgnoreEnd
+
+ $storeDelivery['provider'] = $this->map->getIdentifier();
+ $storeDelivery['markers'] = $markers;
+ $storeDelivery['searchPlaceholderText'] = $this->storeLocatorHelper->getSearchPlaceholder();
+ $storeDelivery = array_merge($storeDelivery, $this->map->getConfig());
+
+ // @codingStandardsIgnoreStart
+ $jsLayout['components']['checkout']['children']['steps']['children']
+ ['shipping-step']['children']['shippingAddress']['children']['address-list']
+ ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
+ ['children']['store-delivery'] = $storeDelivery;
+ // @codingStandardsIgnoreEnd
+
+ // @codingStandardsIgnoreStart
+ $geocoder = $jsLayout['components']['checkout']['children']['steps']['children']
+ ['shipping-step']['children']['shippingAddress']['children']['address-list']
+ ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
+ ['children']['store-delivery']['children']['geocoder'];
+ // @codingStandardsIgnoreEnd
+
+ $geocoder['provider'] = $this->map->getIdentifier();
+ $geocoder = array_merge($geocoder, $this->map->getConfig());
+
+ // @codingStandardsIgnoreStart
+ $jsLayout['components']['checkout']['children']['steps']['children']
+ ['shipping-step']['children']['shippingAddress']['children']['address-list']
+ ['rendererTemplates']['store-delivery']['children']['smile-store-delivery']
+ ['children']['store-delivery']['children']['geocoder'] = $geocoder;
+ // @codingStandardsIgnoreEnd
+ }
+
+ // unset store-delivery if $markers found
+ if (!$markers) {
+ unset($jsLayout['components']['checkout']['children']['steps']['children']
+ ['shipping-step']['children']['shippingAddress']['children']['address-list']
+ ['rendererTemplates']['store-delivery']);
+ unset($jsLayout['components']['checkout']['children']['steps']['children']
+ ['shipping-step']['children']['smile-store-delivery-address-provider']);
+ unset($jsLayout['components']['checkout']['children']['sidebar']['children']
+ ['shipping-information']['children']['ship-to']['rendererTemplates']['store-delivery']);
+ }
}
return $jsLayout;
@@ -118,6 +134,8 @@ private function getStores(): array
'directionUrl' => $this->map->getDirectionUrl($address->getCoordinates()),
'setStoreData' => $this->getSetStorePostData($retailer),
'addressData' => $address->getData(),
+ 'postCode' => $address->getPostcode(),
+ 'city' => $address->getCity(),
];
// phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b4d4493..3996677 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
+## [2.0.1] - 2024-05-03
+[2.0.1]: https://github.com/Smile-SA/magento2-module-store-delivery/compare/2.0.0...2.0.1
+
+- Refactor - same search design everywhere
+- Dont show store delivery shipping method if no markers found
+
## [2.0.0] - 2023-09-20
[2.0.0]: https://github.com/Smile-SA/magento2-module-store-delivery/compare/1.1.10...2.0.0
diff --git a/Plugin/CustomerData/CurrentStorePlugin.php b/Plugin/CustomerData/CurrentStorePlugin.php
new file mode 100644
index 0000000..8c866c3
--- /dev/null
+++ b/Plugin/CustomerData/CurrentStorePlugin.php
@@ -0,0 +1,30 @@
+getRetailer();
+
+ if ($retailer) {
+ $result['allow_store_delivery'] = (int) $retailer->getData('allow_store_delivery');
+ }
+
+ return $result;
+ }
+}
diff --git a/etc/di.xml b/etc/di.xml
index a7e1dab..47c0b94 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -17,5 +17,9 @@
+
+
+
+
diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml
index e36b393..9efd013 100644
--- a/view/frontend/layout/checkout_index_index.xml
+++ b/view/frontend/layout/checkout_index_index.xml
@@ -70,7 +70,6 @@
-
- smile-geocoder
- Find a store :
- - City, Zipcode, Department, ...
- Search
-
diff --git a/view/frontend/web/css/source/_module.less b/view/frontend/web/css/source/_module.less
index 96d6d15..47cd614 100644
--- a/view/frontend/web/css/source/_module.less
+++ b/view/frontend/web/css/source/_module.less
@@ -87,52 +87,56 @@ body.checkout-index-index {
.shop-search {
width: 250px;
height: 100%;
+
+ // TODO cleaning
.fulltext-search-wrapper {
- border-bottom: 1px solid #c2c2c2;
- height: @fulltext-search-wrapper-height;
- padding: @fulltext-search-wrapper-padding;
+ padding: 10px;
+ position: relative;
+ display: flex;
+ align-items: center;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: center;
+
+ div.geolocalize-container {
+ flex: 0 0 100%;
+ a {
+ width: 100%;
+ text-align: center;
+ }
+ }
- .form {
+ .store-search-form {
display: flex;
- padding: 10px 0 5px;
+ margin-left: auto;
align-items: center;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: center;
-
+ flex: 0 0 100%;
+ margin-top: 5px;
.field {
- flex: 1;
+ flex: 5;
}
+ .actions {
+ flex:1;
+ button {
+ width: 100%;
- .actions-toolbar {
-
- .primary .action {
- margin: 0;
- border-top-left-radius: 0px;
- border-bottom-left-radius: 0px;
- padding: 6px 15px;
- font-size: 1.4rem;
- span {
- line-height: 1.3em;
+ &:before {
+ content: '\e615';
+ font-family: 'luma-icons';
+ font-size: 16px;
+ color: #FFFFFF;
+ margin: 0;
+ vertical-align: top;
+ display: inline-block;
+ font-weight: normal;
+ overflow: hidden;
+ speak: none;
+ text-align: center;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: antialiased;
}
}
}
-
- .geolocalize-container {
- flex: 0 0 100%;
- a {
- width:100%;
- text-align:center;
- }
- }
-
- .store-search-form {
- display: flex;
- margin-left: auto;
- align-items: center;
- flex: 0 0 100%;
- margin-top: 5px;
- }
}
}
}
diff --git a/view/frontend/web/js/view/checkout/shipping/store-delivery.js b/view/frontend/web/js/view/checkout/shipping/store-delivery.js
index 9a72f39..4880d16 100644
--- a/view/frontend/web/js/view/checkout/shipping/store-delivery.js
+++ b/view/frontend/web/js/view/checkout/shipping/store-delivery.js
@@ -28,7 +28,7 @@ define([
var type = quote.shippingAddress().getType();
if (type === 'store-delivery') {
selectShippingMethodAction({
- carrier_code: this.getCarrierCode(),
+ carrier_code: this.getCarrierCode(),
carrier_title: this.getCarrierTitle(),
method_code: this.getMethodCode(),
method_title: this.getMethodTitle(),
@@ -67,7 +67,7 @@ define([
return this.methodCode;
},
- getMethodTitle: function() {
+ getMethodTitle: function() {
return this.methodTitle;
},
@@ -75,7 +75,7 @@ define([
return this.carrierCode;
},
- getCarrierTitle: function() {
+ getCarrierTitle: function() {
return this.carrierTitle;
},
diff --git a/view/frontend/web/js/view/shipping-address/store-delivery.js b/view/frontend/web/js/view/shipping-address/store-delivery.js
index 0b105ea..7b742db 100644
--- a/view/frontend/web/js/view/shipping-address/store-delivery.js
+++ b/view/frontend/web/js/view/shipping-address/store-delivery.js
@@ -33,7 +33,12 @@ define(
var address = new storeDeliveryAddress(null, {});
var currentStore = customerData.get('current-store');
- if (currentStore() && currentStore().entity_id && currentStore().address_data) {
+ if (currentStore()
+ && currentStore().entity_id
+ && currentStore().address_data
+ // write address only if allow_store_delivery === 1 for currentStore in customerData
+ && currentStore().allow_store_delivery
+ ) {
var addressData = currentStore().address_data;
if ((addressData.company === undefined) && currentStore().name) {
addressData.company = currentStore().name;