1

When I select a checkbox for one product to remove it from the cart, it empties all products. Any ideas why? Here is the code I am using from inside the {items} tag. Thanks!

<input type="checkbox" class="cart_remove_check" name="remove_items[{key}]" value="1" />

Here is my full template code...

{embed="wrappers/_main"}
{exp:stash:set name="content" no_results_prefix="pfx"}
  <div class="row">
    <div class="small-12 columns">
      {exp:store:cart}{if no_items}{redirect="get-started"}{/if}{/exp:store:cart}
      <h1>Checkout</h1>
    </div>
  </div>
  {exp:store:checkout
    return="checkout/complete/ORDER_HASH"
    require="name|address1|address3|postcode"
    payment_method="stripe"
  }
  <div class="row">
    <div class="small-12 large-4 columns">
      <h3>Credit Card</h3>
      <p>
        <label>Card Number</label>
        <input type="text" id="payment_card_no" value="">
      </p>
      <p>
        <label>Name on Card</label>
        <input type="text" id="payment_name" value="">
      </p>
      <label>Expires</label>
      <div class="row">
        <div class="small-6 columns">
          <select id="payment_exp_month">
            <option value=""></option>
            {exp_month_options}
          </select>
        </div>
        <div class="small-6 columns">
          <select id="payment_exp_year">
            <option value=""></option>
            {exp_year_options}
          </select>
        </div>
      </div>
      <p>
        <label>Security Code</label>
        <input type="text" id="payment_card_csc" size="4" value="">
      </p>
      <h3>Billing Address</h3>
      <p>
        <label>Name</label>
        {field:billing_name}
      </p>
      <p>
        <label>Address</label>
        {field:billing_address1}
        {field:billing_address2}
      </p>
      <p>
        <label>City</label>
        {field:billing_address3}
      </p>
      <p>
        <label>State</label>
        {field:billing_region}
      </p>
      <p>
        <label>Zip</label>
        {field:billing_postcode}
      </p>
      <p>
        <label>Phone</label>
        {field:billing_phone}
      </p>
    </div>
    <div class="small-12 large-4 columns">
      <h3>Email Address</h3>
      <p>
        <label for="order_email">Email Address</label>
        {field:order_email}
      </p>
      <h3>Shipping Address</h3>
        <label for="shipping_same_as_billing">
          <input type="hidden" name="shipping_same_as_billing" value="0">
          <input type="checkbox" id="shipping_same_as_billing" name="shipping_same_as_billing" value="1">
          Same as Billing Details
        </label>
      <div id="shipping_details_drawer">
        <p>
          <label>Name</label>
          {field:shipping_name}
        </p>
        <p>
          <label>Address</label>
          {field:shipping_address1}
          {field:shipping_address2}
        </p>
        <p>
          <label>City</label>
          {field:shipping_address3}
        </p>
        <p>
          <label>State</label>
          {field:shipping_region}
        </p>
        <p>
          <label>Zip</label>
          {field:shipping_postcode}
        </p>
        <p>
          <label>Phone</label>
          {field:shipping_phone}
        </p>
      </div>
    </div>
    <div class="small-12 large-4 columns">
      <div class="row">
        <div class="small-8 columns">
          <h3>Items</h3>
        </div>
        <div class="small-4 columns">
          <input class="tiny button expand" type="submit" name="empty_cart" value="Empty Cart">
        </div>
      </div>
      <table width="100%">
        <thead>
          <tr>
            <th width="75%">Product</th>
            <th width="20%">Price</th>
            <th width="5%"><span id="remove_from_cart_label">x</span></th>
          </tr>
        </thead>
        <tbody>
          {items}
            {exp:channel:entries entry_id="{entry_id}"}
              <tr>
                <td>
                  {title}{if item_qty > 1} (x{item_qty}){/if}
                  {modifiers}
                    <br><span style="font-size: 11px;">Rear Wipers {modifier_value}</span>
                  {/modifiers}
                </td>
                <td>{price}</td>
                <td><input type="checkbox" class="cart_remove_check" name="remove_items[{key}]" value="1" /></td>
              </tr>
            {/exp:channel:entries}
          {/items}
        </tbody>
      </table>
      <div class="row">
        <div class="small-9 columns">
          <p style="text-align:right;">
            Subtotal:<br>
            Tax:<br>
            Shipping:<br>
            Total:
          </p>
        </div>
        <div class="small-3 columns">
          <p>
            {order_subtotal}<br>
            {order_tax}<br>
            {order_shipping}<br>
            {order_total}
          </p>
        </div>
      </div>
      <div class="row">
        <div class="small-12 large-5 columns">
          <input class="small button expand" type="submit" name="empty_cart" value="Update Cart">
        </div>
        <div class="small-12 large-7 columns">
          <a href="{path='get-started'}" class="small secondary button expand">Continue Shopping</a>
        </div>
      </div>
      <div class="row">
        <div class="small-12 columns">
          <input id="checkout_submit" class="large success button expand" type="submit" name="submit" value="Place Order">
        </div>
      </div>
    </div>
  </div>
  <input type="hidden" id="payment_token" name="payment[token]" value="" />
  {/exp:store:checkout}
{/exp:stash:set}
4
  • What version of EE and Store are you using? – Justin Long Nov 6 '13 at 18:11
  • EE 2.5.5 and Store 1.6.3 – Jacob Graf Nov 6 '13 at 18:16
  • Can you also post your full checkout template code – Justin Long Nov 6 '13 at 18:50
  • Just edited my original post with full template code. – Jacob Graf Nov 6 '13 at 18:53
3

Your "Update Cart" button is named empty_cart. By calling it that you are telling Store it should empty the cart when you click it.

Try changing this line:

<input class="small button expand" type="submit" name="empty_cart" value="Update Cart">

To this:

<input class="small button expand" type="submit" value="Update Cart">
2
  • Great eye spotting that! – Anna_MediaGirl Nov 6 '13 at 21:19
  • * drops head in shame * lol - thanks for finding that! :-) – Jacob Graf Nov 6 '13 at 21:21
0

Try adding this also in the item loop:

<input type="hidden" name="items[{key}][item_qty]" value="{item_qty}" />
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.