Pre-Order Text on Out-of-Stock Items

Solved

Pre-Order Text on Out-of-Stock Items

ChrisM187
Tourist
29 0 15

Hello, I am trying to add a text above the Add to Cart button on my products which says something along the lines of "Product out of stock, Pre-Order now" or something similar (would be great if it is editable). Also along it should have a Question mark where i can add a small pop up message explaining what pre-order means.
This message should only pop-up, when the selected Size / Variant of a product's stock is 0. When the product stock is above 0, I would also like to have a message above the Add to Cart Button saying "Delivery 2-6 days" (for example). Would that be possible through a easy code? I tried searching everywhere for answers but nothing worked for me..
I am using the Dawn theme.
here is an example of how it could look like:

ChrisM187_0-1726926252640.png

And the Question mark pop up text example: 

ChrisM187_1-1726926323952.png


Thank you in advance!
Website URL: trinitysneakers.com

Accepted Solutions (3)

BSS-TekLabs
Shopify Partner
2350 702 827

This is an accepted solution.

- Here is the solution for you @ChrisM187 
- Please follow these steps:
1. Go to Online Store --> Theme --> Edit code.
2. Open the main-product.liquid file, which is located under the Sections folder

- Locate the Add to Cart button: Look for the code that generates the Add to Cart button in the file. It will look something like this:

<button type="submit" class="button product-form__cart-submit">Add to Cart</button>

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

BSS-TekLabs
Shopify Partner
2350 702 827

This is an accepted solution.

-Add the dynamic message above the Add to Cart button: Insert this Liquid code above the button to dynamically display the "Pre-Order" or "Delivery" message based on the variant's stock quantity.

<!-- Dynamic Message Section -->
<div class="product-availability-message">
  {% if current_variant.inventory_quantity <= 0 %}
    <!-- Pre-Order Message for Out of Stock Products -->
    <div class="pre-order-message">
      <span>Product out of stock, Pre-Order now</span>
      <!-- Tooltip for explanation -->
      <a href="#" class="preorder-info" data-toggle="tooltip" title="This product is currently out of stock but can be pre-ordered. We'll ship it as soon as it's back in stock.">
        <span class="tooltip-icon">?</span>
      </a>
    </div>
  {% else %}
    <!-- Delivery Message for In Stock Products -->
    <div class="delivery-message">
      <span>Delivery 2-6 days</span>
    </div>
  {% endif %}
</div>

<!-- Add to Cart Button -->
<button type="submit" class="button product-form__cart-submit">Add to Cart</button>

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

BSS-TekLabs
Shopify Partner
2350 702 827

This is an accepted solution.

<!-- Optional: Add the tooltip CSS and JavaScript -->
<style>
  .tooltip-icon {
    border-radius: 50%;
    border: 1px solid #000;
    padding: 2px 5px;
    font-size: 0.8rem;
    cursor: pointer;
  }
  .pre-order-message, .delivery-message {
    margin-bottom: 10px; /* Space between message and button */
    font-weight: bold;
  }
</style>

<script>
  // Tooltip functionality
  document.addEventListener('DOMContentLoaded', function () {
    const tooltipElements = document.querySelectorAll('.preorder-info');

    tooltipElements.forEach(function (el) {
      el.addEventListener('mouseenter', function () {
        const title = this.getAttribute('title');
        const tooltip = document.createElement('div');
        tooltip.className = 'custom-tooltip';
        tooltip.innerText = title;
        document.body.appendChild(tooltip);

        tooltip.style.position = 'absolute';
        tooltip.style.left = `${this.getBoundingClientRect().left}px`;
        tooltip.style.top = `${this.getBoundingClientRect().top - tooltip.offsetHeight}px`;

        el.addEventListener('mouseleave', function () {
          tooltip.remove();
        });
      });
    });
  });
</script>

And add this code to top file

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

Replies 6 (6)

rajimulislamjoy
Shopify Partner
356 37 65

@ChrisM187  Hi! Yes, this is possible with a bit of custom Liquid code and JavaScript. You can conditionally display messages based on stock levels for your variants. I can help you implement this in the Dawn theme, including the editable 'Pre-Order' message with the question mark pop-up. 

