Closed (works as designed)
Project:
Ubercart
Version:
7.x-3.11
Component:
Cart/checkout
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jun 2018 at 13:00 UTC
Updated:
21 Jun 2018 at 06:51 UTC
Jump to comment: Most recent
Comments
Comment #2
tr commentedComment #3
tr commenteduc_cart_get_total_qty()is just a convenience function wrapper arounduc_cart_get_contents(), so it's no surprise that they give you the same answer. Note thatuc_cart_get_total_qty()was never really used, and has been removed for D8, so you should useuc_cart_get_contents()(In D8 this is\Drupal::service('uc_cart.manager')->get()->getContents()).The cart is cached, so it needs to be refreshed if you add or delete items. Refreshing/reloading is an expensive operation so it's not done automatically, only when needed. This is done properly within Ubercart, but if you use the Ubercart API on your own you need to take special care to refresh the cart cache when needed. (In D8, this has been changed and you no longer need to explicitly refresh the cached cart.)
Anyway, if you use
count(uc_cart_get_contents(NULL, 'rebuild'))you should get the correct value in this situation.Comment #4
Dor@ commentedThank you it is fine now. Should I change the status to closed->works as designed?
Comment #5
Dor@ commentedComment #6
tr commentedGlad it works for you.