Hi,
I want to add a Add to Cart Button just below the product image on collection page or home page. below-mentioned is the code for product card/collection
{% comment %}
Accepts:
- product: {Object} Product (required)
- show_variant_options: {Boolean} Show variant swatches at the bottom (optional)
- hide_title: {String} Hide product title (optional)
- image_ratio: {String} Product media ratio (optional)
- pcard_alignment: {String} Product alignment (optional)
- show_vendor: {Boolean} Show product vendor (optional)
- show_cart_button: {Boolean} Show Add to cart button (optional)
- show_quickview_button: {Boolean} Show Quickview button (optional)
- show_wishlist_button: {Boolean} Show Wishlist button (optional)
- show_compare_button: {Boolean} Show Compare button (optional)
- column_wrapper: {Boolean} Wrap product card (optional)
Usage:
{% render ‘product-card-1’, product: product %}
{% endcomment %}
{% liquid
if show_variant_options == nil
assign show_variant_options = settings.show_swatch_option
endif
assign show_title = true
if hide_title == true
assign show_title = false
endif
if image_ratio == nil or image_ratio == blank
assign image_ratio = settings.pcard_image_ratio | default: ‘1/1’
endif
if image_ratio == ‘original’
assign image_ratio = product.featured_image.aspect_ratio | default: ‘1/1’
endif
if show_vendor == nil
assign show_vendor = settings.show_vendor
endif
assign sold_out = false
if product.available == false
assign sold_out = true
endif
assign discount = ‘’
assign compare_at_price = product.compare_at_price
assign price = product.price
assign on_sale = false
if compare_at_price > price
assign on_sale = true
assign discount = compare_at_price | minus: price | times: 100 | divided_by: compare_at_price
endif
assign show_on_sale_badge = false
if settings.on_sale_badge != ‘hide’ and on_sale
assign show_on_sale_badge = true
endif
assign quick_add_text = ‘products.product.quick_add’ | t
unless product.has_only_default_variant
capture quick_add_text
render ‘new-locale’, key: ‘products.product.select_options’
endcapture
endunless
assign sold_number = product.metafields.foxkit.sold_number
if product.available
assign variant_id = product.first_available_variant.id
else
assign variant_id = product.selected_or_first_available_variant.id
endif
assign selected_variant_id = ‘’
if section.settings.change_product_variant_on_fitlering
assign variant_id = product.selected_or_first_available_variant.id
assign selected_variant_id = product.selected_variant.id
endif
if pcard_alignment == nil
assign pcard_alignment = settings.pcard_alignment
endif
assign pcard_default_image = settings.pcard_default_image
if image_ratio == nil or image_ratio == blank
assign image_ratio = settings.pcard_image_ratio | default: ‘1/1’
endif
if show_cart_button == nil
assign show_cart_button = settings.show_cart_button
endif
if show_quickview_button == nil
assign show_quickview_button = settings.show_quickview_button
endif
if show_wishlist_button == nil
assign show_wishlist_button = settings.show_wishlist_button
endif
if show_compare_button == nil
assign show_compare_button = settings.show_compare_button
endif
assign preview_image = product.media[0].preview_image
if section.settings.change_product_variant_on_fitlering == true and product.selected_variant.image != nil
assign preview_image = product.selected_variant.image
endif
if image_ratio == ‘original’
assign image_ratio = product.media[0].aspect_ratio | default: ‘1/1’
endif
assign second_image = ‘’
if settings.show_second_img and product.images.size > 1 and product.images[1] != blank
assign second_image = product.images[1]
endif
assign product_card_classes = ‘m-product-card m-product-card–style-1’
if sold_out
assign product_card_classes = product_card_classes | append: ’ m-product-card–soldout’
endif
if on_sale
assign product_card_classes = product_card_classes | append: ’ m-product-card–onsale’
endif
if settings.show_second_img and second_image != blank
assign product_card_classes = product_card_classes | append: ’ m-product-card–show-second-img’
endif
%}
{%- if column_wrapper -%}
{%- if second_image != blank -%}
{%- if show_quickview_button or show_wishlist_button or show_compare_button -%}
{%- if show_wishlist_button -%}
{% assign wishlist_app = settings.wishlist_app %}
{% if wishlist_app == ‘growave’ %}
{%- for tooltip in tooltip_items -%}
{%- assign settings_key = ‘show_’ | append: tooltip | append: ‘_button’ | replace: ‘add-to-cart’, ‘cart’ -%}
{%- if [settings_key] -%}
{% render ‘tooltip’, type: tooltip, section: section, product: product, class_name: ‘m-tooltip–left’ %}
{%- endif -%}
{%- endfor -%}
{% liquid
assign metafields_time = product.metafields.global[‘minimog_countdown’]
if settings.show_countdown and metafields_time != blank
render ‘countdown-timer’, time: metafields_time, separator: false, short_label: true, extra_classes: ‘m-product-card__countdown m:hidden’
endif
%}
{%- if sold_out == false -%}
{{ product.title }}
if show_cart_button
render ‘tooltip’, type: ‘add-to-cart’, section: section, product: product, class_name: ‘m-tooltip–top m-product-card__atc-button’
endif
%}
{%- if show_wishlist_button -%}
{% assign wishlist_app = settings.wishlist_app %}
{% if wishlist_app == ‘growave’ %}
{%- for tooltip in tooltip_items -%}
{%- assign settings_key = ‘show_’ | append: tooltip | append: ‘_button’ | replace: ‘add-to-cart’, ‘cart’ -%}
{%- if [settings_key] -%}
{% render ‘tooltip’, type: tooltip, section: section, product: product, class_name: ‘m-tooltip–top’ %}
{%- endif -%}
{%- endfor -%}