Wishlist - Privacy Options - Remove select visibility and set the default wishlist to private

Let's proceed with removing "Wishlist visibiity" select
This will require to overwrite some templates from wishlist default folder: all you have to do is to copy the following files

wp-content/plugins/yith-woocommerce-wishlist-premium/templates/wishlist-manage.php
wp-content/plugins/yith-woocommerce-wishlist-premium/templates/wishlist-create.php
wp-content/plugins/yith-woocommerce-wishlist-premium/templates/add-to-wishlist-popup.php


And paste them under wp-content/themes/<your theme or child folder>/woocommerce/ (you may need to create WooCommerce subdirectory)

Then we need to make some changes to our brand new templates inside theme folder

1. wishlist-manage.php
Remove lines 35-39

<th class="wishlist-privacy">
<span class="nobr">
<?php echo apply_filters( 'yith_wcwl_wishlist_manage_privacy_heading', __( 'Privacy', 'yith-woocommerce-wishlist' ) ) ?>
</span>
</th>

54-56

<td class="wishlist-privacy">
<?php echo apply_filters( 'yith_wcwl_wishlist_manage_default_privacy', __( 'Public', 'yith-woocommerce-wishlist' ) )?>
</td>

and 71-77

<td class="wishlist-privacy">
<select name="wishlist_options[<?php echo $wishlist['ID'] ?>][wishlist_privacy]" class="wishlist-visibility selectBox">
<option value="0" class="public-visibility" <?php selected( $wishlist['wishlist_privacy'], 0 ) ?> ><?php echo apply_filters( 'yith_wcwl_public_wishlist_visibility', __( 'Public', 'yith-woocommerce-wishlist' ) )?></option>
<option value="1" class="shared-visibility" <?php selected( $wishlist['wishlist_privacy'], 1 ) ?> ><?php echo apply_filters( 'yith_wcwl_shared_wishlist_visibility', __( 'Shared', 'yith-woocommerce-wishlist' ) )?></option>
<option value="2" class="private-visibility" <?php selected( $wishlist['wishlist_privacy'], 2 ) ?> ><?php echo apply_filters( 'yith_wcwl_private_wishlist_visibility', __( 'Private', 'yith-woocommerce-wishlist' ) )?></option>
</select>
</td>

Fianlly change line 92 from this

<td colspan="3">

to this

<td colspan="2">

2. wishlist-create.php
Remove lines 31-35

<select name="wishlist_visibility" class="wishlist-visibility selectBox">
<option value="0" class="public-visibility"><?php echo apply_filters( 'yith_wcwl_public_wishlist_visibility', __( 'Public', 'yith-woocommerce-wishlist' ) )?></option>
<option value="1" class="shared-visibility"><?php echo apply_filters( 'yith_wcwl_shared_wishlist_visibility', __( 'Shared', 'yith-woocommerce-wishlist' ) )?></option>
<option value="2" class="private-visibility"><?php echo apply_filters( 'yith_wcwl_private_wishlist_visibility', __( 'Private', 'yith-woocommerce-wishlist' ) )?></option>
</select>

3. add-to-wishlist-popup.php
Remove lines 66-72

<div class="yith-wcwl-visibility">
<select name="wishlist_visibility" class="wishlist-visibility">
<option value="0" class="public-visibility"><?php echo apply_filters( 'yith_wcwl_public_wishlist_visibility', __( 'Public', 'yith-woocommerce-wishlist' ) )?></option>
<option value="1" class="shared-visibility"><?php echo apply_filters( 'yith_wcwl_shared_wishlist_visibility', __( 'Shared', 'yith-woocommerce-wishlist' ) )?></option>
<option value="2" class="private-visibility"><?php echo apply_filters( 'yith_wcwl_private_wishlist_visibility', __( 'Private', 'yith-woocommerce-wishlist' ) )?></option>
</select>
</div>

Now every "Wishlist Privacy" select should be removed from your site

Fianlly, we have to set default visibility as private: we will do this using a filter
Unfortunately, currently this filter does not exists, so we will have to add it to plugin code (it will be released within next plugin revision)

So here a couple of steps to follow:
1. download attached files, and upload them under wp-content/plugins/yith-woocommerce-wishlist-premium/includes/, overwriting previous version (please, don' forget to make a backup copy, just in case :) )
2. add the following code to functions.php file of your theme/child theme

if( defined( 'YITH_WCWL' ) && ! function_exists( 'yith_wcwl_change_wishlist_privacy' ) ){
function yith_wcwl_change_wishlist_privacy(){
return 2;
}

add_filter( 'yith_wcwl_add_wishlist_privacy', 'yith_wcwl_change_wishlist_privacy' );
add_filter( 'yith_wcwl_default_wishlist_privacy', 'yith_wcwl_change_wishlist_privacy' );
}

And that's all

Was this article helpful?
0 out of 0 found this helpful

Back to Help Center

Powered by Zendesk