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!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hsiyao’s picture

Issue summary: View changes
berenddeboer’s picture

Assigned: Unassigned » berenddeboer
berenddeboer’s picture

Status: Active » Needs review
FileSize
1.83 KB

You 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:

$wishlist_contents = uc_wishlist_get_contents();
$wishlist_items = $wishlist_contents ? count(uc_wishlist_get_contents()) : 0;
print t('Wish list (@items)', array('@items' => $wishlist_items));
naveenvalecha’s picture

Status: Needs review » Needs work
Issue tags: -wishlist +Needs reroll

Patch not applying.

+++ b/uc_wishlist.admin.inc
@@ -23,12 +23,6 @@ function uc_wishlist_admin_settings_form($form, &$form_state) {
-    '#default_value' => variable_get('uc_wishlist_allow_anonymous', FALSE),

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.

berenddeboer’s picture

Status: Needs work » Needs review
FileSize
2.26 KB

Have added update hook, and patch should apply again.

naveenvalecha’s picture

Category: Bug report » Task
Status: Needs review » Fixed
Issue tags: -Needs reroll

Applied the patch with minor changes.

+++ b/uc_wishlist.install
@@ -143,3 +143,14 @@ function uc_wishlist_update_7000() {
+/**
+ * Drop removed variable.
+ */

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.

  • naveenvalecha committed 9869c21 on 7.x-1.x
    Issue #2227851 by berenddeboer: initial anonymous wishlist count = 1
    

  • naveenvalecha committed cfb83f7 on 7.x-1.x
    Quick fix of the wishlist access bypass problem.Referenced with Issue #...
naveenvalecha’s picture

Also addressed the same in uc_wishlist.pages.inc

  • naveenvalecha committed 9869c21 on
    Issue #2227851 by berenddeboer: initial anonymous wishlist count = 1
    
  • naveenvalecha committed cfb83f7 on
    Quick fix of the wishlist access bypass problem.Referenced with Issue #...

Status: Fixed » Closed (fixed)

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