Motion Theme - Cart Inventory

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 :+1:
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.


:wrench: Step 1: Add the inventory message (Liquid)

Go to:
Online Store → Themes → … → Edit code

Open:

  • sections/main-product.liquid
    (or in older Motion versions: snippets/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’"

Also, I only want it to show in the cart page. We already have it reflecting on the product page. Please see image.

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 :laptop:

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

Its there but its not counting the stock. How can we get it to show the quantity?

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 :alarm_clock: 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 :alarm_clock: 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??