E.g

I have 2 products. Both have no price on them. They both also have attributes/options, also with no price.
I create a product kit to group them into one item on the shopping cart and I give this kit a price.

When I save I get the following message (twice because I have 2 products in the kit).

warning: Division by zero in /uc_product_kit/uc_product_kit.module on line 256.

It seems like it doesn't like the product price of 0.00
If I change this to 1.00 (in the 2 products) it will then work.

Comments

longwave’s picture

Title: Product kit price calculation problem » Division by zero in uc_product_kit.module when kit components have no price

Better title.

tr’s picture

So you normally sell the two products for $0 each but when they are bundled together you charge a price for the kit?

tr’s picture

Status: Active » Postponed (maintainer needs more info)

I need to hear more from you to determine whether this is a use case that we intend to support. Products in kits have to be published, which means they can be sold individually. You're clearly not intending that if you set your product prices to zero. The notion behind product kits is that you can bundle products and offer the kit at a discount when compared to the unbundled products. What you're trying to do instead is to sell the kit for *more* than the unbundled products, which breaks the fundamental assumption this module is built on. It will require a lot of changes if we can't make that assumption. So, if you expect a change here please make a case for what you're trying to do and why you can't do it another way.

I'm leaning towards just handling the divide by zero with message saying the products can't have zero price, rather than trying to properly deal with zero price products.

griz’s picture

Status: Closed (won't fix) » Postponed (maintainer needs more info)

On editing a product kit I get the error:

warning: Division by zero in /var/aegir/drupal-6/sites/example.co.uk/modules/ubercart/uc_product_kit/uc_product_kit.module on line 544.

The SKU is lost, the price is zeroed and the customer is blown a kiss:

AEW Horizon Compendium
Manufacturer: AEW
Machines: Horizon
Contents: Manual
SKU:

Complete data pack including MA454 and MA454A above together with 6 works photographs of "show" machines.
Price: £0.00
x

That's a lovely sentiment, but I'm not planning on being quite that nice to my customers.

In my case both the products have a price, and I had assigned an overall price to the kit.

griz’s picture

On correcting this with another edit I got:

user warning: Duplicate entry '304' for key 'PRIMARY' query: INSERT INTO uc_products (vid, nid, model, list_price, cost, sell_price, weight, weight_units, default_qty, unique_hash, ordering, shippable) VALUES (304, 304, 'MA454 / MA454A', 0, 0, 45, 0, 'kg', 0, '9f1d5505a88447e15ba8307acc4ec410', 0, 1) in /var/aegir/drupal-6/sites/lathes.co.uk/modules/ubercart/uc_product_kit/uc_product_kit.module on line 315.

Is there a reason INSERT is used so often in Drupal as opposed to REPLACE?

longwave’s picture

REPLACE is not part of the SQL standard and does not work in (for example) PostgreSQL.

griz’s picture

Ah, that would explain that then. Thanks.

tr’s picture

@griz: Your issue is not that same as the original poster's. The 'Duplicate entry' bug you're reporting is the subject of a different issue: #641430: user warning: Duplicate entry in uc_product_kit.module on line 351. Perhaps you can contribute to that thread to help it get resolved.

longwave’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

No response from the original poster, assuming this is no longer a problem and does not need to be fixed.

tr’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (won't fix)

Restoring status "Closed (won't fix)" which was reset by the automated site upgrade.