Hi there,
I am trying to add 2 upsell products to the cart page, so when customer clicks “add to basket” then the product should be added to cart and page needs to be refreshed. I have no problem to display both products, but for some reason only one appears (for the 2nd product). Is there a reason why works only for one product?
cart-upsell.liquid (to display both products)
{%- assign cart_upsell_product_one = all_products['a-r-london-pj'] -%}
{%- assign cart_upsell_product_two = all_products['shirred-waist-denim-skirt'] -%}
{% if cart.items != empty %}
## You may also want
{%- unless cart_upsell_product_one.empty? -%}
{% include 'cart-upsell-product', {product: cart_upsell_product_one} %}
{%- endunless -%}
{%- unless cart_upsell_product_two.empty? -%}
{% include 'cart-upsell-product', {product: cart_upsell_product_two} %}
{%- endunless -%}
{% endif %}
cart-upsell-product.liquid (to display product )
####
{{ product.title }}
{% assign variant = product.selected_or_first_available_variant %}
{{ variant.price | money }}
{% if product.variants.size == 1 and product.compare_at_price_max > product.price_min %}
{{ variant.compare_at_price | money }}
{% endif %}
{% if product.available %}
{% form 'product', product, class: 'form', data-product-id: product.id, data-enable-history-state: 'true' %}
{% if product.variants.size > 1 %}
{% for option in product.options_with_values %}
{% endfor %}
{% else %}
{% unless product.variants.first.title contains 'Default' %}
{% endunless %}
{% endif %}
{% if product.variants.size == 1 %}
{% if product.variants.first.inventory_management == 'shopify' and product.variants.first.inventory_quantity < 1 %}
{{ product.title }} {{ 'products.product.backorder' | t }}
{% endif %}
{% else %}
{{ 'products.product.backorder' | t }}
{% endif %}
{% endform %}
{% else %}
*{{ 'products.product.product_unavailable' | t }}*
{% endif %}
Thanks in advance.
