Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/1.15.1 #102

Merged
merged 2 commits into from
Nov 15, 2023
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
60 changes: 31 additions & 29 deletions Block/Checkout/Widget.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<?php
/**
* Copyright © 2019 Paazl. All rights reserved.
* Copyright © Paazl. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Paazl\CheckoutWidget\Block\Checkout;

use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Paazl\CheckoutWidget\Model\Api\UrlProvider;
use Paazl\CheckoutWidget\Model\Api\UrlProviderFactory;
use Paazl\CheckoutWidget\Model\Checkout\WidgetConfigProvider;
use Paazl\CheckoutWidget\Model\Config;
use Magento\Framework\View\Element\Template\Context;

/**
* Class Widget
*
* @package Paazl\CheckoutWidget\Block\Checkout
*/
class Widget extends Template
{

Expand All @@ -26,11 +20,6 @@ class Widget extends Template
*/
private $scopeConfig;

/**
* @var WidgetConfigProvider
*/
private $widgetConfigProvider;

/**
* @var UrlProvider
*/
Expand All @@ -39,27 +28,22 @@ class Widget extends Template
/**
* Widget constructor.
*
* @param Context $context
* @param Config $scopeConfig
* @param UrlProviderFactory $urlProviderFactory
* @param WidgetConfigProvider $widgetConfigProvider
* @param array $data
* @param Context $context
* @param Config $scopeConfig
* @param UrlProviderFactory $urlProviderFactory
* @param array $data
*/
public function __construct(
Context $context,
Config $scopeConfig,
UrlProviderFactory $urlProviderFactory,
WidgetConfigProvider $widgetConfigProvider,
array $data = []
) {
$this->scopeConfig = $scopeConfig;
$this->widgetConfigProvider = $widgetConfigProvider;
$this->urlProvider = $urlProviderFactory->create();
parent::__construct($context, $data);
}

// ---

/**
* @return mixed
*/
Expand All @@ -71,17 +55,35 @@ public function getCustomCss()
/**
* @return boolean
*/
public function isEnabled()
public function getGoogleMapKey()
{
return $this->scopeConfig->isEnabled();
return $this->scopeConfig->getGoogleMapKey();
}

/**
* @return string
*/
public function getApiBaseUrl()
{
return $this->urlProvider->getBaseUrl();
}

/**
* @return boolean
*/
public function getGoogleMapKey()
public function useLocal(): bool
{
return $this->scopeConfig->getGoogleMapKey();
return $this->scopeConfig->isUseLocalCopyOfWidgetJs();
}

/**
* @return string
*/
public function getLocalResourceUrl(): string
{
$cssFile = 'paazl-checkout.min.css';
$url = $this->getViewFileUrl('Paazl_CheckoutWidget::css/' . $cssFile);
return str_replace($cssFile, '', $url);
}

/**
Expand All @@ -97,10 +99,10 @@ protected function _toHtml()
}

/**
* @return string
* @return boolean
*/
public function getApiBaseUrl()
public function isEnabled()
{
return $this->urlProvider->getBaseUrl();
return $this->scopeConfig->isEnabled();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "paazl/magento2-checkout-widget",
"description": "Paazl checkoutWidget for Magento 2",
"type": "magento2-module",
"version": "1.15.0",
"version": "1.15.1",
"keywords": [
"Paazl",
"Magento 2",
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<default>
<carriers>
<paazlshipping>
<version>v1.15.0</version>
<version>v1.15.1</version>
<active>0</active>
<sallowspecific>0</sallowspecific>
<price>0</price>
Expand Down
6 changes: 6 additions & 0 deletions view/base/templates/checkout/widget.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
<?php if ($block->getApiBaseUrl()) : ?>
<script type="text/javascript">
window.PAAZL_CHECKOUT_WIDGET_API_URL = '<?= /* @escapeNotVerified */ $block->getApiBaseUrl(); ?>';
window.PAAZL_CHECKOUT_WIDGET_LOCAL_RESOURCE_URL = '<?= /* @escapeNotVerified */ $block->getLocalResourceUrl(); ?>';
</script>
<?php endif; ?>
<?php if ($block->useLocal()) : ?>
<script type="text/javascript">
window.PAAZL_CHECKOUT_WIDGET_RESOURCE_URL = '<?= /* @escapeNotVerified */ $block->getLocalResourceUrl(); ?>';
</script>
<?php endif; ?>
<?php if ($block->getCustomCss() != '') : ?>
<style>:root {<?= /* @escapeNotVerified */ $block->getCustomCss() ?>}</style>
<?php endif; ?>
3 changes: 3 additions & 0 deletions view/frontend/web/css/paazl-checkout.min.css

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion view/frontend/web/js/checkout/lib/checkout_local_live.js

Large diffs are not rendered by default.

Loading
Loading