The JS works so that clicking a checkbox to remove an item from the cart will submit the form and delete the item appropriately. What it doesn't do is convert the checkbox to the actual delete image specified in #841954: Additional tweaks to the shopping cart form UX. I'm not sold on a delete button with an actual English word on it, but we can work from there... I think red x's and trash can buttons are also fairly standard. The Fivestar module has some pretty sharp little icons for this.

Comments

Bojhan’s picture

Delete word is the most safe direction, with all other icons you are not sure the meaning in other cultures or how clear it is to the lowest dominator of buyer.

rszrama’s picture

I should've clarified - I'm not opposed to having a word, but taking a lot of care to make sure the Commerce modules are very easy to use internationally without have a Delete button for every language seems counter-intuitive to me. Do you know of an easy way to do differently? Should we even use an image or just a styled link w/ output generated by the module?

neokrish’s picture

i vote for "a styled text link"

Bojhan’s picture

Styled link is fine, as long as it looks like a button. Because we want to communicate a "action".

@neokrisch A small opensource lesson, there is no voting only properly argument-ed discussions :)

mertskeli’s picture

Sorry, it is not clear why a checkbox is chosen and why it has such an unusual behavior.
1. What if JS is disabled?
2. What if multiple item are to be removed from a form? Clicking on one of the checkboxes starts the action?

@#4
Right, it should be a clear "action". So, button would be the best option. On the other hand, having a checkbox for each item and a bulk delete button in the bottom could be enough.
If I would have to choose between a checkbox and a button, I would prefer a button. Because: a). it can be styled (see below), b). Q-ty input field is already a kind of a checkfox - if you clear it, it removes the item.

@#2
Submit html element can be styled whatever. With image/icon as well (and very often).
As for i18n, buttons (as well as any other Drupal interface controls) are supposed to be translated by Locale > Translate, or by translation files within Commerce module.

rszrama’s picture

To answer your questions, user testing has shown that customers consistently get the bulk update wrong. Major e-commerce players like Amazon.com standardize on removing a single item at a time using an image or text button / link.

In our case, the reason it was implemented as checkboxes the way it is is precisely so it can degrade when JS is not available. It won't just be themed to look like an image or button - we'll actually use JS to do the image replacement. This way if JS isn't enabled, it will still look like a set of checkboxes that can be checked to remove items from the cart on update.

That said, I hadn't thought of making each individual checkbox a submit element instead. That would certainly rule out multiple removals, though, but it would also simplify the JS required to make this work... will think about it.

mertskeli’s picture

Sorry, can not get it. I'm only curious about checkbox+js being chosen for that. I do not understand why would you need it. Why would you need js to replace checkbox with an image if a button can do it right away and can be styled in a much easier and reliably by css?
You say "Major e-commerce players like Amazon.com standardize on removing a single item at a time using an image or text button / link." and then "it will still look like a set of checkboxes that can be checked to remove items from the cart on update". which sounds controversary, and does look like a bulk update. Link/button is a single action. Checkbox is not. And it means that a user will have to check it (one action) and press update (second action). Or it will completely rely on js for this one-click-trick?

rszrama’s picture

I don't think you're understanding the concept of graceful degradation. It works one way right now because the JS hasn't been fully implemented. We've historically (in Ubercart) used a set of checkboxes to handle removing items from the cart, so I did that here. In retrospect, it might've made more sense to use submit buttons... only that would make it much harder for anyone else to enable a multiple removal tool if they want.

What I said isn't contradictory, it's just the difference between the way the form looks with JS enabled vs. the way it looks with JS disabled. Why do we need checkbox + JS? Because I want that checkbox to look like an image and submit like a button but to work like a checkbox if JS isn't available. : P

mertskeli’s picture

"only that would make it much harder for anyone else to enable a multiple removal tool "
Now it is more clear. Dilema.
So, if JS is disabled, everything changes and becomes even worse than with buttons. Not so graceful.
Ok, not a critical. If it becomes very uncomfortable, people will complain, and it will be modified.

Just checked the Amazon... awful, as usually... It has input type="image".
apple.com store has a "Remove" link.
toshibadirect.com - has a "x" round icon.
microsoft.com store - has a "Remove" link.
Visited almost 10 online shops. Well, not so many checkboxes so far...
Checkboxes are very common in e-mail boxes. Not so typical for online shops.

rszrama’s picture

