Closed (won't fix)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Views integration
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2012 at 06:46 UTC
Updated:
16 May 2018 at 16:31 UTC
Jump to comment: Most recent
Comments
Comment #1
liupascal commentedI would go for a :
- Views bulk operation module
- Rules
Create a Rule Action that adds a list of product to the cart (list of products as parameter), loop on it and use the Action "Add product to the cart".
Configure your view / views bulk operation item to use the newly created rule action.
Done !!
Comment #2
bojanz commentedRelevant issue request in "Commerce Add To Cart Extras": #1395596: Checkboxes instead of quantity. That is where code for that should be implemented.
And of course, there's always #1.
Comment #4
zooter626 commentedSorry, I had to post here as a last resort, not being able to find the answer anywhere else (and being a noob).
Liupascal, can you give a bit more detail about how to go about doing this with Rules + VBO? I've been trying for days and I've just run into the same issues as here: http://www.drupalcommerce.org/discussions/700/add-multiple-products-cart-vbo. Basically, all I can get is the first product (it doesn't even have to be selected) is added to the cart no matter what product(s) is selected.
This seems like a frustratingly easy problem that I just can't figure out. Thanks.
Comment #5
rszrama commentedSorry, zooter626, this post is over a year and a half old. I don't think liupascal will be circling back around any time soon. ; )
You might see if https://drupal.org/project/commerce_add_to_cart_extras can work for you. : ?
Comment #6
zooter626 commentedBeen there done that. Even with a patch (or re-write rather) submitted recently whereby users are allowed to to select checkboxes instead of quantity field, it's buggy and doesn't work (well). I'm studying the Rules Mastery series by Itangalo on YouTube to see if I can learn an answer and I'll post back if I can. I am not a smart man by any means, but I thought this would have been answered somewhere by now through Rules and VBO. Thanks for the suggestion!
Comment #7
chris burge commentedI am able to confirm the behavior described by @zooter626. When I create the rule action described by @liupascal, only the first product is added to the cart, regardless of which product or products are selected.
There appears to be a bug with the Rules integration provided by Commerce. It's probably best to create a new issue and link to it from here.
Comment #8
prorokxp commentedHi,
I'm very interested in such functionality.
commerce_add_to_cart_extras do not works for me. It wont add all the items to the cart. And its not so flexible like VBO + Rules solution.
So, I decided to go with rules.
Fortunately I was able to adjust Rules component to succefully add all selected with VBO products to cart.
It's great. Big thanks to liupascal and creator of this issue!!
But... i want to improve it (if it is possible actually).
For now my Rules Component has one Action and one parameter (Content type: product). It gets product as parameter and executes add to cart action. It is not loop, not like was initially advised by liupascal.
I'm trying to understand how to implement Loop Action (Add loop) and how to configure VBO in such configuration. I need it cause I want to get rid of this screen with progress bar when VBO operation is processed.
Can someone provide simple step by step instruction how to make it? I know it is quite a few steps to do, but it is very difficult to guess the first time how it works.
Thanks in advance.
Comment #9
prorokxp commentedComment #10
rszrama commentedI wouldn't look for a tutorial here in the issue queue, as it's mostly a place for bug reporting / task management. Support requests / tutorials are typically coming through the forums and Commerce Q&A on drupalcommerce.org.
In this case, I'd recommend just finding someone who can help in real time through IRC and crafting the steps yourself. This issue's a year and a half old, so I'd think a tutorial would've materialized by now if anyone else had that itch to scratch. : )
Comment #11
joecanti commentedHi,
I know this is an old thread - but I thought I'd post my solution for others...
This creates a list of products with checkboxes, and one 'add to cart' button.
The Rules Part:
- 1. create a new rules component. Make it an Action set.
- 2. First, add a name. EG "VBO Add To Cart". Below, you'll see a table with three rows - you only need to fill in the top one.
Choose Commerce product from the dropdown (under Entity), and then fill in the other 2 with something memorable like 'Commerce Product' for the label. The machine name needs to be something like commerce_product. Click continue.
- 3. On the next page, choose 'add action'. Choose the type of action: Add product to cart.
- 4. On the next page you need to add the user and the sku. In the user field, start by writing 'site'. This will trigger the dropdown, and you can choose site:current-user. Then for the SKU - first click 'switch to data selection'. You can then click in the field, and select the entity you named earlier (not site). Then you can select sku. Now change the quantity if you need to, then click save.
The Views Part (The easy part)
For this you need VBO installed. Make a view displaying a table of commerce products. You can add the name and the price fields. Next add the VBO field. From the actions list, you should see your newly created rule action. Select it, and if you want, choose to skip the confirmation. Under the bulk options, I also changed it to display as single buttons, as I only have this one action that can be performed. Now save the view. (If you want the tickbox on the left of your table, just rearrange the fields.
Now place your view where you want it (eg a block on a page, or a page, or inserted into a panel) and view it. You should be able to select multiple products with the checkboxes, and then add them to the cart with one click.
Comment #12
narco commentedThanks Joecanti
Considering this thread has been around for years, you posted that at a perfect time for me :)
There is one thing I couldn't figure out (I'm very new to this), I have put the view I made in my Product Display. But I only want the view to list products that would normally be associated with that product display, and at the moment it displays all products.
Do you have any suggestions as to how I could make it only list products associated with that product display?
thanks
Comment #13
amh5514 commentedThis is how I configure views to display items related to a node, in your case Product Display.
I did this using Views 7.x-3.11 and got the results you are looking for. Hopes this helps.
Comment #14
adamps commented@Chris Burge and anyone else who finds that only the first item in the view got added no matter what.
I had the same problem, and it was because of an interaction with an "Add to cart" button that I had as a column in the views table. The VBO action wasn't being fired at all (eventually I changed it to "send email" and still got "XXX added to cart"). Instead the first add to cart button was firing. When I removed the add to cart column it worked fine.
Somehow Drupal seems to be getting confused with the complexity. Without VBO, each add to cart is a separate form. With VBO enabled, the entire view is a form with a submit button for the bulk button and another one for each individual add to cart button (form builder seems to cleverly avoid nesting forms). There is a Drupal core issue that may be relevant #1342066: Document that buttons with the same #value need a unique #name for the form API to distinguish them, or change the form API to assign unique #names automatically.
Sorry I haven't got to the bottom of it yet. If anyone knows the answer please let me know, otherwise maybe my findings so far will help someone else. If someone who has this working can shed any light I would appreciate it - and please say if you did have the separate add to cart buttons.
Comment #16
narco commented@amh5514
(reposted as my last one disappeared)
Thanks a lot, and sorry for the delayed response, I've been moving house, but I'm back onto it now!
That sounds like a very hopeful way of achieving what I want, but I am having a couple of issues:
The first is step 1 (doh!). There is no option when adding a contextual filter for "Content:NID", I only get a lot of Commerce Product options, and one Global:Null. (I expect missing a "Content:ID" is something to do with newbie ignorance). (The view I am editing is the table which I added to select multiple products, I assume that is correct.)
The other thing is in step 4, I get a box for selecting content type, but I get no check boxes beside the options so I can't select anything! I'm using Safari, and I'm guessing its something to do with that. I also tried it in Chrome, but I got an Ajax error, as well as one about the view being locked.
Thanks very much for your response so far :)
Comment #17
narco commentedFigured it out, I (from memory) created a relationship between the product and product display, and filtered the product reference by the Node ID from the URL
Comment #18
bunset commentedThanks @joecanti, your solution #11 worked for me perfectly!!!!
very very nice
Comment #19
bunset commentedNow I would need to check the cart, and disable the checkboxes vbo on the items previously added to the cart.
Any idea?
Comment #20
danzVP06 commented@AdamPS did you find a solution for the add to cart form? Because I am also having problems about that, I can't fill out my custom line items and my bundle products if the add to cart form is not included in the view.
Thank you!
Comment #21
adamps commented@danzVP06 Sorry I never did find a solution. In the end I removed the VBO column entirely and adopted a different approach.
Principally my site needed a way to "buy all" rather than an arbitrary set of items (the concept is to buy all the tracks on the current album). I created a single product to represent "buy all" and showed it on the page using an EVA view that would show just the one item. Then I wrote a rules action implementing hook_rules_action_info to activate the separate licenses of each track, and triggered this rule on "When an order is first paid in full".
Comment #22
takyros commentedHi guys, looks like this is still a hot thread.. I'm trying to accomplish a very similar task but with some difference:
1) I need quantity widgets next to the checkboxes
2) I would like to have a global price field that could (AJAX?)-update with checking or unchecking
3) I need to group selected product in one big product and be able to show them as one unique product in the cart view
(e.g.
1x product one $20
2x product two $25
1x product three $30 price: $100
)
Has anyone made something similar? I'm stuck on the three fronts..
Comment #23
danzVP06 commented@karma0321, Isn't Product Bundle, Product Attributes, and custom jquery for the computation changes good enough on your end?
Comment #24
onehandsomedog commented@joecanti #11 worked beautifully! Now to add a little #22 to the mix. @karma0321 Did you get it figured out?