From 1d42a9030841c8178e621a0f59b3dbe5c88bd4f2 Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Thu, 5 Dec 2024 16:00:29 +0100 Subject: [PATCH] Style product availability --- _dev/css/components/products.scss | 23 ++++++++----- .../catalog/_partials/product-add-to-cart.tpl | 33 ++++++++++++++----- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/_dev/css/components/products.scss b/_dev/css/components/products.scss index 5ca2dc1e..57a1bede 100644 --- a/_dev/css/components/products.scss +++ b/_dev/css/components/products.scss @@ -621,20 +621,27 @@ margin-top: 0.625rem; font-weight: 700; - .material-icons { - line-height: inherit; + .alert { + font-size: 1rem; } - .product-available { - color: $brand-success; + .alert-content-wrapper { + display: flex; + gap: 0.75rem; } - .product-unavailable { - color: $brand-warning; + /* Reset some of the general styles on alert warning */ + .alert-warning { + color: #664d03; + background-color: #fff3cd; + border-color: #ffecb5; } - .product-last-items { - color: $brand-warning; + .alert-warning .material-icons { + padding-top: 0; + margin-right: 0; + font-size: 24px; + color: #664d03; } } diff --git a/templates/catalog/_partials/product-add-to-cart.tpl b/templates/catalog/_partials/product-add-to-cart.tpl index 2e513129..74d93139 100644 --- a/templates/catalog/_partials/product-add-to-cart.tpl +++ b/templates/catalog/_partials/product-add-to-cart.tpl @@ -66,18 +66,35 @@ {/block} {block name='product_availability'} - +
{if $product.show_availability && $product.availability_message} - {if $product.availability == 'available'} - - {elseif $product.availability == 'last_remaining_items'} - + + {** First, we prepare the icons and colors we want to use *} + {if $product.availability == 'in_stock'} + {assign 'availability_icon' 'E5CA'} + {assign 'availability_color' 'success'} + {elseif $product.availability == 'available' || $product.availability == 'last_remaining_items'} + {assign 'availability_icon' 'E002'} + {assign 'availability_color' 'warning'} {else} - + {assign 'availability_icon' 'E14B'} + {assign 'availability_color' 'danger'} {/if} - {$product.availability_message} + + {** And render the availability message with icon *} + {/if} - +
{/block} {block name='product_minimal_quantity'}