Right, as I said in #6 above, I just hadn't thought of making it a button till now. It seems reasonable and Damien is in favor, it just slipped my mind b/c I implemented the cart form so quickly in preparation for DrupalCon CPH and was basing it on what Ubercart does. Also, as I tried to make clear above, it was never intended to appear as checkboxes... I knew that much was bad. : P

mertskeli’s picture

The big advantage of checkboxes (or meaningful icons, or "x" buttons) is that they do not occupy that much space as Delete/Remove button/link.

Bojhan’s picture

@mertskeli I am not sure what you are proposing. Delete is far more clear then almost all icons can communicate, especially considering it needs to be translatable. I don't think the space is a problem, if it becomes a problem you can always theme it differently.

mertskeli’s picture

@Bojhan
I am for buttons, as mentioned in #5.
The dilema is that multiple operations should not be ignored.
To sum up,
1. I suggest a Delete button per line. Or maybe a Remove.
2. No need for checkboxes, because bulk action can be done by q-ty field + update button.

rszrama’s picture

Agreed on all counts. Bojhan, I know you specified a Delete image button, but would you consider it sufficient for the core modules to make it a simple Submit and allow themes to turn that into a smaller button (like Top Notch Themes does with Ubercart styling)? I'm just thinking it's gonna be hard to come up with generic theming for the button at the core...

Bojhan’s picture

I dont get what a simple submit is? Drupal commerce needs to provide sensible defaults, just a CSS based gray button with the black text Delete should be fine. As far as I know, all themes that want too can overwrite. I work enough in the Drupal space to know that, sensible defaults are fine in a lot of cases (people will change it as they see fit)

mertskeli’s picture

gray button with the black text Delete is a simple submit. "Button" is colloquial, "Submit" is per HTML coding.
So a simple Delete button looks like <input type="submit" value="Delete" />
It can be styled by CSS to whatever you want, including borders/shape/image replacement.
rszrama suggested checkboxes (<input type="checkbox" value="Delete" />) and to convert them to buttons by JS. Imo it is less good (see #7).

rszrama’s picture

@mertskeli - No, that was the original suggestion but as I've said above I'm going to change them to submit buttons.

@Bojhan - A simple submit to me is what mertskeli said, a submit element in the Forms API that gets rendered as a submit button with no styling. I've never styled buttons, so I can look around for a little gray button with text... I'd just as soon leave it as a submit button, but it would be too imposing alongside the other buttons in the form. Do you have any CSS examples I can refer to? Seven's seem just as large (or larger) as a browser's default submit element.

rszrama’s picture

Title: Change the checkbox to remove from the cart to an image » Change the checkbox to remove from the cart to a styled submit button

Title clarification.

rszrama’s picture

Wow, I just ran into an unexpected problem. : )

If I have 3 submit buttons on the page named "Delete", Drupal always assumes it's the last one on the page that I clicked. Without making the value of the button something specific to the line item I want to delete from the cart, I can't use normal #submit elements in FAPI. This means for now the checkboxes stand, but they can just as easily be themed into button elements that check a hidden checkbox and submit the form.

Anyone have any ideas for some other workaround? At this point, I don't really care if checkboxes aren't the most user friendly method for non-JS customers... it still works.

mertskeli’s picture

If there is no other workaround, lets use checkboxes. It's better than nothing.

Without making the value of the button something specific to the line item I want to delete from the cart, I can't use normal #submit elements in FAPI.

So, why not to rename the line item delete button to "Remove", lets say?

rszrama’s picture

No, I mean each button on the form would have to have a unique title - like "Delete 1", "Delete 2", etc. That just won't do. However, we should be able to style them as HTML buttons that check the underlying box, and in that case they could all have the same title.

As for whether or not there's no workaround, I'm going to see if Damien can chip in, but I don't think there is one.

Damien Tournoud’s picture

You should be able to use a different submit button name for this (ie. not 'op').

rszrama’s picture

Hmm... ok, I'll look into it. I was basing the removal on the $form_state['clicked_button'], and because the buttons all had the same #value, it was always thinking I clicked the last one on the form with that value.

rszrama’s picture

And magically, setting #name => delete-line-item-X works like a charm. Curious about the core naming behavior rendering all submit buttons as op. Code here:

http://github.com/rszrama/drupalcommerce/commit/50a6f90868699136903d4545...

All that's left now is styling.

torgosPizza’s picture

That is awesome, Ryan. Thanks for the tip!

asak’s picture

Nice direction, very similar to what's going on at #529110: Users misunderstand "Remove” checkbox on cart page.

