Shopify Product Page Modification
Budget: $30 – $250 USD
I need assistance with a specific aspect of my Shopify store - modifying product pages to integrate them with our inventory system.
Objective: Modify the stock status display logic on the product page in Shopify to accurately reflect the availability of stock considering incoming stock transfers.
Current Logic (Summary):
Retrieve the current date and the date of the next incoming stock transfer.
Calculate the difference in weeks between the current date and the next incoming date.
Determine if the product is in stock based on the current inventory and incoming stock.
Display appropriate messages based on the stock status.
Proposed Modifications:
Iterate through each incoming stock batch to collect the dates and quantities.
Calculate the combined inventory considering both the current inventory and total incoming quantities.
Determine the earliest incoming date from the collected dates.
If the combined inventory is zero or negative:
Check if there's an earliest incoming date.
If yes, display a "Ready to ship" message with the earliest incoming date.
If no, display a "Made to order" message with the standard lead time.
If the combined inventory is positive, display an "In stock" message.
Code Implementation (Summary):
Initialize variables for current date, incoming dates, incoming quantities, and combined inventory.
Iterate through incoming stock batches to collect dates and quantities.
Calculate combined inventory considering current inventory and total incoming quantities.
Determine the earliest incoming date.
Based on combined inventory and incoming dates:
Display appropriate stock status messages.
So here is the code we currently have that is working, it just doens't take into account if the next stock transfer date will also leave the product inveotry in a negative stock number that the next stock transfer that will bring the inventory into a positive stock number should be shown.
{% assign current_date = 'now' | date: '%s' %}
{% assign incoming_date = product.variants.first.next_incoming_date | date: '%s' %}
{% assign seconds_in_week = 604800 %}
{% if incoming_date != blank %}
{% assign difference_in_seconds = incoming_date | minus: current_date %}
{% assign weeks_until_ship = difference_in_seconds | divided_by: seconds_in_week | plus: 1 %}
{% assign formatted_incoming_date = product.variants.first.next_incoming_date | date: "%B %d, %Y" %}
{% assign combined_inventory = product.variants.first.inventory_quantity %}
{%- comment -%}
Loop through incoming stock batches to calculate the total incoming quantity.
{%- endcomment -%}
{% for stock_batch in product.variants.first.incoming_stock_batches %}
{% assign combined_inventory = combined_inventory | plus: stock_batch.quantity %}
{% endfor %}
{% if combined_inventory <= 0 %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px;">Ready to ship in approximately {{ weeks_until_ship | round }} weeks ({{formatted_incoming_date}}).</span>
{% else %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px; color: #228B22;">In stock and ready to ship now. More incoming stock due by {{ formatted_incoming_date }}.</span>
{% endif %}
{% elsif product.variants.first.inventory_quantity > 0 %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px; color: #228B22;">In stock and ready to ship now.</span>
{% else %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px;">Made to order. Current lead time 10-14 weeks.</span>
{% endif %}
ChatGPT
Objective: Modify the stock status display logic on the product page in Shopify to accurately reflect the availability of stock considering incoming stock transfers.
Current Logic (Summary):
Retrieve the current date and the date of the next incoming stock transfer.
Calculate the difference in weeks between the current date and the next incoming date.
Determine if the product is in stock based on the current inventory and incoming stock.
Display appropriate messages based on the stock status.
Proposed Modifications:
Iterate through each incoming stock batch to collect the dates and quantities.
Calculate the combined inventory considering both the current inventory and total incoming quantities.
Determine the earliest incoming date from the collected dates.
If the combined inventory is zero or negative:
Check if there's an earliest incoming date.
If yes, display a "Ready to ship" message with the earliest incoming date.
If no, display a "Made to order" message with the standard lead time.
If the combined inventory is positive, display an "In stock" message.
Code Implementation (Summary):
Initialize variables for current date, incoming dates, incoming quantities, and combined inventory.
Iterate through incoming stock batches to collect dates and quantities.
Calculate combined inventory considering current inventory and total incoming quantities.
Determine the earliest incoming date.
Based on combined inventory and incoming dates:
Display appropriate stock status messages.
So here is the code we currently have that is working, it just doens't take into account if the next stock transfer date will also leave the product inveotry in a negative stock number that the next stock transfer that will bring the inventory into a positive stock number should be shown.
{% assign current_date = 'now' | date: '%s' %}
{% assign incoming_date = product.variants.first.next_incoming_date | date: '%s' %}
{% assign seconds_in_week = 604800 %}
{% if incoming_date != blank %}
{% assign difference_in_seconds = incoming_date | minus: current_date %}
{% assign weeks_until_ship = difference_in_seconds | divided_by: seconds_in_week | plus: 1 %}
{% assign formatted_incoming_date = product.variants.first.next_incoming_date | date: "%B %d, %Y" %}
{% assign combined_inventory = product.variants.first.inventory_quantity %}
{%- comment -%}
Loop through incoming stock batches to calculate the total incoming quantity.
{%- endcomment -%}
{% for stock_batch in product.variants.first.incoming_stock_batches %}
{% assign combined_inventory = combined_inventory | plus: stock_batch.quantity %}
{% endfor %}
{% if combined_inventory <= 0 %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px;">Ready to ship in approximately {{ weeks_until_ship | round }} weeks ({{formatted_incoming_date}}).</span>
{% else %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px; color: #228B22;">In stock and ready to ship now. More incoming stock due by {{ formatted_incoming_date }}.</span>
{% endif %}
{% elsif product.variants.first.inventory_quantity > 0 %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px; color: #228B22;">In stock and ready to ship now.</span>
{% else %}
<span style="font-family: 'Lato', sans-serif; font-size: 16px;">Made to order. Current lead time 10-14 weeks.</span>
{% endif %}
ChatGPT