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 Version 3.6.1 #106

Merged
merged 1 commit into from
May 16, 2024
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"klevu/module-msi": "Add support for MSI during product sync"
},
"type": "magento2-module",
"version": "3.6.0",
"version": "3.6.1",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*/
?>
<?php
$scriptString = <<<script
$quickSearchScriptString = '';
$landingScriptString = '';

if ({$block->shouldOutputQuickScript()}) {
if ($block->shouldOutputQuickScript()) {
$quickSearchScriptString = <<<script
klevu.settings.chains.initChain.add({
name: "addPriceSuffixToQuickQuery",
fire: function (data) {
Expand All @@ -33,9 +35,12 @@ $scriptString = <<<script
}
});
});
}

if ({$block->shouldOutputLandingScript()}) {
script;
}

if ($block->shouldOutputLandingScript()) {
$landingScriptString = <<<script
klevu.settings.chains.initChain.add({
name: "addPriceSuffixToLandingQuery",
fire: function (data) {
Expand All @@ -61,13 +66,16 @@ $scriptString = <<<script
}
});
});
}

script;
}

?>
<?= $secureRenderer->renderTag(
'script',
['type' => 'text/javascript'],
$scriptString,
false
) ?>
<?php if (strlen($quickSearchScriptString) || strlen($landingScriptString)): ?>
<?= $secureRenderer->renderTag(
'script',
['type' => 'text/javascript'],
$quickSearchScriptString . $landingScriptString,
false
) ?>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*/
?>
<?php
$scriptString = <<<script
$quickSearchScriptString = '';
$landingScriptString = '';

if ({$block->shouldOutputQuickScript()}) {
if ($block->shouldOutputQuickScript()) {
$quickSearchScriptString = <<<script
klevu.settings.chains.initChain.add({
name: "addCurrencyTranslationToQuick",
fire: function (data) {
Expand All @@ -27,9 +29,12 @@ $scriptString = <<<script
klevu.setObjectPath(data, "flags.currencyTranslationAdded.quick", true);
}
});
}

if ({$block->shouldOutputLandingScript()}) {
script;
}

if ($block->shouldOutputLandingScript()) {
$landingScriptString = <<<script
klevu.settings.chains.initChain.add({
name: "addCurrencyTranslationToLanding",
fire: function (data) {
Expand All @@ -49,13 +54,16 @@ $scriptString = <<<script
klevu.setObjectPath(data, "flags.currencyTranslationAdded.landing", true);
}
});
}

script;
}
?>
<?= $secureRenderer->renderTag(
'script',
['type' => 'text/javascript'],
$scriptString,
false
) ?>

<?php if (strlen($quickSearchScriptString) || strlen($landingScriptString)): ?>
<?= $secureRenderer->renderTag(
'script',
['type' => 'text/javascript'],
$quickSearchScriptString . $landingScriptString,
false
) ?>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$currencyCurrencyRates = $block->getCurrentCurrencyRates();
$isPubInUse = $block->isPubInUse() ? 'true' : 'false';
$outputCurrencyRates = $currencyCurrencyRates
? 'var klevu_currentCurrencyRates = ' . $currencyCurrencyRates .';'
? 'var klevu_currentCurrencyRates = {' . $currencyCurrencyRates .'};'
: '';
?>

Expand Down
16 changes: 9 additions & 7 deletions view/frontend/templates/hyva/html/header/search-form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,24 @@ $configProvider = $viewModels->require(ConfigProvider::class);
$helper = $this->helper(SearchHelper::class);
?>
<?php
$queryLength = (int) $helper->getMinQueryLength();
$minQueryLength = (int) $helper->getMinQueryLength();
$suggestionsAllowed = $configProvider->isSuggestionsAllowed() ? 'true' : 'false';
$scriptString = <<<script

'use strict';

