All things Shopify and commerce
How do I limit the checkout to 1 item and 1 quantity? I'm using spotlight theme.
I did get an error message on the cart page when I tried adding a product or adding the quantity - error message stated "There was an error while updating your cart. Please try again." but it still let me add the products to my cart and go through with the checkout process. Any help would be greatly appreciated.
Below is the code used.
main-cart-items.liquid updated code
<input
class="quantity__input"
data-quantity-variant-id="{{ item.variant.id }}"
type="number"
name="updates[]"
value="{{ item.quantity }}"
{% # theme-check-disable %}
data-cart-quantity="{{ cart | item_count_for_variant: item.variant.id }}"
min="{{ item.variant.quantity_rule.min }}"
{% if item.variant.quantity_rule.max != null %}
max="{%- if product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity != null %} max="{{ product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity }}" {%- endif %}
{% endif %}
step="{{ item.variant.quantity_rule.increment }}"
{% # theme-check-enable %}
aria-label="{{ 'products.product.quantity.input_label' | t: product: item.product.title | escape }}"
id="Quantity-{{ item.index | plus: 1 }}"
data-index="{{ item.index | plus: 1 }}"
>
main-product.liquid code that was updated
<input
class="quantity__input"
type="number"
name="quantity"
id="Quantity-{{ section.id }}"
data-cart-quantity="{{ cart_qty }}"
data-min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
{%- if product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity != null %}
data-max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
max="{{ product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity }}"
{%- endif %}
step="{{ product.selected_or_first_available_variant.quantity_rule.increment }}"
value="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
form="{{ product_form_id }}"
/>
You can remove the add to cart CTA using customise option in theme and hide the quantity selector.
but doing this user will only have checkout button button left with single quantity.
Yes I already removed the Add to cart button. I kept the buy it now button. I removed the cart page from header. The only way you can access the cart page is on checkout page. I'm told you can't remove the cart button from header in checkout page. Is there a way to remove the cart button from checkout page header?
Yes, you can’t remove the cart link from the checkout page.
but you can write a script and cas at cart-footer.liquid.
CSS will make the whole page blank with loader.
script will trigger the click of checkout button of the page.
By this your user will not able do any action on cart page like removing the cart or increasing the quantity.
does it make sense?
don’t forget to mark my answer as solution if it helps…
Can you send me the script please?
Code always depends on the theme structure, please share your store URL.
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024