Please don't forget to Like & Mark Solution to the post that helped you. Thanks!
If you'd like to support me, you can Buy Me a Coffee
Need a Shopify Designer or Dropshipping Expert ?
Hire us at WhatsApp! For Shopify Design | Shopify Customize | Dropshipping

BSS-TekLabs
Shopify Partner
2350 702 827

This is an accepted solution.

- Here is the solution for you @ChrisM187 
- Please follow these steps:
1. Go to Online Store --> Theme --> Edit code.
2. Open the main-product.liquid file, which is located under the Sections folder

- Locate the Add to Cart button: Look for the code that generates the Add to Cart button in the file. It will look something like this:

<button type="submit" class="button product-form__cart-submit">Add to Cart</button>

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
BSS-TekLabs
Shopify Partner
2350 702 827

This is an accepted solution.

-Add the dynamic message above the Add to Cart button: Insert this Liquid code above the button to dynamically display the "Pre-Order" or "Delivery" message based on the variant's stock quantity.

<!-- Dynamic Message Section -->
<div class="product-availability-message">
  {% if current_variant.inventory_quantity <= 0 %}
    <!-- Pre-Order Message for Out of Stock Products -->
    <div class="pre-order-message">
      <span>Product out of stock, Pre-Order now</span>
      <!-- Tooltip for explanation -->
      <a href="#" class="preorder-info" data-toggle="tooltip" title="This product is currently out of stock but can be pre-ordered. We'll ship it as soon as it's back in stock.">
        <span class="tooltip-icon">?</span>
      </a>
    </div>
  {% else %}
    <!-- Delivery Message for In Stock Products -->
    <div class="delivery-message">
      <span>Delivery 2-6 days</span>
    </div>
  {% endif %}
</div>

<!-- Add to Cart Button -->
<button type="submit" class="button product-form__cart-submit">Add to Cart</button>

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
BSS-TekLabs
Shopify Partner
2350 702 827

This is an accepted solution.

<!-- Optional: Add the tooltip CSS and JavaScript -->
<style>
  .tooltip-icon {
    border-radius: 50%;
    border: 1px solid #000;
    padding: 2px 5px;
    font-size: 0.8rem;
    cursor: pointer;
  }
  .pre-order-message, .delivery-message {
    margin-bottom: 10px; /* Space between message and button */
    font-weight: bold;
  }
</style>

<script>
  // Tooltip functionality
  document.addEventListener('DOMContentLoaded', function () {
    const tooltipElements = document.querySelectorAll('.preorder-info');

    tooltipElements.forEach(function (el) {
      el.addEventListener('mouseenter', function () {
        const title = this.getAttribute('title');
        const tooltip = document.createElement('div');
        tooltip.className = 'custom-tooltip';
        tooltip.innerText = title;
        document.body.appendChild(tooltip);

        tooltip.style.position = 'absolute';
        tooltip.style.left = `${this.getBoundingClientRect().left}px`;
        tooltip.style.top = `${this.getBoundingClientRect().top - tooltip.offsetHeight}px`;

        el.addEventListener('mouseleave', function () {
          tooltip.remove();
        });
      });
    });
  });
</script>

And add this code to top file

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
ChrisM187
Tourist
29 0 15

For a weird reason i can not find the add to cart button..

Sandy-Stoq
Shopify Partner
47 2 6

@ChrisM187 👋🏼 You can also do this more easily with a preorder app from App Store. Most - including ours - have a generous free plan and with them, you can - 

1. Make it very clear that customers are preordering the product by changing the 'Add to cart' button.
2. Add a disclaimer underneath so customers know what to expect with their preorder.
3. Add a badge on the products to distinguish them from regular in-stock items.

And you can do all of this across products and variants of products. Here's what ours looks like, and most apps will let you add some version of this to the product page with no coding. 🙂

Screenshot 2024-09-21 at 12.09.12 PM.png

STOQ: Recover lost sales with Back in stock alerts & Preorders


Filemonk: Sell digital products & downloads in 3 quick steps


- Check us out on App Store: STOQ
- Check us out on App Store: Filemonk