From what i can tell (and according to a 3 year old survey found at http://psychology.wichita.edu/surl/usabilitynews/92/shoppingcart.asp) - Stating "Remove" instead of "Delete" would provide better usability. I tend to agree on this one - delete is harsh, remove is way more subtle. when you see "delete" you naturally think twice (which on one hand is good for a shop..) but "remove" is more correct for the action - we're clearly not deleting anything... just removing from the cart... ;)

Bojhan’s picture

@asak Am I missing that conclusion? Also I am not sure if its a/b results or just expert review?

asak’s picture

@Bojhan - sorry i wasn't clear enough. the conclusion is mine - what the survey shows is that the majority of sites (68% in figure 8) use "Remove", but no conclusion is made as to what's better. it's not reviews or testing - it's just statistical info. personally, i think in cases like this it best to "go with the flock", for that's what most users will be costumed to.

Also - my opinion is that it's more correct regardless of the info in that survey, for the reasons stated above.

My comment above was a bit misleading, sorry... ;)

Bojhan’s picture

No problem. I could definitely side with using the reasoning of "Remove" over "Delete".

rszrama’s picture

Status: Active » Fixed

In that case, I've changed the word back to Remove. I've also just committed a patch that changes the button to use Bartik's button styling with a slightly smaller font size and less padding. I imagine the position of these buttons will move (i.e. from its own column to a place beneath the product description), but I think the actual issue here is considered resolved.

http://github.com/rszrama/drupalcommerce/commit/763eed8567e0afc0be2dd6e4...

Bojhan’s picture

Status: Fixed » Active

I dont think we should be closing issues that are not actually finished, it tends to result in very mediocre design that looks unfinished. Lets go with a screenshot and set out clearly the next steps towards fixing.

rszrama’s picture

Status: Active » Needs review

I figured the final fixes would come in the parent issue #841954: Additional tweaks to the shopping cart form UX. That's where the screenies are, particularly the one in your comment #4. The current button is simply Bartik themed a little smaller, and as this issue was simply to change it from a checkbox to a submit button, I considered it finished.

If someone wants to review, more power to ya, but this is as good as I can get it when left to my own devices. ; )

cart-styled-remove-buttons

Bojhan’s picture

Status: Needs review » Fixed

Thats something I can review :) Actually think its fine to keep it like this, it stays in line with the design of Bartik an we don't have to worry about accessibility because we are going with core. Marking it back to fixed, lets make it a habit to include a last screenshot whenever there is a UI change + commit, that way we can keep design people involved.

asak’s picture

Excellent job guys. thanks.

rszrama’s picture

Indeed, I can do that. : )

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

CanOne’s picture

i just changed this button to fit my needs and want to chare it if someone else wants to do the same

function YOURMODULE_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state, $form_id) {
  foreach ($form['edit_delete'] as &$item) {
    $item['#type']='image_button';
    $item['#src']='sites/default/files/images/delete.png';
    $item['#alt']='Delete';
  }
}

I´m not really sure if the ['#alt'] thing is working, because i cant see it in source but i saw it once before the image was loaded so maybe its workin :)

Cheers, Can!

dready2011’s picture

I tried #37 and it seemed OK at first. But then I noticed that if you have 2 or more items in the cart and you want to remove the one at the top, it removes the wrong one (the one at the bottom). If i remove the hook_form_views_form_commerce_cart_form_default_alter code, it works OK again, so it must be related...
Any idea why???

Thanks

dready2011’s picture

I do not understand why exactly the wrong line-item was being deleted, but i managed to solve the problem by changing the code from #37 into:

function myOwnModule_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state, $form_id) {
  foreach ($form['edit_delete'] as &$item) {
	if (is_array($item) && $item['#type'] == 'submit')
	{
		$item['#value'] = '';
	}
  }  
}

and then adding this to my css

.commerce-line-item-views-form input.delete-line-item{
border:none;
background-image:url(../images/delete.png);
width: 20px;
}
adam1’s picture

Issue summary: View changes

After using the code in #37 I got the same issue as @dready2011. Would be great if someone savvy could check what's wrong with the code, because I would like to have a solution which uses a proper image button without a workaround in CSS (see #39).

adam1’s picture

Problem solved on stackexchange. You need to unset the value:

  $item['#type']='image_button';
  $item['#src']='sites/all/themes/mytheme/images/trash.svg';
  $item['#alt']='Remove';
  unset($item['#value']);