I have product type "Sub" with two products "sub-a" and "sub-b" and a product type "Main" that references two products of "Sub" with product "main" that references "sub-a" and "sub-b".

sub-a's price is 5.00
sub-b's price is 0.50
main's own price is 1.00

In each and every page (I have a display for it, but also in the cart) main is shown with price "1.00": sum isn't performed. I have made no change at the default rule.

Comments

Elementica’s picture

I've tried everything... following the steps I have:

- made a product type "item"
- made two products "A" and "B" of "item" type
- made a content-type "display item" that references products "item"
- made one display for "A" and one for "B"
- made a product type "kit" with two reference fields to products "item" (with "product bundle: add to cart form")
- made one product "AB" of "kit" type with a price of "0" and referencing "A" and "B"
- made a content-type "display kit" that references products "kit"
- made one display for "AB"

"AB" is shown as a simple product with a standard "Add to cart" button and its price ("0" in my case).

What can I check? I'm not sure what to look at...

Elementica’s picture

I'm also testing the "dev" version, but nope... moreover reverting display settings of referencing fields to "A" and "B" to a simple "Add to cart", display of "AB" gets corrupted (entity wrapper error): taking it back to "product bundle: add to cart form" restores display.

olafkarsten’s picture

Version: 7.x-1.0-alpha5 » 7.x-1.x-dev

Just for sure: check if the rule 'Calculate Bundle Product Price' is active.

Elementica’s picture

Speaking about default rule set by the module... yes: haven't ever disabled it.

I'm not sure what I can check/log to debug this. I think there could be some problems related to "line items"... e.g. I haven't understood the use/meaning of "Bundle Item" line item created by the module...

js’s picture

I am having the same issue. I have three product references that reference multiple products.

The total when added to the cart is correct, but the price in the "product display" never change from the initial default, which is the combined total of the first product within the products. (confusing, isn't it.)

bob.hinrichs’s picture

Same issue here. This was working in the previous version before 7.x-1.0-alpha6, but now it no longer works.

Output of Calculate Bundle Product Price Rule:
44.672 ms Evaluating conditions of rule Unset the price of disabled products in the cart. [edit]
46.558 ms The condition data_is_empty evaluated to TRUE [edit]
46.575 ms AND evaluated to FALSE.
46.611 ms Finished reacting on event Calculating the sell price of a product.

xbrianx’s picture

I seem to be having an issue similar to this, When i select the bundled item and click add to cart, it does not add the main product item to the cart, rather only adds the selected bundle item. Any ideas on this one?

olafkarsten’s picture

Category: bug » support

Can somebody confirm, the issue still exist with the actual dev version from yesterday?

olafkarsten’s picture

Category: support » bug

should be a bug, if it doesn't work

olafkarsten’s picture

In my case it works as long as I set the 'Number of values' for the product reference fields of the product bundle type to 'unlimited' or any number greater than 1. Don't know why, but it works for me.

Susurrus’s picture

Category: support » bug

So, this problem still exists and was causing problems. Changing the number of products that you can reference with a single field as olafkarsten in #10 suggests, fixed the issue for me when viewing the shopping cart block, but not when actually going to checkout. I've found that the correct solution is to run the EntityFieldQuery() in commerce_product_bundle_get_sub_line_items as an administrator as there are permissions issues for anonymous users and EntityFieldQuery uses the permissions of the current user. The fix is to add to the EntityFieldQuery() at commerce_product_bundle.module:1396 a ->addMetaData('account', user_load(1)) line. So mine ends up looking like:

$query = new EntityFieldQuery();
    $entities = $query->entityCondition('entity_type', 'commerce_line_item')
      ->entityCondition('bundle', 'bundle')
      ->addMetaData('account', user_load(1)) // Fixes permission issues for anonymous users.
      ->fieldCondition('commerce_parent_line_item', 'line_item_id', $parent_line_item->line_item_id, '=')
      ->execute();

I'm pretty certain this is a safe operation because this query isn't querying a specific line item, it's querying for the structure behind the line item type.

maciej.zgadzaj’s picture

Issue summary: View changes
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new6.66 KB
new2.26 KB

I had an occasion to briefly play with this module.

And, first thing, I confirm what olafkarsten said in #10, setting Number of values field to Unlimited for ALL product reference fields helps. But it is not really a proper solution in any way.

There are actually 2 issues here, both apply to commerce_product_bundle_calculate_price() function (Calculate the price of a bundle product rule):

1. One is the way $sub_product is being fetched using that funny foreach ($product->{$product_field_name} as $sub_product) loop.

In my case I had 3 product reference fields, 2 of them filled, 3rd one empty. With this loop I was getting product referenced in 2nd field in 3rd field as well. Wrong, as it should be empty there. It was just keeping the old value there, as it never was getting into the loop for the 3rd field (as there was nothing to loop through).

2. Second issue was with prices being used. That $commerce_total['amount'] = $quantity * $sub_product->commerce_price->amount->value(); takes price directly from $sub_product->commerce_price, but this is only the initial price, before any pricing rules are run on it. Again, wrong, as this means no possibility of changing the price through rules, no VAT, no sales tax, no anything.

Attached patch fixes both those issues.

I am not 100% sure that it does everything it should do, haven't played with it long enough, so if anyone feels like testing and confirming that it works (or doesn't, and what exactly then) you'll be more than welcomed!

Also, changing to Major as this is pretty serious. (And yes, it still exists in 7.x-1.x just checked out from git repo.)

Also, the "patch" from #11 is not necessary.

Also, the commerce_product_bundle-bundle_price-1477584-11-exclwl.txt file is not a proper patch, it is there just to make reading it easier, as it does not include white space changes.

maciej.zgadzaj’s picture

maciej.zgadzaj’s picture

Actually, the same changes should be applied to the case when $multiply_by_quantity is not true.

kscheirer’s picture

Priority: Major » Normal
Status: Needs review » Postponed (maintainer needs more info)

Is this still an issue with the latest dev? I committed #2374509: Default total price incrementing by previous referenced product price if product reference field is empty which should solve problem #1 identified above. I do like the way you're using commerce_product_calculate_sell_price() instead of grabbing the value directly. Making this change might also solve some issues that crop up using Entity API without try/catch blocks.

pifagor’s picture

I eroryt previous patch, I corrected it, worked.

pifagor’s picture

Status: Postponed (maintainer needs more info) » Needs review
hunziker’s picture

pifagor’s picture

Issue tags: +Needs tests
unl0ck’s picture

I understand that the module is no longer supported, but it is very suitable for my task. The only problem is with the recalculation of the cost. With the first patch nothing changes, with the second it displays an error. Or maybe someone knows another way to implement similar functionality. Last version Drupal 7 with module drupal commerce

olafkarsten’s picture

Status: Needs review » Closed (outdated)

Closing. No development for D7 anymore.