Hello everyone,
Can someone please help me with a code that fits the Motion theme so that the inventory stock warning can display on each product rather than just our products that have reviews like Amazon does.
Hi! Yes, this is possible in Motion ![]()
You donāt need reviews for this ā you can show a low stock / inventory warning on every product using Shopifyās inventory data.
Below is a Motion-theme friendly solution.
Go to:
Online Store ā Themes ā ⦠ā Edit code
Open:
sections/main-product.liquidsnippets/product-form.liquid)Find where the product price or variant info is shown, and add this below it
{% if product.selected_or_first_available_variant.inventory_management == 'shopify' %}
{% assign stock = product.selected_or_first_available_variant.inventory_quantity %}
{% if stock > 0 and stock <= 10 %}
<p class="inventory-warning">
ā ļø Only {{ stock }} left in stock ā order soon
</p>
{% elsif stock <= 0 %}
<p class="inventory-warning sold-out">
ā Out of stock
</p>
{% endif %}
{% endif %}
You can change 10 to any threshold you like.
Regards
Titu
I received an error message of āFileSaveError: Invalid JSON in tag āschemaā"
Hi @yonicque
Okay, please send me the store URL and the collaborator code.
I will check everything and then update you properly.
Best regards,
Devcoder ![]()
Iām sorry, I donāt feel comfortable doing that. However, I can place the code in myself. Thank you for your assistance.
Can you share the code for the cart page (preferably from the product title to the button) here? I donāt have any customers with the Motion theme, which is why Iām asking. There are variables here that will carry over; before they become incorrect, Iād rather see the code first.
.cart-inventory-warning {
margin-top: 6px;
font-size: 13px;
font-weight: 500;
color: #8b0000;
letter-spacing: 0.2px;
}
Hi @yonicque ,
Your theme is paid, so we canāt access it exactly to do a plug an play code. However, this is what you should do:
1- go to the cart template in your code
2- go to the main block and find the for loop that iterates over the items.
3 - add this inside of the loop (depending on what you theme uses, this might be slightly different)
<p style="margin-top:6px;font-size:13px;font-weight:500;color:#8b0000;letter-spacing:0.2px;">
Only {{ item.variant.inventory_quantity }} left in stock
</p>
Please let me know if that works or if you need additional help!
Regards,
Rodrigo
This is a regular product
This is the product with a review.
This is the script JudgeMe app used to add it. But even theres will not count the inventory
Can you share the code of you cart here please?
The variable {{item.variant.inventory_quantity }} has to be changed to what you have in the for loop inside of your cart.
{{ item.variant.inventory_quantity }} Low Premium Stock
Buy Now
{%- render ābreadcrumbsā -%}
<h1 class="section-header__title">{{ 'cart.general.title' | t }}</h1>
<div class="rte text-spacing">
<p>{{ 'cart.general.continue_browsing_html' | t: url: routes.all_products_collection_url }}</p>
</div>
<p>{{ 'cart.general.empty' | t }}</p>
{%- if cart.item_count > 0 -%}
<form action="{{ routes.cart_url }}" method="post" novalidate data-location="page" id="CartPageForm">
<div class="cart__item cart__item--headers small--hide">
<div class="cart__item--details">
<div class="cart__item--qty">{{ 'cart.label.quantity' | t }}</div>
<div class="cart__item--price text-right">{{ 'cart.label.total' | t }}</div>
</div>
</div>
{{ item.variant.inventory_quantity }} Low Premium Stock
Buy Now
<div data-products>
{%- for item in cart.items -%}
{%- render 'cart-item', product: item, sizeVariable: '150px', fallback: '90px', -%}
{%- endfor -%}
</div>
<div class="cart__footer">
<div class="grid">
{%- if settings.cart_notes_enable -%}
<div class="grid__item medium-up--one-half">
<label for="CartNote">{{ 'cart.general.note' | t }}</label>
<textarea name="note" class="input-full cart-notes" id="CartNote">{{ cart.note }}</textarea>
</div>
{%- endif -%}
<div class="grid__item medium-up--one-half text-center medium-up--text-right{% unless settings.cart_notes_enable %} medium-up--push-one-half{% endunless %}">
<div data-discounts>
{% if cart.cart_level_discount_applications != blank %}
<div class="cart__item-sub cart__item-row">
<div>{{ 'cart.general.discounts' | t }}</div>
<div class="text-right">
{% for cart_discount in cart.cart_level_discount_applications %}
<div>
{{ cart_discount.title }} (-{{ cart_discount.total_allocated_amount | money }})
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
<div class="cart__item-sub cart__item-row">
<div class="cart__subtotal">{{ 'cart.general.subtotal' | t }}</div>
<div data-subtotal>{{ cart.total_price | money }}</div>
</div>
{%- assign cartTotalDiscounts = cart.total_discounts | money -%}
<div class="cart__item-row cart__savings {% unless cart.total_discounts > 0%} hide{% endunless %}" data-savings>
{{ 'cart.general.savings_html' | t: savings: cartTotalDiscounts }}
</div>
<div class="cart__item-row ajaxcart__note">
<small>
{{ 'cart.general.shipping_at_checkout' | t }}<br />
</small>
</div>
{%- if settings.cart_terms_conditions_enable -%}
<div class="cart__item-row cart__terms cart__terms--right">
<input type="checkbox" id="CartTerms" class="cart__terms-checkbox">
<label for="CartTerms">
{% if settings.cart_terms_conditions_page != blank %}
{{ 'cart.general.terms_html' | t: url: settings.cart_terms_conditions_page.url }}
{% else %}
{{ 'cart.general.terms' | t }}
{% endif %}
</label>
</div>
{%- endif -%}
<div class="cart__checkout-wrapper">
<button type="submit" name="checkout" {% if settings.cart_terms_conditions_enable %} data-terms="CartPageAgree"{% endif %} class="btn btn--no-animate cart__checkout">
{{ 'cart.general.checkout' | t }}
</button>
{%- if additional_checkout_buttons and settings.cart_additional_buttons -%}
<div class="additional-checkout-buttons additional-checkout-buttons--vertical">{{ content_for_additional_checkout_buttons }}</div>
{%- endif -%}
</div>
</div>
</div>
</div>
</form>
{%- endif -%}
{% schema %}
{
ānameā: āt:sections.main-cart.nameā
}
{% endschema %}
Try to add it here:
{%- for item in cart.items -%}
{%- render 'cart-item', product: item, sizeVariable: '150px', fallback: '90px', -%}
āāADD HERE
{%- endfor -%}
We are on the right track, but how do we get it to show with the title box like this product when added: Shop Yonicque | #1 Trendy Online Boutique | United States of America to the cart??
off sitewide
July sale ā 45% off at checkout, applied automatically. Valid for 60 minutes. One per customer.
Offer ends in