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 1 commit
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
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
34 changes: 34 additions & 0 deletions src/scripts/slate/cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Cart Template Script
* ------------------------------------------------------------------------------
* A file that contains scripts highly couple code to the Cart template.
*
* @namespace cart
*/

slate.cart = {

selectors: {
cartEmpty: '.cart--empty',
cartNoCookies: 'cart--no-cookies'
},

checkCookies: function() {
if (!this.cookiesEnabled()) {
$(this.selectors.cartEmpty).addClass(this.selectors.cartNoCookies);
}
},

/**
* 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;
}
};
4 changes: 4 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,7 @@ $(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.

slate.cart.checkCookies();
});
20 changes: 20 additions & 0 deletions src/styles/modules/cart.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*================ Cart Template ================*/
.cart__empty {
display: none;

.cart--empty & {
display: block;
}

.cart--no-cookies & {
display: none;
}
}

.cart__no-cookies {
display: none;

.cart--no-cookies & {
display: block;
}
}
1 change: 1 addition & 0 deletions src/styles/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
@import url('global/blank-states.scss');

/*================ MODULES ================*/
@import url('modules/cart.scss');
@import url('modules/site-header.scss');
@import url('modules/gift-card-template.scss');
21 changes: 18 additions & 3 deletions src/templates/cart.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,22 @@
<input type="submit" name="checkout" class="btn" value="{{ 'cart.general.checkout' | t }}">
</form>
{% else %}
<h1>{{ 'cart.general.title' | t }}</h1>
<p>{{ 'cart.general.empty' | t }}</p>
<p>{{ 'cart.general.continue_browsing_html' | t }}</p>
<div class="cart--empty">
<h1>{{ 'cart.general.title' | t }}</h1>

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

{% comment %}
Cart Empty State
{% endcomment %}
<div class="cart__empty">
<p>{{ 'cart.general.empty' | t }}</p>
<p>{{ 'cart.general.continue_browsing_html' | t }}</p>
</div>
</div>
{% endif %}