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

Commit

Permalink
SHOP-1497 : Display error message when total cart amount is greater t…
Browse files Browse the repository at this point in the history
…han max checkout amount (#177)

## JIRA Ticket

[SHOP-1497](https://youcanshop.atlassian.net/browse/SHOP-1497)

## QA Steps

-  [ ] `pnpm i`
-  [ ] `pnpm dev`

## Note

Leave empty when you have nothing to say


[SHOP-1497]:
https://youcanshop.atlassian.net/browse/SHOP-1497?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
elhassantouza authored May 9, 2024
1 parent a6171d5 commit 0aa022f
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 @@ -338,3 +338,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 0aa022f

Please sign in to comment.