Sorting in shortcode wpsc_products

This topic is: not resolved

This topic contains 4 replies, has 3 voices, and was last updated by  glenbod 2 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
Author Posts
Author Posts
September 5, 2010 at 1:54 pm #150195

danstegman

I have a client who isn’t happy with the layout of a full product list, and she wants it broken down by category. Not an ideal solution, but that’s what the client wants. If I do a regular products-page, I can drag and drop the items to her satisfaction, but if I break it down by category, it reverts to sorting the items by date entered. Is there a way to specify in the short code how you want them sorted? I’ve tried doing a drag and drop sort inside of each product category, but that doesn’t seem to change it.

The shortcodes I’m using are like this:

[wpsc_products category_url_name='apparel']

Is there a way to add a sort=”dragndrop” or some such in there? Haven’t found it in the docs.

Thanks in advance,

Dan Stegman

April 11, 2011 at 7:19 pm #150196

cheey2003

1. (WPeC version 3.8) Go to wpsc-includes > shortcode.functions.php
2. Edit the sort_order and order settings for the shortcode

function wpsc_products_shorttag($atts) {
	$query = shortcode_atts(array(
		'product_id' => 0,
		'old_product_id' => 0,
		'product_url_name' => null,
		'product_name' => null,
		'category_id' => 0,
		'category_url_name' => null,
		'tag' => null,
		'price' => 0, //if price = 'sale' it shows all sale products
		'limit_of_items' => 0,
		'sort_order' => null, // author,date,title,modified,parent,ID,rand,comment_count
		'order' => 'ASC', // ASC or DESC
		'number_per_page' => 0,
		'page' => 0,
	), $atts);

Note: As this method requires overwriting an existing include file, you may need to edit the file every WPeC update.

May 7, 2011 at 8:35 pm #150197

glenbod

thanks Cheey2003. worked like a charm. i don’t see why the sorting stops working for other templates, but thanks!

May 7, 2011 at 8:45 pm #150198

glenbod

Stop the lorry !!! If you don’t want to change the code: The code gave me the answer.
You can add to [wpsc_products category_url_name='NAME OF YOUR CATEGORY'] any of the following with an argument (I haven’t tried them all to see the effect):

`’product_id’ => 0,
‘old_product_id’ => 0,
‘product_url_name’ => null,
‘product_name’ => null,
‘category_id’ => 0,
‘category_url_name’ => null,
‘tag’ => null,
‘price’ => 0, //if price = ‘sale’ it shows all sale products
‘limit_of_items’ => 0,
‘sort_order’ => null, // author,date,title,modified,parent,ID,rand,comment_count
‘order’ => ‘ASC’, // ASC or DESC
‘number_per_page’ => 0,
‘page’ => 0,`

So to order by title simply put this in your page:

[wpsc_products category_url_name='YOUR CATEGORY NAME' sort_order='title']

It does mean setting up a new page for each category and inserting the above code, but it will get you what you want.

May 7, 2011 at 8:46 pm #150199

glenbod

I tried to tag the code in the post above correctly. Anyway, the code works nicely.

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘Archives – How-To and Troubleshooting’ is closed to new topics and replies.