How to limit checkout to a single item in Spotlight theme?

BRITTBRITT
Excursionist
14 0 3

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 }}"
/>

Replies 5 (5)

gr_trading
Shopify Partner
1694 141 176

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.

 

 

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
BRITTBRITT
Excursionist
14 0 3

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? 

gr_trading
Shopify Partner
1694 141 176

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…

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
BRITTBRITT
Excursionist
14 0 3

Can you send me the script please? 

gr_trading
Shopify Partner
1694 141 176

Code always depends on the theme structure, please share your store URL.

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee