I have added a few simple discounts like all products from a certain brand (category) get a 10% product discount. My discounts are shown/calculated fine 70% of the time, but 30% of the time (or even more) they are NOT calculated. When I refresh my browser, they aren't calculated, when I refresh again they are calculated. It's like toggling between discount and no discount just by refreshing the browser (cmd+r).
But the most bizar thing I see in my shopping cart. I use the normal view with a few lay-out changes. My product is the field (Line items referenced by commerce_line_items) Commerce Line item: Product (Product) - Formatter: rendered product, View mode: Line item. I added the price to the Line item display, just for debugging.
Prices are shown as Formatted amount with savings.
Normal view:
Discount is calculated on the price per item and the total product price, but not on my rendered product display (with the image)

After refresh or status update or next time you go to your shoppingcart (or during checkout)
Discount is NOT calculated on the price per item and the total product price, so the user does not get the discount price, but not on my rendered product display (with the image) the discount is calculated !!

When the discount is calculated in my shoppingcart and I go to checkout, the discount isn't calculated anymore in the order review . Or the other way round.
What is happening here ? How can I fix this ? Is this a bug somewhere? I have a few stores with commerce kickstart, never had this problem. This is the first store without Kickstart. If I compare my views, displays, modules and more with my other stores, I can't find a difference.
I don't have any errors in dblog,
I did not change anything to the price calculation rule.
I use normal Drupal Commerce, not Kickstart
- Commerce Discount 7.x-1.0-alpha7 + Commerce Discount Date + Commerce Discount Usage
- Commerce Discount Product Category 7.x-1.2
- Commerce Price Savings Formatter 7.x-1.4
| Comment | File | Size | Author |
|---|---|---|---|
| View_shoppingcart_2.png | 36.91 KB | fotograafinge | |
| View_shoppingcart_1.png | 37.63 KB | fotograafinge |
Comments
Comment #2
fotograafinge commentedComment #3
torgospizzaHave either of you tested with the latest -dev version of Discount?
For the OP: What happens if you disable the price savings formatter module?
Comment #4
fotograafinge commentedI have uninstalled the alpha version, cleaned the remains in the DB, and installed the latest dev version. But ... doesn't help.
I uninstalled Commerce Price Savings Formatter, but also does not help.
Comment #5
fotograafinge commentedAlso no difference when I disable Commerce Discount Date and Commerce Discount Usage, and uninstall Commerce Discount Product Category 7.x-1.2
Comment #6
dmsmidtI have the same problem, but it seems to only exist for anonymous users.
Commerce 1.13
Commerce Discount 1.0-alpha8
Commerce Discount Extra 1.0-rc4
Commerce Coupon 2.0-rc2
Commerce Vat 1.0-rc2
Comment #7
dmsmidtThis actually is a major problem
Comment #8
joelpittetLet's work on the latest -dev release because that is where things happen. If you are not using that version please try it. Also, though frustrating, it's hard to fix something that is not reproducible, please add the conditions that it takes to reproduce the bug in the issue summary. Thanks for putting the version numbers in the issue summary as those should help narrow down the problem.
Also is it reproducible without Commerce Discount Extra or Coupon? knocked it back to Normal because it's not clear yet that this is an issue of commerce discount and not something else in a custom or integration module.
Comment #9
dave-at-sherpa commentedJust noticed I'm having the same issue, although unlike dmsmidt (#6), it seems to be happening for all roles, not just anonymous users. BUT, as ridiculous as this sounds, it's only occuring on my dev site, not on my production site, even though all modules and discounts are the same. I noticed it in the dev site while I was testing out a new discount, but saw that it wasn't happening on the prod site. So I set everything in the dev site back to what it was, so it exactly matches the prod site again, but it's still happening. To make matters worse, it seems to be disregarding all compatibility definitions and applying three discounts at the same time. I played around with sort order, but nothing changed.
Drupal 7.51
Commerce 1.13
Commerce Discount 1.0-alpha8
Commerce Discount Extra 1.0-rc4
Commerce Coupon 1.0-beta7
Discount 1 = 20% off regular price of Item A
Discount 2 = 40% off regular price of Item A for [commerce-line-item:quantity] greater than 9; not compatible with Discount 1.
Discount 3 = $6.40 off discounted price of Item A for [commerce-line-item:quantity] greater than 9; only compatible with Discount 1.
Comment #10
dave-at-sherpa commentedUpdated to the latest dev release of Commerce Discount, ran update.php, flushed cache, flushed again.
When I enter checkout, the regular price is displayed with no discounts applied. Hit refresh, all 3 discounts are applied. When I view the log for the first event (where only the reg price is displayed), it shows the compatibility checks for all 3 discounts as False, False, False. But the log for the second event (where all 3 discounts are displayed), it shows True, True, True. It should be False, True, False for a quantity of 11, or True, False, True for a quantity of 1.
Comment #11
dmsmidt@dave, do you have differences in Drupal caching settings or PHP opcache/apcu between dev and prod?
Comment #12
dave-at-sherpa commented@dmsmidt, I did have a difference in Drupal cache settings at first, but then I set the dev site like the prod site. No difference. Hitting refresh while viewing /cart or /checkout/* is, as OP said, like flipping a switch. [FWIW, sales tax with location condition (via commerce_tax 1.13) is correctly calculated every time... hooray]
Re: opcache/apcu - sorry, that's out of my league. Both sites (dev & prod) are running off the same server, so I'm assuming there is no difference.
Comment #13
joelpittetMaybe there is a PHP or MySQL configuration difference between the two? Could you compare your php.ini values and my.cnf values between the two environments to rule that out?
Comment #14
dave-at-sherpa commented@joel, both sites are on the same shared server at Inmotion, and both are configured by the same recursive php.ini. But---because of the shared server situation---I'm unable to access the my.cnf. [I only know this because I was recently trying to solve the max_allowed_packet problem and ran into a brick wall.]
What's the best next move? Clone the prod site and see if I can recreate the error? Uninstall modules on the dev site? Roll back the dev site to see if I can pinpoint exactly when it happened? As this and my previous posts have made clear, my knowledge/abilities are fairly limited.
Comment #15
joelpittetIdeally it would be great if you could reproduce with the least amount of extra modules on something like https://simplytest.me/project Failing that clone production and replace dev and see if you can reproduce the problem.
Comment #16
jonaskills commentedI am having the exact same issue on my Drupal Commerce site. I can replicate this issue with a fresh install of Commerce Kickstart 7.x-2.40 and Commerce Discount 7.x-1.0-alpha8 locally with absolutely no changes, simply creating the discount. I can also confirm this is happening in a production environment (https://bookstore-prd.umn.edu), the site is not live yet if you want to test it there - by adding an apparel product to your cart.
The discount I created is 25% OFF APPAREL, Product discount, Product type = Apparel, % off 25, Discount dates, 11/01/2016 - 12/31/2016, Discount compatibility Not with any other discounts.
Once the product is added the cart you the discount applied can be toggled on and off by refreshing the page.
Commerce Discounts has been the biggest pain to work with, it hasn't worked at all - various bugs - since we have begun developing our Drupal Commerce site. I have put off looking at it hoping things would get sorted, unfortunately not the case. These seem like rather critical bugs as well. Discounts do not work at all.
-Tom
Comment #17
torgospizza@Tom (jonaskills): Can you set the discount's Compatibility to "Any other discount" and then see if the problem persists?
If that's the case, I suspect your issue is possibly related to #2621526: Compatibility settings other than "all" causes Discount+Coupon to be removed.
Comment #18
jonaskills commented@torgosPizza, Updated the Discount compatibility to Any discount and it appears to be working as expected now. Looking at the issue you posted in #17. Thank you much!
-Tom
Comment #19
skwashd commentedThis is a duplicate of #2621526: Compatibility settings other than "all" causes Discount+Coupon to be removed.