Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,15 @@ class Config extends AbstractHelper
const XML_PATH_IS_WEB_VIEW = 'payment/boltpay/is_web_view';

/**
*
* Is authentication popup enabled
*/
const XML_PATH_IS_AUTHENTICATION_POPUP_ENABLED = 'payment/boltpay/is_authentication_popup_enabled';

/**
* Google Maps Key for Magestore Storepickup
*/
const XML_PATH_MAGESTORE_STOREPICKUP_GOOGLE_MAPS_KEY = 'payment/boltpay/magestore_storepickup_google_maps_key';

/**
* Default whitelisted shopping cart and checkout pages "Full Action Name" identifiers, <router_controller_action>
* Pages allowed to load Bolt javascript / show checkout button
Expand Down Expand Up @@ -521,7 +526,8 @@ class Config extends AbstractHelper
'instant_button_variant' => self::XML_PATH_INSTANT_BUTTON_VARIANT,
'instant_button_variant_ppc' => self::XML_PATH_INSTANT_BUTTON_VARIANT_PPC,
'is_web_view' => self::XML_PATH_IS_WEB_VIEW,
'is_authentication_popup_enabled' => self::XML_PATH_IS_AUTHENTICATION_POPUP_ENABLED
'is_authentication_popup_enabled' => self::XML_PATH_IS_AUTHENTICATION_POPUP_ENABLED,
'magestore_storepickup_google_maps_key' => self::XML_PATH_MAGESTORE_STOREPICKUP_GOOGLE_MAPS_KEY,
];

/**
Expand Down Expand Up @@ -686,7 +692,7 @@ public function getPayByLinkUrl($isAllowCustomURLForProduction = false, $storeId
{
if ($this->isSandboxModeSet()) {
$url = $this->getCdnUrlFromAdditionalConfig($storeId) ?: $this->getCustomURLValueOrDefault(self::XML_PATH_CUSTOM_CDN, self::CDN_URL_SANDBOX);
} else if ($isAllowCustomURLForProduction) {
} elseif ($isAllowCustomURLForProduction) {
$url = $this->getCdnUrlFromAdditionalConfig($storeId) ?: $this->getCustomURLValueOrDefault(self::XML_PATH_CUSTOM_CDN, self::CDN_URL_PRODUCTION);
} else {
$url = self::CDN_URL_PRODUCTION ?: '';
Expand Down Expand Up @@ -2104,6 +2110,9 @@ public function getAllConfigSettings()
$boltSettings[] = $this->boltConfigSettingFactory->create()
->setName('instant_button_variant_ppc')
->setValue($this->getInstantPPCButtonVariant());
$boltSettings[] = $this->boltConfigSettingFactory->create()
->setName('magestore_storepickup_google_maps_key')
->setValue($this->getMagestoreStorepickupGoogleMapsKey());

return $boltSettings;
}
Expand Down Expand Up @@ -2775,4 +2784,20 @@ public function isAuthenticationPopupEnabled($websiteId = null)
$websiteId
);
}

/**
* Get Google Maps Key for Magestore Storepickup from config
*
* @param int|string $storeId
*
* @return string
*/
public function getMagestoreStorepickupGoogleMapsKey($storeId = null)
{
return $this->getScopeConfig()->getValue(
self::XML_PATH_MAGESTORE_STOREPICKUP_GOOGLE_MAPS_KEY,
ScopeInterface::SCOPE_STORE,
$storeId
) ?: '';
}
}
22 changes: 16 additions & 6 deletions ThirdPartyModules/Magestore/Storepickup.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Bolt\Boltpay\Api\Data\StoreAddressInterfaceFactory;
use Bolt\Boltpay\Api\Data\ShipToStoreOptionInterfaceFactory;
use Bolt\Boltpay\Helper\Bugsnag;
use Bolt\Boltpay\Helper\Config;
use Bolt\Boltpay\Helper\Geolocation;
use Bolt\Boltpay\Helper\Shared\CurrencyUtils;

Expand Down Expand Up @@ -93,6 +94,11 @@ class Storepickup
*/
private $geolocation;

/**
* @var Config
*/
private $configHelper;

/**
* @var Json
*/
Expand Down Expand Up @@ -126,7 +132,8 @@ class Storepickup
* @param ShippingMethodExtensionFactory $extensionFactory
* @param Session $checkoutSession
* @param Geolocation $geolocation
* @param Json $json
* @param Config $configHelper
* @param Json|null $json
*/
public function __construct(
Bugsnag $bugsnagHelper,
Expand All @@ -140,7 +147,8 @@ public function __construct(
ShippingMethodExtensionFactory $extensionFactory,
Session $checkoutSession,
Geolocation $geolocation,
Json $json
Config $configHelper,
Json $json = null
) {
$this->bugsnagHelper = $bugsnagHelper;
$this->storeAddressFactory = $storeAddressFactory;
Expand All @@ -153,7 +161,8 @@ public function __construct(
$this->extensionFactory = $extensionFactory;
$this->checkoutSession = $checkoutSession;
$this->geolocation = $geolocation;
$this->json = $json;
$this->configHelper = $configHelper;
$this->json = $json ?: ObjectManager::getInstance()->get(Json::class);
}

/**
Expand Down Expand Up @@ -307,7 +316,7 @@ public function getShipToStoreOptions(
if (!empty($stores)) {
$radius = $systemConfig->getDefaultRadius();
$distanceUnit = ($systemConfig->getDistanceUnit() == 'Km') ? 'km' : 'mile';
$shippingGeoData = $this->calShippingAddressGeo($addressData, $mageStoreHelper);
$shippingGeoData = $this->calShippingAddressGeo($addressData, $mageStoreHelper, $quote);
if (empty($shippingGeoData)) {
$this->bugsnagHelper->notifyError('Fail to get geolocation', var_export($addressData, true));
}
Expand Down Expand Up @@ -421,11 +430,12 @@ public function filterStoreCollection(
*
* @return array
*/
protected function calShippingAddressGeo($addressData, $mageStoreHelper)
protected function calShippingAddressGeo($addressData, $mageStoreHelper, $quote)
{
$geoData = [];
$address = ($addressData['street_address1'] ?? '') . ',' . ($addressData['locality'] ?? '') . ',' . ($addressData['region'] ?? '') . ' ' . ($addressData['postal_code'] ?? '') . ',' . ($addressData['country_code'] ?? '');
$googleMapApiKey = $mageStoreHelper->getGoogleApiKey();
$storeId = $quote->getStoreId();
$googleMapApiKey = $this->configHelper->getMagestoreStorepickupGoogleMapsKey($storeId) ?: $mageStoreHelper->getGoogleApiKey();
$client = $this->clientFactory->create(['config' => [
'base_uri' => 'https://maps.googleapis.com/'
]]);
Expand Down
5 changes: 5 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<if_module_enabled>MageWorx_RewardPoints</if_module_enabled>
</field>
<field id="magestore_storepickup_google_maps_key" translate="label" type="text" sortOrder="248" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Google Maps Key for Magestore Storepickup</label>
<config_path>payment/boltpay/magestore_storepickup_google_maps_key</config_path>
<if_module_enabled>Magestore_Storepickup</if_module_enabled>
</field>
</group>
<group id="catalog_ingestion" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Catalog Ingestion</label>
Expand Down