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

Inventory status block #1979

Merged
merged 55 commits into from Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
28ce656
Add inventory status block
Sep 19, 2022
31a7a62
Add inventory status block
eugenekasimov Sep 20, 2022
4abe91b
Make threshold in %
eugenekasimov Sep 22, 2022
c16dfd2
Replace range with input number for threshold. Delete percentage
eugenekasimov Sep 23, 2022
205cfa3
Hide inventory status if there is no stock or varian does not exist
eugenekasimov Sep 29, 2022
c0352d2
Change input number to range
eugenekasimov Sep 29, 2022
ae96b0e
Change status icons. Refactor liquid code.
eugenekasimov Sep 29, 2022
a31ca80
Add locales. Show inventory quantity with disabled JS. Add inventory …
eugenekasimov Sep 29, 2022
c21413f
Minor changes in css
eugenekasimov Sep 30, 2022
7e141aa
Update locales. Minor changes in featured-product.
eugenekasimov Sep 30, 2022
61cab11
Merge branch 'main' into inventory-status-block
eugenekasimov Sep 30, 2022
72396e7
Minor changes in locales
eugenekasimov Sep 30, 2022
5493fac
Change approach in JS to better reuse existing functions
eugenekasimov Oct 1, 2022
ac88a5f
Remove whitespaces in liquid
eugenekasimov Oct 1, 2022
ce1d908
Minor changes in liquid
eugenekasimov Oct 1, 2022
e374ff7
Refactor code
eugenekasimov Oct 5, 2022
2155480
Chnage .hidden to .visually-hidden. Add aria-hidden attribute.
eugenekasimov Oct 6, 2022
195efcb
Add role presentation for svg
eugenekasimov Oct 6, 2022
0e4d858
Add In Stock for inventory_policy. Refactor code.
eugenekasimov Oct 7, 2022
a65035c
Merge branch 'main' into inventory-status-block
eugenekasimov Oct 7, 2022
d0fba5a
Refactor code. Minor changes in css and JS. Add logic for no-JS case.
eugenekasimov Oct 17, 2022
60f9a3e
Remove Inventory block from Featured product.
eugenekasimov Oct 18, 2022
2b5aebc
Merge branch 'main' into inventory-status-block
eugenekasimov Oct 18, 2022
0593c44
Delete unnecessary code for Featured product from locales
eugenekasimov Oct 18, 2022
7e128b7
Add comment to css. Delete empty line in JS.
eugenekasimov Oct 18, 2022
fcfd6f9
Add Out of stock status.
eugenekasimov Oct 18, 2022
a7af905
Delete unnecessary part of code in JS since we added Out-of-stock sta…
eugenekasimov Oct 18, 2022
16b4e29
Update 2 translation files
translation-platform[bot] Oct 19, 2022
0349d17
Update 1 translation file
translation-platform[bot] Oct 19, 2022
23428cc
Update 21 translation files
translation-platform[bot] Oct 19, 2022
d1613e8
Merge branch 'main' into inventory-status-block
eugenekasimov Oct 19, 2022
5298f02
Update 1 translation file
translation-platform[bot] Oct 19, 2022
59a5eb9
Update 10 translation files
translation-platform[bot] Oct 19, 2022
2f6bfb7
Update 21 translation files
translation-platform[bot] Oct 20, 2022
0579422
Update 7 translation files
translation-platform[bot] Oct 20, 2022
12b2a1e
Update 2 translation files
translation-platform[bot] Oct 20, 2022
21b9028
Update 5 translation files
translation-platform[bot] Oct 20, 2022
ae09d94
Update 1 translation file
translation-platform[bot] Oct 20, 2022
8b721ff
Add condition for no-track-quantity. Remove inventory status from no-…
eugenekasimov Oct 20, 2022
1378c49
Delete doubled line of code
eugenekasimov Oct 20, 2022
81f2f77
Update 1 translation file
translation-platform[bot] Oct 21, 2022
1180fbe
Delete whitespace. Minor refactor in Liquid.
eugenekasimov Oct 21, 2022
7594b1c
Merge branch 'main' into inventory-status-block
eugenekasimov Oct 21, 2022
9cec4de
Merge branch 'main' into inventory-status-block
eugenekasimov Oct 24, 2022
a699366
Merge branch 'main' into inventory-status-block
eugenekasimov Oct 24, 2022
d8e5165
Change a condition in Liquid when inventory quantity < 0
eugenekasimov Oct 24, 2022
8e3b06f
Add separate string for inventopry_out_of_stock_continue_selling
eugenekasimov Oct 24, 2022
c371fe2
Update 1 translation file
translation-platform[bot] Oct 25, 2022
f730ed9
Update 21 translation files
translation-platform[bot] Oct 25, 2022
9f78bc7
Minor refactor in JS
eugenekasimov Oct 25, 2022
de06ded
Update 3 translation files
translation-platform[bot] Oct 26, 2022
663c0eb
Fix conflicts
eugenekasimov Oct 26, 2022
0950d46
Replace role=presentation with aria-hidden=true
eugenekasimov Oct 26, 2022
9a6d32c
Update 5 translation files
translation-platform[bot] Oct 26, 2022
a57786f
Merge branch 'main' into inventory-status-block
eugenekasimov Oct 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions assets/global.js
Expand Up @@ -859,8 +859,11 @@ class VariantSelects extends HTMLElement {
const skuDestination = document.getElementById(`Sku-${this.dataset.section}`);
const variantPickerDestination = document.getElementById(`variant-radios-${this.dataset.section}`) || document.getElementById(`variant-selects-${this.dataset.section}`);
const variantPickerSource = html.getElementById(`variant-radios-${this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section}`) || html.getElementById(`variant-selects-${this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section}`);
const inventorySource = html.getElementById(`Inventory-${this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section}`);
const inventoryDestination = document.getElementById(`Inventory-${this.dataset.section}`);

if (source && destination) destination.innerHTML = source.innerHTML;
if (inventorySource && inventoryDestination) inventoryDestination.innerHTML = inventorySource.innerHTML;
if (variantPickerSource && variantPickerDestination) variantPickerDestination.innerHTML = variantPickerSource.innerHTML;
if (skuSource && skuDestination) {
skuDestination.innerHTML = skuSource.innerHTML;
Expand All @@ -871,6 +874,8 @@ class VariantSelects extends HTMLElement {

if (price) price.classList.remove('visibility-hidden');

if (inventoryDestination) inventoryDestination.classList.toggle('visibility-hidden', inventorySource.innerText === '');

this.toggleAddButton(!this.currentVariant.available, window.variantStrings.soldOut);

document.querySelector('variant-radios') ? this.querySelector(`[for="${activeElementId}"]`).focus() : this.querySelector(`#${activeElementId}`).focus();
Expand Down Expand Up @@ -900,11 +905,13 @@ class VariantSelects extends HTMLElement {
const addButton = button.querySelector('[name="add"]');
const addButtonText = button.querySelector('[name="add"] > span');
const price = document.getElementById(`price-${this.dataset.section}`);
const inventory = document.getElementById(`Inventory-${this.dataset.section}`);
const sku = document.getElementById(`Sku-${this.dataset.section}`);

if (!addButton) return;
addButtonText.textContent = window.variantStrings.unavailable;
if (price) price.classList.add('visibility-hidden');
if (inventory) inventory.classList.add('visibility-hidden');
if (sku) sku.classList.add('visibility-hidden');
}

Expand Down
21 changes: 21 additions & 0 deletions assets/section-main-product.css
Expand Up @@ -1286,6 +1286,27 @@ a.product__text {
flex-shrink: 0;
}

/* Inventory status */

.product__inventory {
display: flex;
align-items: center;
gap: 0.5rem;
}

.product--no-media .product__inventory {
justify-content: center;
}

/* This keeps the container from getting display: none; applied to it and to make sure we're not introducing some layout shift when switching to an unavailable variant */
.product__inventory.visibility-hidden:empty {
display: block;
}

.product__inventory.visibility-hidden:empty::after {
content: "#";
}
ludoboludo marked this conversation as resolved.
Show resolved Hide resolved

/* Icon with text */
.icon-with-text {
--icon-size: calc(var(--font-heading-scale) * 3rem);
Expand Down
6 changes: 6 additions & 0 deletions locales/bg-BG.json
Expand Up @@ -153,6 +153,12 @@
"choose_product_options": "Изберете опции за {{ product_name }}",
"value_unavailable": "{{ option_value }} [Неналично]",
"variant_sold_out_or_unavailable": "Вариантът е изчерпан или неналичен.",
"inventory_in_stock": "В наличност",
"inventory_in_stock_show_count": "{{ quantity }} в наличност",
"inventory_low_stock": "Ниски наличности",
"inventory_low_stock_show_count": "Ниски наличности: остават {{ quantity }}",
"inventory_out_of_stock": "Изчерпано количество",
"inventory_out_of_stock_continue_selling": "В наличност",
"sku": "SKU"
},
"modal": {
Expand Down
8 changes: 7 additions & 1 deletion locales/cs.json
Expand Up @@ -155,7 +155,13 @@
"choose_product_options": "Zvolte možnosti pro: {{ product_name }}",
"value_unavailable": "{{ option_value }} [nedostupné]",
"variant_sold_out_or_unavailable": "Vyprodaná nebo nedostupná varianta",
"sku": "SKU"
"inventory_in_stock": "Skladem",
"inventory_in_stock_show_count": "{{ quantity }} skladem",
"inventory_low_stock": "Skladové zásoby docházejí",
"inventory_low_stock_show_count": "Skladové zásoby docházejí, zbývající množství: {{ quantity }}",
"inventory_out_of_stock": "Není skladem",
"sku": "SKU",
"inventory_out_of_stock_continue_selling": "Skladem"
},
"modal": {
"label": "Galerie multimédií"
Expand Down
24 changes: 24 additions & 0 deletions locales/cs.schema.json
Expand Up @@ -1830,6 +1830,30 @@
}
}
}
},
"inventory": {
"name": "Stav skladových zásob",
"settings": {
"text_style": {
"label": "Textový styl",
"options__1": {
"label": "Hlavní část"
},
"options__2": {
"label": "Podtitul"
},
"options__3": {
"label": "Velká písmena"
}
},
"inventory_threshold": {
"label": "Práh docházejících skladových zásob",
"info": "Zvolte 0, pokud chcete vždy zobrazoval stav Skladem, když je zboží k dispozici."
},
"show_inventory_quantity": {
"label": "Zobrazovat objem skladových zásob"
}
}
}
},
"settings": {
Expand Down
6 changes: 6 additions & 0 deletions locales/da.json
Expand Up @@ -153,6 +153,12 @@
"choose_product_options": "Vælg muligheder for {{ product_name }}",
"value_unavailable": "{{ option_value }} [Utilgængelig]",
"variant_sold_out_or_unavailable": "Varianten er udsolgt eller utilgængelig",
"inventory_in_stock": "På lager",
"inventory_in_stock_show_count": "{{ quantity }} på lager",
"inventory_low_stock": "Lav lagerbeholdning",
"inventory_low_stock_show_count": "Lav lagerbeholdning: {{ quantity }} tilbage",
"inventory_out_of_stock": "Ikke på lager",
"inventory_out_of_stock_continue_selling": "På lager",
"sku": "SKU"
},
"modal": {
Expand Down
24 changes: 24 additions & 0 deletions locales/da.schema.json
Expand Up @@ -1830,6 +1830,30 @@
}
}
}
},
"inventory": {
"name": "Lagerstatus",
"settings": {
"text_style": {
"label": "Teksttypografi",
"options__1": {
"label": "Brødtekst"
},
"options__2": {
"label": "Underoverskrift"
},
"options__3": {
"label": "Store bogstaver"
}
},
"inventory_threshold": {
"label": "Lav grænse for lagerbeholdning",
"info": "Vælg 0 for altid at vise på lager, hvis tilgængelig."
},
"show_inventory_quantity": {
"label": "Vis lagerantal"
}
}
}
},
"settings": {
Expand Down
6 changes: 6 additions & 0 deletions locales/de.json
Expand Up @@ -153,6 +153,12 @@
"choose_product_options": "Optionen für {{ product_name }} auswählen",
"value_unavailable": "{{ option_value }} [Nicht verfügbar]",
"variant_sold_out_or_unavailable": "Variante ausverkauft oder nicht verfügbar",
"inventory_in_stock": "Auf Lager",
"inventory_in_stock_show_count": "{{ quantity }} auf Lager",
"inventory_low_stock": "Niedriger Lagerbestand",
"inventory_low_stock_show_count": "Niedriger Lagerbestand: {{ quantity }} verbleibend",
"inventory_out_of_stock": "Nicht vorrätig",
"inventory_out_of_stock_continue_selling": "Auf Lager",
"sku": "SKU"
},
"modal": {
Expand Down
24 changes: 24 additions & 0 deletions locales/de.schema.json
Expand Up @@ -1829,6 +1829,30 @@
}
}
}
},
"inventory": {
"name": "Inventarstatus",
"settings": {
"text_style": {
"label": "Textstil",
"options__1": {
"label": "Nachricht"
},
"options__2": {
"label": "Untertitel"
},
"options__3": {
"label": "Großbuchstaben"
}
},
"inventory_threshold": {
"label": "Geringer Inventarschwellenwert",
"info": "Wähle 0 aus, um immer den Lagerbestand anzuzeigen, falls verfügbar."
},
"show_inventory_quantity": {
"label": "Inventar anzeigen"
}
}
}
},
"settings": {
Expand Down
6 changes: 6 additions & 0 deletions locales/el.json
Expand Up @@ -153,6 +153,12 @@
"choose_product_options": "Ορίστε επιλογές για {{ product_name }}",
"value_unavailable": "{{ option_value }} [Μη διαθέσιμο]",
"variant_sold_out_or_unavailable": "Η παραλλαγή εξαντλήθηκε ή δεν είναι διαθέσιμη",
"inventory_in_stock": "Σε απόθεμα",
"inventory_in_stock_show_count": "{{ quantity }} σε απόθεμα",
"inventory_low_stock": "Χαμηλό απόθεμα",
"inventory_low_stock_show_count": "Χαμηλό απόθεμα: Απομένουν {{ quantity }}",
"inventory_out_of_stock": "Χωρίς απόθεμα",
"inventory_out_of_stock_continue_selling": "Σε απόθεμα",
"sku": "SKU"
},
"modal": {
Expand Down
6 changes: 6 additions & 0 deletions locales/en.default.json
Expand Up @@ -108,6 +108,12 @@
"choose_options": "Choose options",
"choose_product_options": "Choose options for {{ product_name }}",
"description": "Description",
"inventory_in_stock": "In stock",
"inventory_in_stock_show_count": "{{ quantity }} in stock",
"inventory_low_stock": "Low stock",
"inventory_low_stock_show_count": "Low stock: {{ quantity }} left",
eugenekasimov marked this conversation as resolved.
Show resolved Hide resolved
"inventory_out_of_stock": "Out of stock",
"inventory_out_of_stock_continue_selling": "In stock",
"sku": "SKU",
"on_sale": "Sale",
"product_variants": "Product variants",
Expand Down
24 changes: 24 additions & 0 deletions locales/en.default.schema.json
Expand Up @@ -1662,6 +1662,30 @@
"price": {
"name": "Price"
},
"inventory": {
"name": "Inventory status",
"settings": {
"text_style": {
"label": "Text style",
"options__1": {
"label": "Body"
},
"options__2": {
"label": "Subtitle"
},
"options__3": {
"label": "Uppercase"
}
},
"inventory_threshold": {
"label": "Low inventory threshold",
"info": "Choose 0 to always show in stock if available."
},
"show_inventory_quantity": {
"label": "Show inventory count"
}
}
},
eugenekasimov marked this conversation as resolved.
Show resolved Hide resolved
"quantity_selector": {
"name": "Quantity selector"
},
Expand Down
6 changes: 6 additions & 0 deletions locales/es.json
Expand Up @@ -154,6 +154,12 @@
"choose_product_options": "Elegir opciones para {{ product_name }}",
"value_unavailable": "{{ option_value }} (no disponible)",
"variant_sold_out_or_unavailable": "Variante agotada o no disponible",
"inventory_in_stock": "En existencias",
"inventory_in_stock_show_count": "{{ quantity }} en existencias",
"inventory_low_stock": "Bajas existencias",
"inventory_low_stock_show_count": "Bajas existencias: quedan {{ quantity }}",
"inventory_out_of_stock": "Agotado",
"inventory_out_of_stock_continue_selling": "En existencias",
"sku": "SKU"
},
"modal": {
Expand Down
24 changes: 24 additions & 0 deletions locales/es.schema.json
Expand Up @@ -1830,6 +1830,30 @@
}
}
}
},
"inventory": {
"name": "Estado del inventario",
"settings": {
"text_style": {
"label": "Estilo de texto",
"options__1": {
"label": "Cuerpo"
},
"options__2": {
"label": "Subtítulo"
},
"options__3": {
"label": "Mayúscula"
}
},
"inventory_threshold": {
"label": "Umbral de inventario bajo",
"info": "Elige 0 para que siempre se muestre en existencias si está disponible."
},
"show_inventory_quantity": {
"label": "Mostrar recuento de inventario"
}
}
}
},
"settings": {
Expand Down
8 changes: 7 additions & 1 deletion locales/fi.json
Expand Up @@ -153,7 +153,13 @@
"choose_product_options": "Valitse vaihtoehtoja tuotteelle {{ product_name }}",
"value_unavailable": "{{ option_value }} [ei saatavilla]",
"variant_sold_out_or_unavailable": "Versio on loppuunmyyty tai ei saatavilla",
"sku": "SKU-koodi"
"inventory_in_stock": "Varastossa",
"inventory_in_stock_show_count": "{{ quantity }} varastossa",
"inventory_low_stock": "Varasto vähissä",
"inventory_low_stock_show_count": "Varasto vähissä: {{ quantity }} jäljellä",
"inventory_out_of_stock": "Loppunut varastosta",
"sku": "SKU-koodi",
"inventory_out_of_stock_continue_selling": "Varastossa"
},
"modal": {
"label": "Mediagalleria"
Expand Down
24 changes: 24 additions & 0 deletions locales/fi.schema.json
Expand Up @@ -1829,6 +1829,30 @@
}
}
}
},
"inventory": {
"name": "Varaston tila",
"settings": {
"text_style": {
"label": "Tekstityyli",
"options__1": {
"label": "Leipäteksti"
},
"options__2": {
"label": "Alaotsikko"
},
"options__3": {
"label": "Isot kirjaimet"
}
},
"inventory_threshold": {
"label": "Vähäisen varaston kynnysarvo",
"info": "Valitse 0, jos haluat näyttää aina varastossa, jos saatavilla."
},
"show_inventory_quantity": {
"label": "Näytä varastomäärä"
}
}
}
},
"settings": {
Expand Down
8 changes: 7 additions & 1 deletion locales/fr.json
Expand Up @@ -154,7 +154,13 @@
"choose_product_options": "Choisir des options pour {{ product_name }}",
"value_unavailable": "{{ option_value }} [Indisponible]",
"variant_sold_out_or_unavailable": "Variante épuisée ou indisponible",
"sku": "SKU"
"inventory_in_stock": "En stock",
"inventory_in_stock_show_count": "{{ quantity }} en stock",
"inventory_low_stock": "Stock bas",
"inventory_low_stock_show_count": "Stock bas : {{ quantity }} restant(s)",
"sku": "SKU",
"inventory_out_of_stock": "En rupture de stock",
"inventory_out_of_stock_continue_selling": "En stock"
},
"modal": {
"label": "Galerie de supports multimédias"
Expand Down