Tags/topics: 
2
Answers
Vote up!
0
Vote down!

Rules - Looping Line Item Quantity

I have a product type "Gift Pack" which has three types available– small, medium and large, respectively £50, £60 and £70. The idea is when a gift pack is purchased a Coupon is created with the corresponding value for each of the purchased gifts.

So far (with rules) I am able to create a new coupon for each of the packs but there is an issue in that I can only loop over the line items and not the quantity of line items. So if a customer buys 3 small gifts and 2 large gifts my rule only generates 1 small coupon and one large coupon as the line items are bundled together in the loop.

Similarly, on another product type, upon checkout I need to generate 3 nodes for each product purchased. Again my rule can not loop through multiple quantities of the same line item.

I've read a few other posts which get into custom module development and areas of PHP which are a little over my head at the moment. I get Rules but don't know if the above can be achieved with a standard Rules approach.

There could be a bounty available here if anyone is up for the challenge.

David

Asked by: dsinnet
on October 29, 2013

Comments

2 Answers

Vote up!
1
Vote down!

Not sure this is a complete answer to your exact problem, but I did notice there is a new gift card module released a few days ago ...

https://drupal.org/project/commerce_gc

It works with coupon 2.x and might answer some of your needs.

Josh Miller
Answer by: Josh Miller
Posted: Nov 1, 2013

Comments

Hey. Thanks for the response. Unfortunately the commerce_gc module seems way off. I tried installing and received a host of errors. Just going to track back to see exactly whats happened and feed back to the module development.

- dsinnet on November 3, 2013
Vote up!
0
Vote down!

For anyone interested. The closest workaround I could fine was using views bulk operations to run the action on a list of line items. Strange that the same list wasn't available to rules directly. I'm sure someone with a bit more expertise could have figured it out.

The only down side is that this now create a manual step in the process which is "Generate Coupons".

Drop me a line if interested.

David

Answer by: dsinnet
Posted: Nov 6, 2013