?
Solved

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

Posted on 2013-01-22
5
Medium Priority
?
800 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Learn about the eCommerce marketing trends for the year ahead.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Suggested Courses

762 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