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 11 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
13 changes: 13 additions & 0 deletions assets/global.js
Expand Up @@ -849,12 +849,23 @@ class VariantSelects extends HTMLElement {
if (source && destination) destination.innerHTML = source.innerHTML;

eugenekasimov marked this conversation as resolved.
Show resolved Hide resolved
const price = document.getElementById(`price-${this.dataset.section}`);
const inventory = document.getElementById(`inventory-${this.dataset.section}`);

if (price) price.classList.remove('visibility-hidden');
if (inventory && inventory !== null) inventory.classList.remove('hidden'), this.updateInventory(html);
this.toggleAddButton(!this.currentVariant.available, window.variantStrings.soldOut);
});
}

updateInventory(html) {
const id = `inventory-${this.dataset.section}`;
const destination = document.getElementById(id);
const source = html.getElementById(id);

if (source && destination) destination.innerHTML = source.innerHTML;
if (source === null) destination.classList.add('hidden');
}

toggleAddButton(disable = true, text, modifyClass = true) {
const productForm = document.getElementById(`product-form-${this.dataset.section}`);
if (!productForm) return;
Expand All @@ -878,9 +889,11 @@ 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}`);
if (!addButton) return;
addButtonText.textContent = window.variantStrings.unavailable;
if (price) price.classList.add('visibility-hidden');
if (inventory) inventory.classList.add('hidden');
}

getVariantData() {
Expand Down
13 changes: 13 additions & 0 deletions assets/section-main-product.css
Expand Up @@ -1244,3 +1244,16 @@ a.product__text {
margin-left: 1.2rem;
flex-shrink: 0;
}

/* Inventory status */

.product__inventory {
display: flex;
flex-direction: row;
eugenekasimov marked this conversation as resolved.
Show resolved Hide resolved
align-items: center;
gap: 0.5rem;
}

.product--no-media .product__inventory {
justify-content: center;
}
4 changes: 4 additions & 0 deletions locales/en.default.json
Expand Up @@ -108,6 +108,10 @@
"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
"on_sale": "Sale",
"product_variants": "Product variants",
"media": {
Expand Down
48 changes: 48 additions & 0 deletions locales/en.default.schema.json
Expand Up @@ -773,6 +773,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": "Display Low inventory threshold",
"info": "Choose 0 to always show in stock if available."
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this info bit is actually useful 🤔 Maybe it's just me though 😅
Choose 0 to always show the status as 'in stock' if the variant is available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it seem too obvious for you? Is that what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just find it a bit confusing. I think the wording could be better. But maybe it's only confusing to me. cc: @YoannJailin

Choose a reason for hiding this comment

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

@ludoboludo how about this one?
« Shows low stock status when quantity is below the threshold. Choose 0 to always show in stock if the product is available. »
I wonder if it's not confusing to refer to the variant.

Copy link
Contributor

Choose a reason for hiding this comment

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

I even wonder if it needs help text ? Or maybe something to explain how this value they're using is used.
Anything below the threshold set will show a low stock status unless it's 0.

},
"show_inventory_quantity": {
"label": "Show inventory count"
}
}
},
"quantity_selector": {
"name": "Quantity selector"
},
Expand Down Expand Up @@ -1645,6 +1669,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": "Display 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