0

I have a table that displays rows of products with there attributes, the last item on each row has the variation add to cart form. The view's self sorts on the product id to display all the variations for the product.

The issue is it can't select the variation for each row automatically, it always expects the user to choose the right variation from a dropdown.

Any changes that do not have the drop-down displayed defaults to only the first product item in the table. I have tried the relationship to the product and product id and variation cart form modules but these also failed to deliver.

I there a way in views to add a per-variation add to cart button with no selection in views table?

enter image description here

0

I finally found the answer from help on this post. here Although, I still had a few issues and mine ended up being slightly different, so I will lay out what I did to achieve this.

I am using a view table but really any sort of display using fields with grids should work the same.

  1. Install the module Add to cart link
  2. Create a new display on your product variation called what you like I am using 'view' with only the add to cart link field.
  3. In your view add the display type you require.
  4. Add Relationship: variations (Relate each Product with a variations set to the product variation.)
  5. Add Relationship: Product
  6. Add contextual filter: Product: ID - Provide default value Product ID from URL
  7. Add Field Rendered entity - Product variation
  8. Select your display from the view mode.
  9. Save, add your view and output your view to your product page.

Now you will see all the Add to cart buttons displayed for each variation on the product with the right token add to cart link for each.

0

You can also be done using the Drupal module Direct Checkout

You can then build your own Drupal commerce buy now link or button in any view using the global custom text, by simply adding the following code.

<a href="/direct-checkout-by-url/products={{ sku }}" class="btn btn-default">Add to cart</a>

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.