Marketpress: mp_list_products shortcode attributes not working

I've been experimenting with the optional attributes for the mp_list_products shortcode on a static test page. I have two products with different titles, product IDs, and prices. I have tried six different combinations of shortcode attributes:

order_by="price" order="DESC"
order_by="price" order="ASC"
order_by="title" order="DESC"
order_by="title" order="ASC"
order_by="ID" order="DESC"
order_by="ID" order="ASC"

An example of how I wrote each shortcode is "mp_list_products order_by="title" order="DESC"" (using square brackets). As far as I can tell, this is correct.

But all six attribute combinations result in exactly the same page with products in exactly the same order; the products are listed in the same order as they do when no attributes are used (as in the link above). Clearly, some of these attributes should reverse the order of the items on the page. But they do not. Do I need more than 2 products to get this to work? Am I missing an essential attribute to make the order "stick"? Should I use all lowercase? Or what?

  • Robert

    I did as you suggested. I added the "per_page" attribute, with this general format:

    [mp_list_products per_page="10" order_by="price" order="DESC"]

    I also added a third product.

    I retried several of the variants listed in my first post, and none made any difference. The order of products is the same as that when no attributes are listed. I couldn't get the list of products to change in any way. It's as if all attributes are simply ignored.

  • Robert

    I have created a clean local install of MarketPress plus my theme (Suffusion) for testing this shortcode issue. The only other plug-in installed at this point is your own companion plug-in, WPMU DEV Update Notifications. With Suffusion active, I have the same shortcode attribute problem as above: I can (I think) get all the attributes to work except order_by="xxxx" and order="xxx". I have tried various order_by="xxxx" parameters (title, ID, date, price) and none of them work for me.

    I switched to Twenty Eleven 1.1 theme and the problem persisted. I tried Twenty Ten 1.2 theme as well, same result. This seems to indicate that my theme, Suffusion, is not at fault.

    Here is an example of the shortcode as I have written it:

    [mp_list_products category="real-photo-postcard" paginate="true" page="1" per_page="12" order_by="title" order="DESC"]

    order_by="xxxx" with order="xxx" is obviously an important attribute combo for ordering the items in a product list. I need to get these to work. The fact that I cannot get them to work in a bare-bones install indicates either (1) I am doing something wrong, or (2) these two attributes don't work properly. Are they working for other people? Is there something incorrect in the way I have written the shortcode?

    I leave early tomorrow for a week-long trip, so I may not be able to post any updates on this issue until next week. Thanks for any help you can offer.

  • Philip John

    Hiya Robert,

    My apologies that you haven't recieved a response to this. David is very good at monitoring threads so I believe his notifications must not be working for this one.

    I have run a few tests myself according to your messages and I am seeing the exact same issue which tells me this is a bug.

    Therefore I'm gonna pass it straight to the developer to provide a fix asap.

    Thanks,
    Phil

  • Robert

    V--

    Thanks for the update. I installed your attachment (2.1.3a), tested it, then with the WP updater updated to 2.1.3. Both seemed to behave the same way. (Perhaps there is no difference between the two?)

    I am now able to get the sort attributes to work. I didn't test every last one, but the ones I did test (ID, price, title) worked fine. Thanks for that!

    But I have now encountered several different problems:

    1. I have now entered enough products to test pagination, and I was a bit stymied on this (and I don't know if this was a problem in the previous version, or just this new one). With auto-generated pages, pagination occurs automatically when needed. With shortcode pages, however, I cannot find a way to generate more than a single page. Is this a feature, or a bug? Or I am missing something? Perhaps I should start a new thread on this once the update goes live?

    2. On a related issue, I want to use WP_Pagenavi -- which my theme (Suffusion) supports for standard posts -- but it doesn't work with auto-generated products pages. I assume the same to be true with shortcode-generated pages, but as noted have yet to generate more than one page via shortcode. Subject for another thread as well?

    3. Nick Daugherty's MarketPress Product Grid Shortcode plug-in (available in this forum, and which I am using) does not appear to pick up your fix. I still can't get the sort attributes to work with this plug-in's shortcode (despite the fact that it is based on MP's shortcode). Also, the plug-in's grid display is (oddly) now messed up. I realize this is not your problem, and presume Nick will need to revise his code to work with your new version. Just FYI.

  • poltaj

    I do have a similar problem and the updated version of VeBailovity isn't fixing the problem for me.
    I'm not working with shortcodes, but calling the function in a template.

    <?php mp_list_categories('order_by=sales')?>
    <?php mp_list_categories('order_by=price')?>
    <?php mp_list_categories('order_by=date')?>

    Return the exact same list... which is ordered by whatever is selected in the settings page.
    Can you have a look at this too?
    Thanks,
    Paolo

  • Vladislav

    Hi,

    @Robert, as for pagination in pages with shortcode - Marketpress doesn't show pagination links in shortcodes by design. However, flipping through pages of your products by using "per_page" and "page" attributes in your shortcode works just like one would expected. Additionally, if you specify "per_page" attribute in your shortcode and omit the "page" attribute, urls such as http://yourdomain.com/your-page-with-shortcode/page/2 should work too and lead to subsequent product pages. With this in mind, it shouldn't be too difficult to devise your own navigation system (depending, of course, on what you want to do).

    As for MarketPress Product Grid Shortcode by Nick Daugherty, it uses some code inherited from Marketpress, but separated from it. This means it didn't pick up the fix from the updated version just yet, but I'll be posting a fixed version to the original thread.

    @paoltaia, I'm not sure if I understood the problem fully, but it's definitely a different kind of issue. Let's try to break it down.

    1) If you're trying to list categories - which is what the function you're calling does - the function worked exactly as it was supposed to work with the parameters you passed in (however, that most likely wasn't what you wanted, hence the unexpected behavior you're seeing).

    The first argument passed to the function determines if it will return the generated value as a string or echo it, and it is supposed to be a boolean (i.e., you pass true to echo the generated value, OR false to return it as a string). The additional parameters for the function are passed in the second argument to the function.

    In your case, you were supplying a non-empty string, which was considered to be a bool-ish value, and so the function echoed the result. Since there was no second argument, the result was created with defaults from the settings.

    Here is an example of a function call that would work (note the array passed as second argument):

    <?php mp_list_categories(true, array(
    	'orderby' => 'count',
    	'hierarchical' => 1,
    	'show_count' => 1,
    ));?>

    Additionally, you can't order catgories by sales or prices, as categories don't have either. You can, however, order them by their names ("orderby" => "name"), slugs ("orderby" => "slug") or item counts, as it is in the example.

    2) If you wanted to show products instead, you could order them the way you wanted, but you want to use a different function for that:

    mp_list_products( $echo = true, $paginate = '', $page = '', $per_page = '', $order_by = '', $order = '', $category = '', $tag = '' )

    So if you, for an example, wanted to show your products ordered by price, your function call would look like this:

    mp_list_products(true, '', '', '', 'price', 'asc');

    I hope this helped.

  • Spiritap

    Hello!

    I'm currently using marketpress 2.3.2 and having the same problem that this post was originally started for. I cannot get any of these parameters to effect the order of my 8 products-

    order_by="price" order="DESC"
    order_by="price" order="ASC"
    order_by="title" order="DESC"
    order_by="title" order="ASC"
    order_by="ID" order="DESC"
    order_by="ID" order="ASC"

    I currently have [mp_list_products order_by="title" order="desc" category="sessions" ] and it shows all the products in category on this page, but I can't get the order to change. Is your fix part of 2.3.2? OR do I need something else to get this to work correctly? Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.