Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I tried to make a simple, text-based wish list counter that is linked to the wish list page. Everything goes well if you're logged in, but if anonymous wish lists are enabled, the initial count is always one. Howevery, if you actually add an item and remove it again the counter is set to 0.
This is the code I used:
$wishlist_items = count(uc_wishlist_get_contents()); print t('Wish list (@items)', array('@items' => $wishlist_items));
Thanks for taking a look at this!
Comment | File | Size | Author |
---|---|---|---|
#5 | uc_wishlist-support-anonymous-wishlist-2227851-5.patch | 2.26 KB | berenddeboer |
#3 | uc_wishlist-support-anonymous-wishlist-2227851-3.patch | 1.83 KB | berenddeboer |
Comments
Comment #1
hsiyao CreditAttribution: hsiyao commentedComment #2
berenddeboer CreditAttribution: berenddeboer commentedComment #3
berenddeboer CreditAttribution: berenddeboer commentedYou probably are using the anonymous option in the settings? That won't work.
Have attached a patch that gets rid of this option, and uses the Drupal permission system as used elsewhere in the code. And note that uc_wishlist_get_contents() can return false, the correct code is:
Comment #4
naveenvalechaPatch not applying.
Also we have to delete this variable after this update.So need to write the hook_update to remove this variable from database.Also if this is set to true. Then update the 'create wishlist' permissions and give to anonymous users.
Comment #5
berenddeboer CreditAttribution: berenddeboer commentedHave added update hook, and patch should apply again.
Comment #6
naveenvalechaApplied the patch with minor changes.
This description comes at the update page while updating the module.So I replaced it with "Replaced the anonymous configuration settings with 'create wish lists' permissions."
patch applied and fixed.
Comment #9
naveenvalechaAlso addressed the same in uc_wishlist.pages.inc