Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Permalink issue in Wordpress archive 1 33
Wordpress Carousel Size 1 15
Method for submitting dynamically created rows 20 17
Remove lines by logo 2 23
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

895 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

12 Experts available now in Live!

Get 1:1 Help Now