[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2013-01-22
5
Medium Priority
?
801 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
andy_adams earned 2000 total points
ID: 38811426
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
ID: 38812670
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
ID: 38819752
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
ID: 38821015
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
ID: 38821505
A fantastic conditional for the WP Ecommerce plugin.  Great work!
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
The purpose of this video is to demonstrate how to Import and export files in WordPress. 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 : Click on Too…
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…
Suggested Courses

649 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