Hi. How can we help?

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 52-67

<th class="wishlist-privacy"> 
<span class="nobr">
<?php
/**
* APPLY_FILTERS: yith_wcwl_wishlist_manage_privacy_heading
*
* Filter the heading of the column to show the Wishlist privacy in the Wishlists table.
*
* @param string $heading Heading text
*
* @return string
*/
echo esc_html( apply_filters( 'yith_wcwl_wishlist_manage_privacy_heading', __( 'Privacy', 'yith-woocommerce-wishlist' ) ) );
?>
</span>
</th>

212-218

<td class="wishlist-privacy"> 
<select name="wishlist_options[<?php echo esc_attr( $wishlist->get_id() ); ?>][wishlist_privacy]" class="wishlist-visibility selectBox">
<option value="0" class="public-visibility" <?php selected( $wishlist->get_privacy(), 0 ); ?> ><?php echo wp_kses_post( yith_wcwl_get_privacy_label( 0 ) ); ?></option>
<option value="1" class="shared-visibility" <?php selected( $wishlist->get_privacy(), 1 ); ?> ><?php echo wp_kses_post( yith_wcwl_get_privacy_label( 1 ) ); ?></option>
<option value="2" class="private-visibility" <?php selected( $wishlist->get_privacy(), 2 ); ?> ><?php echo wp_kses_post( yith_wcwl_get_privacy_label( 2 ) ); ?></option>
</select>
</td>

2. wishlist-create.php
Remove lines 32-45

<p class="form-row form-row-wide wishlist-privacy-radio"> 
<label>
<input type="radio" checked="checked" name="wishlist_visibility" class="wishlist-visiblity" value="0"/>
<?php echo wp_kses_post( yith_wcwl_get_privacy_label( 0, true ) ); ?>
</label>
<label>
<input type="radio" name="wishlist_visibility" class="wishlist-visiblity" value="1"/>
<?php echo wp_kses_post( yith_wcwl_get_privacy_label( 1, true ) ); ?>
</label>
<label>
<input type="radio" name="wishlist_visibility" class="wishlist-visiblity" value="2"/>
<?php echo wp_kses_post( yith_wcwl_get_privacy_label( 2, true ) ); ?>
</label>
</p>

3. add-to-wishlist-popup.php
Remove lines 181-194

<p class="form-row form-row-wide">
<label>
<input type="radio" name="wishlist_visibility" value="0" class="public-visibility wishlist-visibility" <?php checked( true ); ?> />
<?php echo wp_kses_post( yith_wcwl_get_privacy_label( 0, true ) ); ?>
</label>
<label>
<input type="radio" name="wishlist_visibility" value="1" class="shared-visibility wishlist-visibility"/>
<?php echo wp_kses_post( yith_wcwl_get_privacy_label( 1, true ) ); ?>
</label>
<label>
<input type="radio" name="wishlist_visibility" value="2" class="private-visibility wishlist-visibility"/>
<?php echo wp_kses_post( yith_wcwl_get_privacy_label( 2, true ) ); ?>
</label>
</p>

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

Finally, we have to set default visibility as private by adding the following code snippet to the functions.php file of your active theme (wp-content/themes/<your theme or child folder>/functions.php): 

if ( ! function_exists( 'yith_wcwl_set_default_wishlist_private' ) ) {

function yith_wcwl_set_default_wishlist_private( $privacy ) {

$privacy = 2;
return $privacy;

}
add_filter( 'yith_wcwl_default_wishlist_privacy', 'yith_wcwl_set_default_wishlist_private' );
}

And that's all

Was this article helpful?
1 out of 15 found this helpful

Back to Help Center >