Skip to content
This repository was archived by the owner on Jul 19, 2021. It is now read-only.

Add cart cookies disabled message #101

Merged
merged 3 commits into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions src/layout/theme.liquid
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!doctype html>
<!--[if IE 9]> <html class="ie9 no-js" lang="{{ shop.locale }}"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js" lang="{{ shop.locale }}"> <!--<![endif]-->
<!--[if IE 9]> <html class="ie9 no-js no-cookies" lang="{{ shop.locale }}"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js no-cookies" lang="{{ shop.locale }}"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"update": "Einkaufswagen aktualisieren",
"checkout": "Zur Kasse",
"empty": "Ihr Einkaufswagen ist im Moment leer.",
"cookies_required": "Aktivieren Sie Cookies, um den Einkaufswagen benutzen zu können",
"continue_browsing_html": "Mit der Suche <a href=\"/collections/all\">hier</a> fortfahren.",
"item_quantity": "Produktmenge",
"savings": "Sie sparen"
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"update": "Update Cart",
"checkout": "Check Out",
"empty": "Your cart is currently empty.",
"cookies_required": "Enable cookies to use the shopping cart",
"continue_browsing_html": "Continue browsing <a href=\"/collections/all\">here</a>.",
"item_quantity": "Item quantity",
"savings": "You're saving"
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"update": "Actualizar carrito",
"checkout": "Finalizar pedido",
"empty": "Su carrito actualmente está vacío.",
"cookies_required": "Habilite las cookies para usar el carrito de compras",
"continue_browsing_html": "Continúe explorando <a href=\"/collections/all\">aquí</a>.",
"item_quantity": "Cantidad de artículo",
"savings": "Está ahorrando"
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"update": "Mettre à jour",
"checkout": "Procéder au paiement",
"empty": "Votre panier est vide.",
"cookies_required": "Activer les cookies pour utiliser le panier",
"continue_browsing_html": "<a href=\"/collections/all\">Retourner au magasinage</a>.",
"item_quantity": "Quantité de l'article",
"savings": "Vous économisez"
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"update": "Atualizar Carrinho",
"checkout": "Fechar pedido",
"empty": "Seu carrinho está vazio no momento.",
"cookies_required": "Habilite os cookies para usar o carrinho de compras",
"continue_browsing_html": "Continue navegando <a href=\"/collections/all\">aqui</a>.",
"item_quantity": "Quantidade de itens",
"savings": "Você está economizando"
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"update": "Atualizar Carrinho de Compras",
"checkout": "Check-Out",
"empty": "O seu carrinho de compras está neste momento vazio.",
"cookies_required": "Ative cookies para poder usar o carrinho de compras",
"continue_browsing_html": "Continue a ver <a href=\"/collections/all\">aqui</a>.",
"item_quantity": "Quantidade de itens",
"savings": "Está a poupar"
Expand Down
23 changes: 23 additions & 0 deletions src/scripts/slate/cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Cart Template Script
* ------------------------------------------------------------------------------
* A file that contains scripts highly couple code to the Cart template.
*
* @namespace cart
*/

slate.cart = {

/**
* Check if cookies are enabled in the browser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a small blurb in here that explains browser cookies are required to build a cart

*/
cookiesEnabled: function() {
var cookieEnabled = navigator.cookieEnabled;

if (!cookieEnabled){
document.cookie = 'testcookie';
cookieEnabled = (document.cookie.indexOf('testcookie') !== -1);
}
return cookieEnabled;
}
};
6 changes: 6 additions & 0 deletions src/scripts/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ window.theme = window.theme || {};

/*================ Slate ================*/
// =require slate/a11y.js
// =require slate/cart.js
// =require slate/utils.js
// =require slate/rte.js
// =require slate/sections.js
Expand Down Expand Up @@ -31,4 +32,9 @@ $(document).ready(function() {
// Wrap videos in div to force responsive layout.
slate.rte.wrapTable();
slate.rte.iframeReset();

// Add a message to the cart if cookies are disabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function won't directly display the message, that's taken care of by CSS. Suggested reword:

Apply a specific class to the html element for browser support of cookies.

if (slate.cart.cookiesEnabled()) {
document.documentElement.className = document.documentElement.className.replace('no-cookies', 'cookies');
}
});
16 changes: 16 additions & 0 deletions src/styles/global/helper-classes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@
}
}

// Only show when cookies are not supported
.no-cookies:not(html) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that a cookies class is too generic; however, we made a change in class names for our most recent theme along these lines already. To express support for JS in a class that made more sense we switched to: supports-js and supports-no-js.

Following the same logic:

// Only show when browser cookies are not supported
.supports-no-cookies:not(html) {
  display: none;
  
  html.supports-no-cookies & {
    display: block;
  }
}

// Only show when browser cookies are supported
.supports-cookies {
  html.supports-no-cookies & {
    display: none;
  }
}

display: none;

.no-cookies & {
display: block;
}
}

// Only show when cookies are supported
.cookies {
.no-cookies & {
display: none;
}
}

/*============================================================================
Skip to content button
- Overrides .visually-hidden when focused
Expand Down
17 changes: 15 additions & 2 deletions src/templates/cart.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@
</form>
{% else %}
<h1>{{ 'cart.general.title' | t }}</h1>
<p>{{ 'cart.general.empty' | t }}</p>
<p>{{ 'cart.general.continue_browsing_html' | t }}</p>

{% comment %}
Cart Empty State
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cart empty state

^ letter-casing

{% endcomment %}
<div class="cookies">
<p>{{ 'cart.general.empty' | t }}</p>
<p>{{ 'cart.general.continue_browsing_html' | t }}</p>
</div>

{% comment %}
Cart no cookies state
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a small blurb in here that explains browser cookies are required to build a cart

{% endcomment %}
<div class="no-cookies">
<p>{{ 'cart.general.cookies_required' | t }}</p>
</div>
{% endif %}