function initMiniSearch() {
return {
minSearchLength: {$queryLength},
minSearchLength: $minQueryLength,
suggestionsAllowed: $suggestionsAllowed,
suggestions: [],
suggest() {
const search = this.$refs.searchInput;
const search = this.\$refs.searchInput;
if (search.value.length >= this.minSearchLength) {
search.setCustomValidity('');
search.reportValidity();
// Start Klevu customisation of default Hyvä template
if({$configProvider->isSuggestionsAllowed()}){
if (this.suggestionsAllowed) {
this.fetchSuggestions(search.value);
} else {
this.suggestions = [];
Expand All @@ -75,17 +77,17 @@ $scriptString = <<<script
.then(result => this.suggestions = result);
},
search(term) {
const search = this.$refs.searchInput;
const search = this.\$refs.searchInput;
term = term || search.value;
if (term.length < this.minSearchLength) {
search.setCustomValidity('{$escaper->escapeJs(
__('Minimum Search query length is %1', $helper->getMinQueryLength())
__('Minimum Search query length is %1', $minQueryLength)
)}');
search.reportValidity();
} else {
search.setCustomValidity('');
search.value = term;
this.$refs.form.submit();
this.\$refs.form.submit();
}
},
focusElement(element) {
Expand Down
55 changes: 33 additions & 22 deletions view/frontend/templates/klevu/search/form_js.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
*/
?>

<?php if ($block->isExtensionConfigured()) :
$url = $block->getUrl('search', ['_secure' => $block->getRequest()->isSecure()]); ?>
<?php if ($block->isExtensionConfigured()) : ?>
<?php
$isLandingDisabled = $block->isLandingEnabled() === $block::DISABLE;
$isLandingThemeJs = $block->isLandingEnabled() === $block::KlEVUTEMPLATE;
$isLandingPreserveLayout = $block->isLandingEnabled() === $block::KlEVUPRESERVELAYOUT;
$url = $block->getUrl('search', ['_secure' => $block->getRequest()->isSecure()]);
$landingTheme = (int)$block->isLandingEnabled();
$scriptString = <<<script

// add in cms template
var klevu_current_version = '{$block->getModuleInfo()}';
var allInputs = document.getElementsByTagName('input');
if ({$isLandingDisabled}) {

script;
if ($landingTheme === $block::DISABLE) {
$scriptString .= <<<script
var klevu_showQuickSearchOnEnter = true;
(function () {
// Remove Magento event observers from the search box
Expand All @@ -32,24 +33,32 @@
}
}
})();
} elseif ({$isLandingThemeJs}) {

script;
} else if ($landingTheme === $block::KlEVUTEMPLATE) {
$scriptString .= <<<script
(function () {
// Remove Magento event observers from the search box
// Redirect to klevu js page
for (i = 0, len = allInputs.length; i < len; i++) {
if (allInputs[i].type === "text" || allInputs[i].type === "search") {
if (allInputs[i].name === "q" || allInputs[i].id === "search") {
var search_input = allInputs[i];
search_input.form.action = '{$url}';//?q="+search_input.value;
search_input.form.action = '$url';//?q="+search_input.value;
}
}
}

})();
} elseif ({$isLandingPreserveLayout}) {
var klevu_storeLandingPageUrl = '$url';
var klevu_showQuickSearchOnEnter = false;

script;
} else if ($landingTheme === $block::KlEVUPRESERVELAYOUT) {
$scriptString .= <<<script
(function () {
// Remove Magento event observers from the search box
// default magetno layout landing page
// default Magento layout landing page
for (i = 0, len = allInputs.length; i < len; i++) {
if (allInputs[i].type === "text" || allInputs[i].type === "search") {
if (allInputs[i].name === "q" || allInputs[i].id === "search") {
Expand All @@ -58,20 +67,16 @@
}
}
})();
<?php
} ?>

if ({$isLandingPreserveLayout}) {
var klevu_storeLandingPageUrl = '{$block->getUrl(
'catalogsearch/result',
['_secure' => $block->getRequest()->isSecure()]
)}';
var klevu_showQuickSearchOnEnter = false;
} elseif ({$isLandingThemeJs}) { ?>
var klevu_storeLandingPageUrl = '{$url}';
var klevu_showQuickSearchOnEnter = false;

script;
}

$scriptString .= <<<script
// call store js
var klevu_apiKey = '{$block->getJsApiKey()}',
searchTextBoxName = 'search',
Expand Down Expand Up @@ -108,14 +113,20 @@ script;
if (typeof klevu_currentCurrencyCode === "undefined") {
var klevu_currentCurrencyCode = "{$block->escapeJsQuote($block->getCurrentCurrencyCode())}";
}
script;

<?php if (!empty({$currency})) : ?>
if (typeof klevu_currentCurrencyRates === "undefined") {
var klevu_currentCurrencyRates = {{$currency}};
if ($currency) {
$currencyScriptString .= <<<script

if (typeof klevu_currentCurrencyRates === "undefined") {
var klevu_currentCurrencyRates = {{$currency}};
}
script;
}
<?php endif; ?>

klevu_pubIsInUse = {$pubIsInUse};
$currencyScriptString .= <<<script

klevu_pubIsInUse = $pubIsInUse;
if (!(typeof klevu_uc_productCustomizations === "function" && typeof klevu_uc_productCustomizations.nodeType !== "number")) {
function klevu_uc_productCustomizations(product) {
if (klevu_pubIsInUse) {
Expand Down