Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #212 from youcan-shop/SHOP-1497
Browse files Browse the repository at this point in the history
SHOP-1497 : Display error message when total cart amount is greater than max checkout amount
  • Loading branch information
elhassantouza authored May 9, 2024
2 parents cbf8398 + 70dd528 commit 7e29762
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions assets/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,22 @@ function processVideoSections() {
}

processVideoSections();

function decodeHtmlEntities(text) {
let textarea = document.createElement('textarea');
textarea.innerHTML = text;

return textarea.value;
}

function renderTextContent(htmlContent) {
let tempElement = document.createElement('div');
tempElement.innerHTML = htmlContent;

return tempElement.innerText || tempElement.textContent;
}

if (FORM.errors) {
let decodedText = decodeHtmlEntities(FORM.errors);
notify(renderTextContent(decodedText), 'error', 20000);
}
6 changes: 6 additions & 0 deletions layouts/theme.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
{% section 'main-footer' %}
{%- render 'cart-drawer' -%}

{% javascript %}
const FORM = {
errors: '{{ form.errors | first }}',
}
{% endjavascript %}

{{ 'main.js' | asset_url | script_tag }}
</body>
</html>

0 comments on commit 7e29762

Please sign in to comment.