Solved

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

Posted on 2013-01-22
5
799 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How important is it to take extra precautions to protect your online business? These are some steps you can take to make sure you're free of any cyber crime.
Businesses who process credit card payments have to adhere to PCI Compliance standards. Here’s why that’s important.
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

695 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