Answers.Body: <p>I have confirmed this would indeed appear to be a bug in Commerce.</p>
  
  <p>A quick workaround would be to listen to login events and call some sort of update cart hack, but this is really a fix that should happen at the Commerce end of things.</p>
  
  <p>I'll report it.</p>
  
  <p>EDIT: Luke Holder comfirms he's found the bug and it will be fixed in the next point release coming soon.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-14T04:58:10.880Z
Answers.Text: Any suggestions on the update cart hack ?
  
  Have tried the following on login: 
  * adding & removing items from cart eg: `craft()->commerce_cart->removeFromCart(...)
  craft()->commerce_cart->addToCart(...)`
  * updating the cart using saveOrder eg: `craft()->commerce_lineItems->updateLineItem(...)
  $order->setShouldRecalculateAdjustments(true);
  craft()->commerce_orders->saveOrder($order);`
  * run Adjusters again eg: `Commerce_DiscountAdjuster->adjust(..)`
  
  Was just about ready to hand over the finished site when I stumbled accross this issue
Answers.UserDisplayName: celeste.nexus
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-14T05:15:59.203Z
Answers.Text: hmm if it is that urgent I'd contact Luke Holder on slack for assistance.  I note that when an address is changed on the cart it does a recalc for sure, so in our case the discount is applied then anyway, butit's far from ideal.  (You'd probably need to ajax do this hack on the cart page and then load in the updated details...)
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-14T06:56:03.830Z
Answers.Text: See above, a fix will be along soon
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-14T00:46:53.173Z
Answers.LastActivityDate: 2017-06-14T06:55:47.933Z
Answers.LastEditDate: 2017-06-14T06:55:47.933Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>I've run accross an issue that seems like a bug to me and I'm desperately looking for some help to solve it. </p>
  
  <p>I've created user groups in Craft &amp; Discounts applicable to those user groups in Craft Commerce.</p>
  
  <ol>
  <li>a user lands on the site and adds items to his cart &amp; proceeds to checkout</li>
  <li>the user is prompted to login or register </li>
  <li>the user logs in OR registers 
  3a. upon registration the user is activated &amp; auto logged in with the 'autoLoginAfterAccountActivation' => true config option</li>
  <li>the user is redirected back to his cart - at this point in time I'm expecting to see a discount adjustment on the cart</li>
  </ol>
  
  <p>The problem is that there is no discount adjustment on the cart - the only way the discount adjustment kicks in is if the cart is updated, by adding or removing an item ie: updateCart is fired. </p>
  
  <p>I've double checked my discount rules &amp; they are definitely setup correctly - the problem is that the users cart is "remembered" from before he was registered ie: before he was part of a user group that is eligible for a discount. </p>
  
  <p>I'm looking for a way to "force" a cart refresh of some sorts. </p>
  
Tags: <plugin-craftcommerce>
Title: User group discount not applied when user has existing cart
ThreadText: # User group discount not applied when user has existing cart
  
  (Asked by: username_0 on 2017-06-13)
  
  I've run accross an issue that seems like a bug to me and I'm desperately looking for some help to solve it.
  
  I've created user groups in Craft & Discounts applicable to those user groups in Craft Commerce.
  
  1. a user lands on the site and adds items to his cart & proceeds to checkout
  2. the user is prompted to login or register
  3. the user logs in OR registers
     3a. upon registration the user is activated & auto logged in with the 'autoLoginAfterAccountActivation' => true config option
  4. the user is redirected back to his cart - at this point in time I'm expecting to see a discount adjustment on the cart
  
  The problem is that there is no discount adjustment on the cart - the only way the discount adjustment kicks in is if the cart is updated, by adding or removing an item ie: updateCart is fired.
  
  I've double checked my discount rules & they are definitely setup correctly - the problem is that the users cart is "remembered" from before he was registered ie: before he was part of a user group that is eligible for a discount.
  
  I'm looking for a way to "force" a cart refresh of some sorts.
  
  **Tags:** plugin-craftcommerce
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-14. Score: 1 | Accepted answer
  
  I have confirmed this would indeed appear to be a bug in Commerce.
  
  A quick workaround would be to listen to login events and call some sort of update cart hack, but this is really a fix that should happen at the Commerce end of things.
  
  I'll report it.
  
  EDIT: Luke Holder comfirms he's found the bug and it will be fixed in the next point release coming soon.
  
  > **Comments:**
  > **username_0**: Any suggestions on the update cart hack ?  Have tried the following on login:  * adding & removing items from cart eg: `craft()->commerce_cart->removeFromCart(...) craft()->commerce_cart->addToCart(...)` * updating the cart using saveOrder eg: `craft()->commerce_lineItems->updateLineItem(...) $order->setShouldRecalculateAdjustments(true); craft()->commerce_orders->saveOrder($order);` * run Adjusters again eg: `Commerce_DiscountAdjuster->adjust(..)`  Was just about ready to hand over the finished site when I stumbled accross this issue  
  > **username_1**: hmm if it is that urgent I'd contact Luke Holder on slack for assistance.  I note that when an address is changed on the cart it does a recalc for sure, so in our case the discount is applied then anyway, butit's far from ideal.  (You'd probably need to ajax do this hack on the cart page and then load in the updated details...)  
  > **username_1**: See above, a fix will be along soon  
  
  ---
  
  