Updated the version and the code for the warnings and error messages

This commit is contained in:
abhishek.qlo
2026-10-15 12:49:55 +05:30
parent 813c362ebf
commit 2c54a1ea4e
11 changed files with 192 additions and 70 deletions

View File

@@ -1,3 +1,3 @@
---------------------------------------------------------------
# V1.0.0 | COMPATIBLE:: QloApps V1.8.x
# V4.0.0 | COMPATIBLE:: QloApps V1.8.x
---------------------------------------------------------------

View File

@@ -19,9 +19,9 @@ https://qloapps.com/addons/
### Module Versions and Compatibility:
- **Current version:** `1.0.0`
- **Current version:** `4.0.0`
- Module version `1.0.0` compatible with QloApps version `1.8.x`
- Module version `4.0.0` compatible with QloApps version `1.8.x`
### Refund Policy:

View File

@@ -175,18 +175,26 @@ class QghcPropertyService
if ($property) {
if ((int) $property->google_status === QghcProperty::GOOGLE_STATUS_FAILED) {
return array($property->failure_reason
? self::l('Google Hotel: Google could not verify this hotel — ') . $property->failure_reason
: self::l('Google Hotel: Google reported an issue connecting this hotel. Please contact support.'));
? self::l('Google could not verify this hotel — ') . $property->failure_reason
: self::l('Google reported an issue connecting this hotel. Please contact support.'));
}
return array();
}
$errors = self::validateRequiredFields($idHotel, $idLang);
if ($errors) {
// Shown as a list under a "Need to fix" heading, so the "Google Hotel: " prefix is redundant.
$prefix = self::l('Google Hotel: ');
foreach ($errors as $key => $error) {
if (strpos($error, $prefix) === 0) {
$errors[$key] = Tools::substr($error, Tools::strlen($prefix));
}
}
return $errors;
}
return array(self::l('Google Hotel: This hotel is not yet enabled for Google Hotel.'));
return array(self::l('This hotel is not yet enabled for Google Hotel.'));
}
/**

View File

@@ -74,6 +74,22 @@ class AdminGoogleHotelConfigController extends ModuleAdminController
}
}
/** True when the current admin request came over HTTPS (directly or via a TLS-terminating proxy). */
protected function isSecureRequest()
{
if (Tools::usingSecureMode()) {
return true;
}
if (empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
return false;
}
$protos = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO']);
return strtolower(trim($protos[0])) === 'https';
}
/** Renders the configuration page into the admin layout. */
public function initContent()
{
@@ -129,6 +145,8 @@ class AdminGoogleHotelConfigController extends ModuleAdminController
'configs' => $configs,
'ws_key' => $wsKey,
'is_connected' => $isConnected,
'is_secure' => $this->isSecureRequest(),
'ssl_settings_url' => $this->context->link->getAdminLink('AdminPreferences'),
'action_url' => $this->context->link->getAdminLink('AdminGoogleHotelConfig'),
'cron_url' => $cronUrl,
'hotel_list_url' => $hotelEditBase,
@@ -143,6 +161,11 @@ class AdminGoogleHotelConfigController extends ModuleAdminController
return;
}
if (!$this->isSecureRequest()) {
$this->errors[] = $this->l('Connection cannot be created from an unsecure (HTTP) server. Please use HTTPS.');
return;
}
$wsKey = trim(Tools::getValue(QloGoogleHotelConnector::CONFIG_WS_KEY));
$pmsUrl = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__;
@@ -219,6 +242,11 @@ class AdminGoogleHotelConfigController extends ModuleAdminController
return;
}
if (!$this->isSecureRequest()) {
$this->errors[] = $this->l('The webservice key cannot be regenerated from an unsecure (HTTP) server. Please use HTTPS.');
return;
}
$newKey = QghcWebserviceSetup::regenerateKey();
if (!$newKey) {
$this->errors[] = $this->l('Failed to regenerate the webservice key.');

View File

@@ -42,7 +42,7 @@ class QloGoogleHotelConnector extends Module
{
$this->name = 'qlogooglehotelconnector';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->version = '4.0.0';
$this->author = 'Webkul';
$this->need_instance = 0;
$this->bootstrap = true;
@@ -387,10 +387,18 @@ class QloGoogleHotelConnector extends Module
{
$idLang = (int) $this->context->language->id;
$hotelEditBase = $this->context->link->getAdminLink('AdminAddHotel');
$hotels = array();
foreach (QghcPropertyService::getHotelsWithIssues($idLang) as $idHotel => $hotelName) {
$hotels[] = array(
'name' => $hotelName,
'url' => $hotelEditBase . '&id=' . (int) $idHotel . '&updatehtl_branch_info',
);
}
$this->context->smarty->assign(array(
'is_connected' => (int) Configuration::get(self::CONFIG_STATUS) === QghcProperty::GOOGLE_STATUS_CONNECTED,
'hotel_names' => array_values(QghcPropertyService::getHotelsWithIssues($idLang)),
'hotel_list_url' => $this->context->link->getAdminLink('AdminAddHotel'),
'hotels' => $hotels,
'config_url' => $this->context->link->getAdminLink('AdminGoogleHotelConfig'),
));
@@ -402,16 +410,22 @@ class QloGoogleHotelConnector extends Module
{
$idLang = (int) $this->context->language->id;
$isConnected = (int) Configuration::get(self::CONFIG_STATUS) === QghcProperty::GOOGLE_STATUS_CONNECTED;
$hotelNames = array_values(QghcPropertyService::getHotelsWithIssues($idLang));
$editBaseUrl = $this->context->link->getAdminLink('AdminAddHotel');
$hotels = array();
foreach (QghcPropertyService::getHotelsWithIssues($idLang) as $idHotel => $hotelName) {
$hotels[] = array(
'hotel_name' => $hotelName,
'edit_url' => $editBaseUrl . '&id=' . (int) $idHotel . '&updatehtl_branch_info',
);
}
if ($isConnected && !$hotelNames) {
if ($isConnected && !$hotels) {
return '';
}
$this->context->smarty->assign(array(
'is_connected' => $isConnected,
'hotel_names' => $hotelNames,
'hotel_list_url' => $this->context->link->getAdminLink('AdminAddHotel'),
'hotels_with_issues' => $hotels,
'config_url' => $this->context->link->getAdminLink('AdminGoogleHotelConfig'),
));

View File

@@ -110,6 +110,9 @@ table.qghc_api_log th.actions .pull-right {
.qlo-ghc-col-padded { padding-top: 6px; }
.qlo-ghc-status-label { font-size: 12px; padding: 5px 10px; }
.qlo-ghc-missing-list { margin: 8px 0 0 0; padding-left: 20px; }
.qlo-ghc-warning-title { margin-top: 6px; }
.qlo-ghc-warning-title:first-child { margin-top: 0; }
.qlo-ghc-warning-title + .qlo-ghc-missing-list { margin-top: 2px; }
.qlo-ghc-switch-disabled { opacity: 0.5; cursor: not-allowed; }
/* Double class to out-specify core's ".bootstrap p { margin: ... }" without !important. */
.qlo-ghc-helpblock-top.qlo-ghc-helpblock-top { margin-top: 10px; }

View File

@@ -20,6 +20,14 @@
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{if !$is_secure}
<div class="alert alert-danger">
<strong>{l s='Unsecure server detected.' mod='qlogooglehotelconnector'}</strong>
{l s='Your store is not running on a secure (HTTPS) server, so the connection with Google Hotel cannot be created or updated.' mod='qlogooglehotelconnector'}
<a href="{$ssl_settings_url|escape:'html':'UTF-8'}" class="alert-link">{l s='Please enable HTTPS to continue.' mod='qlogooglehotelconnector'}</a>
</div>
{/if}
{* ── Google Hotel Setup ───────────────────────────────────────────────── *}
<div class="panel qlo-ghc-form-left-labels">
@@ -51,9 +59,10 @@
<strong>{l s='Important:' mod='qlogooglehotelconnector'}</strong>
{l s='This key was automatically generated for the Google Hotel connection. Please do not change the permissions of this webservice key.' mod='qlogooglehotelconnector'}
{if !$is_connected}
<br><br>
{l s='To complete the setup, click' mod='qlogooglehotelconnector'}
<strong>{l s='Create Connection' mod='qlogooglehotelconnector'}</strong>.
<div class="qlo-ghc-warning-title">
{l s='To complete the setup, click' mod='qlogooglehotelconnector'}
<strong>{l s='Create Connection' mod='qlogooglehotelconnector'}</strong>.
</div>
{/if}
</div>
@@ -70,7 +79,7 @@
placeholder="{l s='Enter your webservice key' mod='qlogooglehotelconnector'}" />
{if $ws_key}
<p class="qlo-ghc-helpblock-top">
<button type="submit" form="ghc-regenerate-form" class="btn btn-default btn-sm">
<button type="submit" form="ghc-regenerate-form" class="btn btn-default btn-sm"{if !$is_secure} disabled="disabled"{/if}>
<i class="icon-refresh"></i>
{l s='Regenerate Key' mod='qlogooglehotelconnector'}
</button>
@@ -112,7 +121,7 @@
{else}
<span></span>
{/if}
<button type="submit" form="ghc-connection-form" class="btn btn-default">
<button type="submit" form="ghc-connection-form" class="btn btn-default"{if !$is_secure} disabled="disabled"{/if}>
<i class="process-icon-save"></i>&nbsp;
{if $is_connected}
{l s='Update Connection' mod='qlogooglehotelconnector'}
@@ -124,6 +133,36 @@
</div>
{if !$is_secure}
<script type="text/javascript">
{literal}
(function () {
var form = document.getElementById('ghc-connection-form');
if (!form) { return; }
// Unsecure server: never let the connection form be submitted, even if the disabled attribute is removed.
form.addEventListener('submit', function (e) {
e.preventDefault();
e.stopImmediatePropagation();
return false;
}, true);
form.removeAttribute('action');
form.onsubmit = function () { return false; };
var regenForm = document.getElementById('ghc-regenerate-form');
if (regenForm) {
regenForm.addEventListener('submit', function (e) {
e.preventDefault();
e.stopImmediatePropagation();
return false;
}, true);
regenForm.removeAttribute('action');
regenForm.onsubmit = function () { return false; };
}
})();
{/literal}
</script>
{/if}
{* ── Cron job setting ─────────────────────────────────────────────────── *}
<div class="panel">

View File

@@ -22,16 +22,16 @@
<div class="col-sm-12">
<section id="ghc-dashboard-notification" class="widget panel">
<h3>
<i class="icon-{if $is_connected && empty($hotel_names)}check-circle text-success{else}warning-sign text-warning{/if}"></i>
<i class="icon-{if $is_connected && empty($hotels)}check-circle text-success{else}warning-sign text-warning{/if}"></i>
{l s='Google Hotel Connector' mod='qlogooglehotelconnector'}
</h3>
{if !$is_connected}
<p class="qlo-ghc-notif-desc">
{l s='Not connected to the Google Hotel Center.' mod='qlogooglehotelconnector'}
&nbsp;<a href="{$config_url|escape:'html':'UTF-8'}">{l s='Fix in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
{l s='Connect to Google Hotel to get more commission-free direct bookings.' mod='qlogooglehotelconnector'}
&nbsp;<a href="{$config_url|escape:'html':'UTF-8'}">{l s='Connect in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
</p>
{elseif !empty($hotel_names)}
{elseif !empty($hotels)}
<p class="qlo-ghc-notif-desc">
{l s='Connected to the Google Hotel Center, but some hotels are not listed.' mod='qlogooglehotelconnector'}
</p>
@@ -41,22 +41,18 @@
</p>
{/if}
{if !empty($hotel_names)}
{if !empty($hotels)}
<p class="qlo-ghc-notif-title">
<strong>{l s='Hotels with an issue:' mod='qlogooglehotelconnector'}</strong>
&nbsp;<span class="label label-danger qlo-ghc-badge-urgent">{l s='Urgent Action Needed' mod='qlogooglehotelconnector'}</span>
</p>
<ul class="list-unstyled qlo-ghc-notif-list">
{foreach from=$hotel_names item=hotelName}
{foreach from=$hotels item=hotel}
<li class="qlo-ghc-notif-item">
<i class="icon-circle text-danger qlo-ghc-notif-dot"></i>
&nbsp;<strong>{$hotelName|escape:'html':'UTF-8'}</strong>
&nbsp;<a href="{$hotel.url|escape:'html':'UTF-8'}"><strong>{$hotel.name|escape:'html':'UTF-8'}</strong></a>
</li>
{/foreach}
</ul>
<p class="qlo-ghc-notif-desc">
<a href="{$hotel_list_url|escape:'html':'UTF-8'}">{l s='View Hotel List' mod='qlogooglehotelconnector'}</a>
</p>
{/if}
<a href="{$config_url|escape:'html':'UTF-8'}" class="btn btn-default btn-sm btn-block">

View File

@@ -21,24 +21,42 @@
*}
<div class="row">
<div class="col-lg-12">
{if !$is_connected}
<div class="alert alert-danger">
<strong>{l s='Not connected to the Google Hotel Center.' mod='qlogooglehotelconnector'}</strong>
{l s='Hotels cannot sync with Google Hotel Ads until this is fixed.' mod='qlogooglehotelconnector'}
&nbsp;<a href="{$config_url|escape:'html':'UTF-8'}" class="alert-link">{l s='Fix in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
</div>
{/if}
<div class="alert alert-warning" id="ghc-dashboard-warning">
<button type="button" class="close" aria-label="{l s='Close' mod='qlogooglehotelconnector'}">&times;</button>
{if !$is_connected}
<strong>{l s='Connect to Google Hotel to get more commission-free direct bookings.' mod='qlogooglehotelconnector'}</strong>
&nbsp;<a href="{$config_url|escape:'html':'UTF-8'}" class="alert-link">{l s='Connect in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
{/if}
{if !empty($hotel_names)}
<div class="alert alert-warning">
<strong>{l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'}</strong>
{if !empty($hotels_with_issues)}
<div class="qlo-ghc-warning-title">{l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'}</div>
<ul class="qlo-ghc-missing-list">
{foreach from=$hotel_names item=hotelName}
<li>{$hotelName|escape:'html':'UTF-8'}</li>
{foreach from=$hotels_with_issues item=hotel}
<li><a href="{$hotel.edit_url|escape:'html':'UTF-8'}" class="alert-link">{$hotel.hotel_name|escape:'html':'UTF-8'}</a></li>
{/foreach}
</ul>
<a href="{$hotel_list_url|escape:'html':'UTF-8'}" class="alert-link">{l s='View Hotel List' mod='qlogooglehotelconnector'}</a>
</div>
{/if}
{/if}
</div>
</div>
</div>
<script type="text/javascript">
{literal}
(function () {
var box = document.getElementById('ghc-dashboard-warning');
if (!box) { return; }
var name = 'qghc_dismiss_dashboard';
// Dismissed earlier? Hide it right away. Clearing cookies brings the warning back.
if (document.cookie.indexOf(name + '=1') !== -1) {
box.parentNode.removeChild(box);
return;
}
var btn = box.querySelector('.close');
if (btn) {
btn.addEventListener('click', function () {
document.cookie = name + '=1; path=/';
box.parentNode.removeChild(box);
});
}
})();
{/literal}
</script>

View File

@@ -20,22 +20,19 @@
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
<div id="ghc-hotel-top-warning">
{if !$is_connected}
<div class="alert alert-danger qlo-ghc-alert-mb">
<strong>{l s='Not connected to the Google Hotel Center.' mod='qlogooglehotelconnector'}</strong>
{l s='Hotels cannot sync with Google Hotel Ads until this is fixed.' mod='qlogooglehotelconnector'}
&nbsp;<a href="{$hotel_edit_config_url|escape:'html':'UTF-8'}" class="alert-link">{l s='Fix in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
</div>
{/if}
<div class="alert alert-warning">
{if !$is_connected}
<strong>{l s='Connect to Google Hotel to get more commission-free direct bookings.' mod='qlogooglehotelconnector'}</strong>
&nbsp;<a href="{$hotel_edit_config_url|escape:'html':'UTF-8'}" class="alert-link">{l s='Connect in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
{/if}
{if !empty($issue_reasons)}
<div class="alert alert-warning">
<strong>{l s='This hotel is not listed on Google Hotel:' mod='qlogooglehotelconnector'}</strong>
{if !empty($issue_reasons)}
<div class="qlo-ghc-warning-title">{l s='Need to fix the below mentioned issues:' mod='qlogooglehotelconnector'}</div>
<ul class="qlo-ghc-missing-list">
{foreach from=$issue_reasons item=reason}
<li>{$reason|escape:'html':'UTF-8'} {l s='Use the Google Hotel tab below to enable it.' mod='qlogooglehotelconnector'}</li>
<li>{$reason|escape:'html':'UTF-8'}</li>
{/foreach}
</ul>
</div>
{/if}
{/if}
</div>
</div>

View File

@@ -19,21 +19,40 @@
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{if !$is_connected}
<div class="alert alert-danger">
<strong>{l s='Not connected to the Google Hotel Center.' mod='qlogooglehotelconnector'}</strong>
{l s='Hotels cannot sync with Google Hotel Ads until this is fixed.' mod='qlogooglehotelconnector'}
&nbsp;<a href="{$config_url|escape:'html':'UTF-8'}" class="alert-link">{l s='Fix in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
</div>
{/if}
<div class="alert alert-warning" id="ghc-hotel-list-warning">
<button type="button" class="close" aria-label="{l s='Close' mod='qlogooglehotelconnector'}">&times;</button>
{if !$is_connected}
<strong>{l s='Connect to Google Hotel to get more commission-free direct bookings.' mod='qlogooglehotelconnector'}</strong>
&nbsp;<a href="{$config_url|escape:'html':'UTF-8'}" class="alert-link">{l s='Connect in Google Hotel Setup' mod='qlogooglehotelconnector'}</a>
{/if}
{if !empty($hotels_with_issues)}
<div class="alert alert-warning">
<strong>{l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'}</strong>
{if !empty($hotels_with_issues)}
<div class="qlo-ghc-warning-title">{l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'}</div>
<ul class="qlo-ghc-missing-list">
{foreach from=$hotels_with_issues item=hotel}
<li><a href="{$hotel.edit_url|escape:'html':'UTF-8'}">{$hotel.hotel_name|escape:'html':'UTF-8'}</a></li>
<li><a href="{$hotel.edit_url|escape:'html':'UTF-8'}" class="alert-link">{$hotel.hotel_name|escape:'html':'UTF-8'}</a></li>
{/foreach}
</ul>
</div>
{/if}
{/if}
</div>
<script type="text/javascript">
{literal}
(function () {
var box = document.getElementById('ghc-hotel-list-warning');
if (!box) { return; }
var name = 'qghc_dismiss_hotel_list';
// Dismissed earlier? Hide it right away. Clearing cookies brings the warning back.
if (document.cookie.indexOf(name + '=1') !== -1) {
box.parentNode.removeChild(box);
return;
}
var btn = box.querySelector('.close');
if (btn) {
btn.addEventListener('click', function () {
document.cookie = name + '=1; path=/';
box.parentNode.removeChild(box);
});
}
})();
{/literal}
</script>