Update input step quantity Cart Drawer (Refresh Theme)

Ant_Papa
Shopify Partner
5 0 0

Hi,

 

I need some help implementing box quantity's for the cart drawer (Increasing / decreasing the cart quantities in multiples). I used the input step for the product page which works fine but i tried the same for cart drawer, but when there is multiple items in the cart the step change doesn't work.

 

 

 <input class="quantity__input"
                                type="number"
                                name="updates[]"
                                value="{{ item.quantity }}"
                                min="{{ caseQty }}"
                                step="{{ caseQty }}"
                                onkeydown="return false"
                                aria-label="{{ 'products.product.quantity.input_label' | t: product: item.product.title | escape }}"
                                id="Drawer-quantity-{{ item.index | plus: 1 }}"
                                data-index="{{ item.index | plus: 1 }}"
                              >

 

 

I know I have to change something in cart.js but not sure where to start.

 

Thanks

 

Replies 6 (6)

Rahul3F
Excursionist
14 2 4

Hello,

Please check and try the code

{% for item in cart.items %}
<input class="quantity__input"
type="number"
name="updates[]"
value="{{ item.quantity }}"
min="{{ item.product.min_quantity }}"
step="{{ item.product.min_quantity }}"
onkeydown="return false"
aria-label="{{ 'cart.item.quantity.input_label' | t: quantity: item.quantity, product: item.product.title | escape }}"
id="cart-quantity-{{ item.key }}"
data-index="{{ forloop.index0 }}"
>
{% endfor %}

 

Thanks

 

rahul
Ant_Papa
Shopify Partner
5 0 0

Thanks for your reply,

 

I tried the code and it seems to break my cart, im afraid. I should of explained slightly better, i need certain products to increment up in certain amounts, for example a product can only be sold in a box of 6, so the quantity needs to increase and decrease in 6's. I'm using a metafield for the case qty number. here is my full code, however like i said previously the step count is being overridden by something in the cart.js file.

 

 {% assign caseQty = item.product.metafields.custom.case_qty %}
                              {% if product.metafields.custom.case_qty == blank %}
                              {% assign caseQty = 1 %}
                              {% endif %} 
                      
                                <input class="quantity__input"
                                type="number"
                                name="updates[]"
                                value="{{ item.quantity }}"
                                min="{{ caseQty }}"
                                step="{{ caseQty }}"
                                onkeydown="return false"
                                aria-label="{{ 'products.product.quantity.input_label' | t: product: item.product.title | escape }}"
                                id="Drawer-quantity-{{ item.index | plus: 1 }}"
                                data-index="{{ item.index | plus: 1 }}"
                              >
gr_trading
Shopify Partner
1749 142 184

@Ant_Papa 

 

You have to create custom attribute at product level.

 

which will be accessible at cart page and perform same you did on product page.

 

Hope 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
Ant_Papa
Shopify Partner
5 0 0

Thanks for the reply, could you please elaborate on creating a create custom attribute at product level? Do you mean creating a custom metafield? or via code in cart.js?

 

Thanks

gr_trading
Shopify Partner
1749 142 184

Hi @Ant_Papa ,

 

As per my understanding, you already have created the metafield, you just need to forward it to the cart page, and based on that you can filter the element.

 

Please refer to the below URL.

https://devsworks-1103.workctrl.store/

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
pyates23
Shopify Partner
4 0 0

did you ever solve this, I have the exact same issue

 

thanks in advance