WordPress.org

Ready to get started?Download WordPress

Forums

TheCartPress eCommerce Shopping Cart
[resolved] [Plugin: TheCartPress, E-Commerce for WordPress Stores] Sorting products (9 posts)

  1. Joy
    Member
    Posted 2 years ago #

    It would be nice if you could mention somewhere that you take over the sorting of the posts using Session variables.
    I wanted to sort my products and didn't realize that the "Order Panel" widget was for sorting. (I would rename it to use the word Sort because an order in a shopping cart is something else.) So I tried to use a different plugin to sort but they don't sort!
    I had to dig through the code to find that you override the sorting for all post queries, not just products. I don't have a lot of other content on my test blog to try it out, but it seems like it would not be a good thing to sort them by price...

    And speaking of sorting by price, it doesn't work correctly. It is sorting as text instead of a number. (not sure what it does with a grouped product) I fixed my local copy by putting "+0" in line 274 of TheCartPress.class.php
    $orderby = "tcp_postmeta_price.meta_value+0 {$_SESSION['tcp_order_desc']}, {$wpdb->posts}.post_title";

    There is one sort type that is called "order", which I assume means I can set the order of the products myself. Where do I do that?

    http://wordpress.org/extend/plugins/thecartpress/

  2. Joy
    Member
    Posted 2 years ago #

    Shortly after adding that "+0" to the code, I added some product tags and put the taxonomy widget in the sidebar. I clicked on my new tags and sorted by price (I put the code from the Order Panel widget into my loop-tcp-grid). This is when things didn't look right. I had several products with a zero price suddenly.

    I looked at my product list in the back-end and figured out that it was the products with the new tags that I had just displayed sorted by price that had a zero. And I had just put that +0 fix in.

    So I edited all those products and set the values. It turns out all the meta values were gone on those. I took the +0 back out of the code. I then clicked on the same links as before and had no problems, sorted by price too (although it sorts wrong). I then put the +0 back in the code and clicked around again. I couldn't get it to misbehave. It all looks good (and sorts correctly).

    Since I couldn't find the reason for the loss of data, I suspect there is still some bug lurking in the code.
    Just thought I'd let you know...

  3. Inigo Gonzalez
    Member
    Plugin Author

    Posted 2 years ago #

    Hi

    I have fixed this error with a CAST, but still there are problems with the order, so for the moment is a known bug.

    I'd like to sort only tcp_products. But with the TheCartPress code all the post types are sorted

    Best regards

  4. Joy
    Member
    Posted 2 years ago #

    Why can't you use the conditional template functions to determine if you should apply your sort?

    if (is_tax('tcp_product_tag') || is_tax('tcp_product_category') || is_tax('tcp_product_supplier'))
     ...do your orderby...

    Or at least make the sort optional?

  5. Inigo Gonzalez
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Joy,

    I have changed it and I think it works!!

    I have to test it more, Thank you very much!!

    Have you download the beta version? It has a lot of new features...

    Thanks again and best regards

  6. Joy
    Member
    Posted 2 years ago #

    Sensei,
    This method of sorting causes a problem when using a TCP loop in a page or a sidebar. There is no way to tell that loop to come out in a different order than the user chose.
    I want to put a list of products on my home page, so I generated a shortcode and the products show up. But they are in whatever order I last chose on the category page. I want them in the order I specified in the backend.

  7. Joy
    Member
    Posted 2 years ago #

    The fix of the sort with the CAST does not fix the numerical sort problem. When you fix it with +0, it sorts correctly.

    Oh! I see you put the CAST on the tcp_postmeta_order instead of tcp_postmeta_price. The order would have the same problem, if you get into double digits which is easy to do, but price is the one that is really apparent.

  8. Joy
    Member
    Posted 2 years ago #

    I've been trying to get this to work on the front page on the 1.0.9 beta.
    I just realized that you put the conditional tags into your parseRequest function, so now you only respond to the user trying to change the sort on a tcp_product taxonomy page. But me trying to put a list of products on the home page is still affected by your ordering (whatever was chosen last).

    I think it's a bad practice to ignore a request variable that's there (only available sometimes). I would remove the conditional from parseRequest. This might be what is causing it to now take 2 clicks of the sort button (Order in the Order Panel) to get it to sort, even though you can be on a list page. It redraws the screen, but the products are not sorted. The second time I click, the products are sorted.

  9. Joy
    Member
    Posted 2 years ago #

    Finally!
    Much better sorting capability in the August 7 1.1.0 beta release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic