Welcome to our community support forums! We're here to help - but if you have an urgent request for a Pro Plugin, you will get a prioritised response through our Premium Support page.
I have the same question. The directions for editing the product-template.php file are very clear, but not these. Can you please describe the surrounding code and exactly where it needs to go?
No matter what I was trying, I couldn’t get the guest visibility to work. I had to copy the wpsc_wp_is_product_visible() function, rename it, and make changes to it in my own functions.php file to get it to work.
I’m not sure if it will help anyone on here, but hopefully it will. The changes I made will request the post data for all user roles (including guest, which wasn’t happening before). In order to get this to work, do the following steps in order.
Just be advised, for any update after the 3.8 version of WP-eCommerce, this fix MAY break if they decide to make changes to the way their built in function works. When that happens, you will have to go back and change these back to the way they suggested.
1.) Copy the following to your ‘functions.php’ file in your theme directory and then save the file
function sp_wpsc_wp_is_product_visible()
{
// Check if the user is logged in
if(is_user_logged_in())
{
global $current_user;
get_currentuserinfo();
$role = $current_user->roles[0];
}
else
{
$role = ‘guest’;
}
// Get the product information
switch(wpsc_get_major_version())
{
case ‘3.7’:
$checkbox = get_product_meta( wpsc_the_product_id(), ‘wpsc_wp_checkbox’, true );
break;
case ‘3.8’:
global $post;
$post_id = $post->ID;
if(!$post_id)
$post_id = $product_id;
$product_data = get_post_custom($post_id);
$product_data[‘meta’] = maybe_unserialize($product_data);
if($product_data[‘meta’])
{
foreach($product_data[‘meta’] as $meta_key => $meta_value)
$product_data[‘meta’][$meta_key] = $meta_value[0];
$product_meta = maybe_unserialize($product_data[‘_wpsc_product_metadata’][0]);
// See if the visibility is actuall enabled
if($checkbox[$role] == ‘on’)
{
// User per-Product visibility for that User Role, including Site Visitors
switch(wpsc_get_major_version())
{
case ‘3.7’:
$visibility = get_product_meta( wpsc_the_product_id(), ‘wpsc_wp_visibility’, true );
break;
default:
case ‘3.8’:
$visibility = $product_meta[‘wpsc_wp_visibility’][$role];
break;
}
switch($visibility)
{
case ‘0’:
return false;
break;
bnance63, if you want to just use their built in function, you can just skip the first step and follow steps 2 and 3 using ‘wpsc_wp_is_product_visible()’ instead of ‘sp_wpsc_wp_is_product_visible()’.
I tried this solution above and it breaks my theme. I’m just using the basic WordPress 2011 theme on the latest 3.3 install of WordPress, 3.8 WP Ecommerce plugin and the most recent Wholesale Pricing plugin. I desperately need to hid products for wholesale customers only on my client’s site. Any help would be greatly appreciated.
Author
Posts
Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Support’ is closed to new topics and replies.