When used with Commerce Customizable Products module, a discount is not applied to that specific item at checkout.

I am using commerce discount module with the lastest dev, along with the coupon module's latest version. Also Commerce Customizable Products 7.x-1.0-beta2, the lastest release.

When a coupon is entered during checkout, it is applied to all products that do not use commerce custom product fields . However, any item in checkout that has commerce custom product fields (and they have been filled out), the discount is not applied to these products only. All other products still get the discount.

In the event the item has the custom fields, but they are not filled out, the coupon works.
In the event there is only one item in the checkout, and it has custom fields and they are filled out, the coupon gives the applied message on screen (but it doesnt actually display the discounted amount, nor apply it).

No error message is given on screen or in the logs.

I have tried every which way, and discounts are only not applied to the products with custom fields that have been filled out by the customer. Every other product works fine.

I added the fields per the Commerce Guys Tueday video: http://www.commerceguys.com/resources/articles/272 , so nothing strange there.

Comments

mach5_kel’s picture

Issue summary: View changes
mach5_kel’s picture

grammer

mach5_kel’s picture

I attempted to manually adjust the order, by finding the order number, choosing edit.

I choose "fixed amount discount", add line item.

I got the following error when I clicked save. (And no discount was applied).

Notice: Undefined property: stdClass::$commerce_unit_price in commerce_line_item_manager_validate() (line 1228 of /home/content/35/12580935/html/sites/all/modules/commerce/modules/line_item/commerce_line_item.module).

mr.andrey’s picture

I'm experiencing the same thing.

drupal_simply_amazing’s picture

StatusFileSize
new53.26 KB
new65.73 KB

I got the same bugs. When using Commerce Customizable Products the discount is not applied on checkout.

drupal_simply_amazing’s picture

StatusFileSize
new23.51 KB

We've figure out that you just need to include the line items you created using the Commerce Customizable Products "admin/commerce/store/discounts/settings".

joelpittet’s picture

Category: Bug report » Support request

@drupal_simply_amazing so this is resolved according to #6?

mglaman’s picture

Component: Code » Documentation
Issue tags: +Commerce Sprint

Changing component to documentation. This is a huge documentation pitfall that I forget all the time. Tagging for weekly sprint to see if someone can get the documentation node updated about custom line items and discounts. Or maybe we could make it a feature request to automatically include all product line item types?

mglaman’s picture

Title: Conflict with Commerce Customizable Products Module » Support all product line item types automatically
Component: Documentation » Code
Category: Support request » Feature request

So I was thinking on this issue and realized it isn't just for Commerce Customizable Products created line items. This issue affects all custom product line item types. I'm proposing we change the default value of commerce_discount_line_item_types to include all line items returned from commerce_product_line_item_types().

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new1.61 KB

here is a patch which allows all product line item types, sans the Commerce Discount product_discount type.

Status: Needs review » Needs work

The last submitted patch, 10: support_all_product-2410283-10.patch, failed testing.

mglaman’s picture

Status: Needs work » Needs review
StatusFileSize
new1.15 KB
new2.59 KB

Fix some logic for checking line item bundles and enabled bundles.

joelpittet’s picture

That looks reasonable, I guess we can't auto-include them if new types are added?

mglaman’s picture

:) rszrama had the same question. I think we could listen in on hook_modules_enabled() for ones provided in code to automatically add them if variable is saved, ditto to hook_commerce_custom_product_line_item_type_insert().

Want me to roll patch that does this? It makes sense. But at same time I'm 99% against modifying a saved variable if someone has already gone and saved the form its in (or saved it.)

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

I'm not sure it's a good idea, it was just a thought so we cover our bases.

RTBC, @rszrama can commit if he's ok with this.

jkuma’s picture

Status: Reviewed & tested by the community » Needs work

This patch is a good working approach to solve this issue but it doesn't remove the logic. it would be nice to get rid of "$line_item_types" var and remove the logic around it.

mglaman’s picture

Title: Support all product line item types automatically » Support all product line item types automatically by default.
Status: Needs work » Needs review

jkuma, #16 doesn't make sense. We still want it to be configurable. Maybe the title of the issue needs to be changed to "by default."

jkuma’s picture

Status: Needs review » Reviewed & tested by the community

Ok mglaman,

I thought you wanted to completely remove this configuration setting. The code looks good to me, i'm re-updating this issue to RTBC.

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks for all the -dev

  • joelpittet committed b43d9c2 on 7.x-1.x authored by mglaman
    Issue #2410283 by mglaman, drupal_simply_amazing, mach5_kel, joelpittet...

Status: Fixed » Closed (fixed)

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