This patch adds three new actions for use with Views Bulk Operations, loosely based on the uc_views code for 6.x-2.x.

- add product to cart
- print invoice
- set order status

CommentFileSizeAuthor
uc_vbo.patch2.65 KBlongwave
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Neo13’s picture

Will this patch be implemented in core?

longwave’s picture

Yes, if someone (like you!) tests it and confirms that it works.

Neo13’s picture

If you could please post it as patched module in .zip file I would be happy to test it.

longwave’s picture

See http://drupal.org/patch/apply to learn how to apply patches.

Neo13’s picture

I have tried, but I wasnt succesful in patching uc_order.module and just uc_product was patched. If you cant post .zip then I will try again later.

Neo13’s picture

The problem was that I wasnt using dev version of Ubercart. Now I patched it and it works like a charm :)

Neo13’s picture

Status: Needs review » Reviewed & tested by the community
longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

natuk’s picture

Status: Closed (fixed) » Active

Forgive me for reopening this but I think there is a problem with this function:

function uc_product_action_add_to_cart($product, $context = array()) {
  uc_cart_add_item($product->nid);
}

What happens is that if this action is used in VBO to add multiple items in the cart for an order, in many cases we would want the customer to land in the cart page after submitting the form. This can be done, for example, with the ?destination=cart on the url. VBO is supposed to honour the destination parameter after submission of the form. However, it seems that only the first item of the selected ones is added to the cart. I think this is because of the default parameters of uc_cart_add_item. The sixth parameter is by default set to TRUE and I think that when the function discovers the ?destination=cart it jumps to it straight away and does not let VOB to carry on with processing the rest of the items.
If instead we write:

function uc_product_action_add_to_cart($product, $context = array()) {
  uc_cart_add_item($product->nid, 1, NULL, NULL, TRUE, FALSE, TRUE);
}

(sixth parameter is FALSE) the problem disappears. I.e. there is no redirection by the uc_cart_add_item and therefore VBO carries on and redirects when done.
Thanks to Lee Rowlands for the pointer.

longwave’s picture

Status: Active » Fixed

Committed the improvement in #10, thanks.

Status: Fixed » Closed (fixed)

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

DrCord’s picture

Issue summary: View changes

This seems to have been put into VBO core.

truyenle’s picture

patch already committed to version 7.x-3.9. Work for me.