It's currently not easy for me to get the "add to cart button" inline.
Do you know of a way or wouldn't it be better to add a css class ?

See attached screenshot for example.

CommentFileSizeAuthor
shop_inline.png72.44 KBJGO
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Haza’s picture

Status: Active » Needs review

This patch add a generic class to the add to cart form, provinding a class on the form.

The form now look like that :

<form class="commerce-add-to-cart commerce-cart-add-to-cart-form-1" action="/" method="post" id="commerce-cart-add-to-cart-form-1" accept-charset="UTF-8"><div><input type="hidden" name="product_id" value="1">
<input type="hidden" name="form_build_id" value="form-Bgcv8UaA-8oCp1oAdgblklhBqxgh1haiNdfEM_Ai-0E">
<input type="hidden" name="form_token" value="rdbI2DvHp80yiEQJpoLHw4gW6nsr6tWeZNngR60x4Eo">
<input type="hidden" name="form_id" value="commerce_cart_add_to_cart_form_1">
<input type="hidden" name="quantity" value="1">
<input type="submit" id="edit-submit" name="op" value="Add to cart" class="form-submit"></div></form>

So you can target the submit button with css with something like .commerce-add-to-cart submit
I have a patch on my sandbox
http://drupalcode.org/sandbox/haza/1198696.git/commitdiff/refs/heads/119...

JGO’s picture

works perfectly now, thank you very much! Hope code gets added :)

rszrama’s picture

Status: Needs review » Fixed

This is a great approach. Committed. : )

JGO’s picture

Status: Fixed » Active

Updated to latest dev version, unfortunately it is not included :s

rszrama’s picture

Status: Active » Fixed

It's there... check your commerce_cart.module line 1252:

  // Add a generic class ID.
  $form['#attributes']['class'][] = drupal_html_class('commerce-add-to-cart');
JGO’s picture

you're right, I accidently "updated" with an older version

JGO’s picture

Btw has anything else changed ? I see the commerce-add-to-cart class, but my inline doesn't seem to work anymore.

JGO’s picture

Yeps, now it's this that is making troubles:

etc

#edit: well I could select it of course, so it's ok now :)

Status: Fixed » Closed (fixed)

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

Frank HH-germany’s picture

Issue summary: View changes

Hi, how can i get a class in Commerce 2.x ?

Currently i fix this with this code in the style.css but its not realy fine...

.form-actions .btn-primary {
animation: perspect 15s infinite linear;
}
.form-actions .btn-primary:hover {
animation: perspect 0s infinite linear;
}
alirahimian’s picture

hi you can add a class to your view ( for example .commerceshop ) and then use this simple css code


.commerceshop form {
  display: flex;
}


that's easy way for display inline add to cart form and quantity box !