Solved

Need to echo content for a specific category in WP-Ecommerce

Posted on 2013-01-22
5
793 Views
Last Modified: 2013-01-25
On a theme I'm using, the single product page has a specific "If" code:

<?php if( wpsc_product_on_special() ) echo '<div class="sale-icon-big">Sale!</div>'; ?>

Open in new window


That's fine.  It means that for special (discounted) items, a div with an on sale badge will show up.

What I need is an addition that would allow for items of a specific category to echo another div.  

<?php elseif( wpsc_products category_id(28) ) echo '<div>Featured</div>'; ?>

Open in new window


I've tried several variations... but I am getting parsing errors on all of them.

So my question, what's the syntax for a specific category to echo content in WP Ecommerce?

The product category ID is 28 and the slug for that category is richards-top-shelf

Support from GetShopped suggested something similar to the following:

<?php if( wpsc_display_products_page (array('category_url_name'=>'richards-top-shelf'))) echo '<div class="topshelfitems"></div>'; ?>

Open in new window


But it didn't limit the "topshelfitems" div to just that category.  It showed up on all items.  And when posted after the "sale-icon-big" div like this...
<?php if( wpsc_product_on_special() ) echo '<div class="sale-icon-big"></div>'; ?>

<?php if( wpsc_display_products_page (array('category_url_name'=>'richards-top-shelf'))) echo '<div class="topshelfitems"></div>'; ?>

Open in new window


...they stopped working correctly at all.
0
Comment
Question by:Power_Pro
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
andy_adams earned 500 total points
Comment Utility
I may be misunderstanding the question, but you might look into the has_term function:

<?php if ( has_term( 'richards-top-shelf', 'wpsc_product_category', get_the_ID() ) ) echo '<div>Featured</div>'; ?>

Let me know if that does it!
0
 

Author Comment

by:Power_Pro
Comment Utility
No joy.

Here's a sample page which is in the category that should get that ribbon (please note this is all dummy content for the sake of configuring and testing everything so none of these items are for sale :D ) ...

http://richardsmusiccloset.com/shop/richards-top-shelf/sony-vaio-red-3/ (no echoed "topshelfitems" div)

Here's a sample page of a discounted item...

http://richardsmusiccloset.com/shop/bamboo/digital-wacom/  (as you can see, the featured image has a badge indicating it's on sale via the echoed "sale-icon-big" div)

Here's what I posted in the individual product page (wpsc-single_product.php):

<?php if( wpsc_product_on_special() ) echo '<div class="sale-icon-big">Sale!</div>'; ?>

<?php if ( has_term( 'richards-top-shelf', 'wpsc_product_category', get_the_ID() ) ) echo '<div class="topshelfitems"></div>'; ?>

Open in new window

0
 
LVL 2

Expert Comment

by:andy_adams
Comment Utility
Just to be clear, is richards-top-shelf a category, or something different? I'm a bit puzzled as to why it wouldn't be displaying if 'richards-top-shelf' is in the 'wpsc_product_category' taxonomy.

The only piece that could be wrong is the get_the_ID() call - is this being called within the loop? Could you paste the surrounding code so I can see the context these snippets are being executed in?

Thanks!
0
 

Author Comment

by:Power_Pro
Comment Utility
I just deleted everything I had in this comment because I retried your answer after making an edit to the CSS that I realized might have been causing a problem with your code not working.

And guess what.  It works!

:D

Thank you so much!!!
0
 

Author Closing Comment

by:Power_Pro
Comment Utility
A fantastic conditional for the WP Ecommerce plugin.  Great work!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Are you using email marketing software? If not, you're missing out on effortless marketing and the reaching of desired conversion rates through email marketing software.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now