Skip to content

Commit

Permalink
no store delivery if no markers found
Browse files Browse the repository at this point in the history
  • Loading branch information
livca-smile committed Oct 5, 2023
1 parent 148ee06 commit f128607
Showing 1 changed file with 49 additions and 34 deletions.
83 changes: 49 additions & 34 deletions Block/Checkout/LayoutProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,55 @@ 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 = 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;
Expand Down

0 comments on commit f128607

Please sign in to comment.