Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2167
    FredTheValet
    Participant

    We would like to order display items on the Form by SKU rather than Name – is this possible or is there a workaround you can think of to do this?

    Thanks!

    – Fred.

    #2170
    Slavi Marinov
    Keymaster

    Hi,

    Just pushed a new release which should allow you to sort by sku.
    Please, check the examples in plugin’s plugin’s settings ( WP Admin > Settings > Orbisius Quick Order for WooCommerce ).

    Slavi

    #2177
    FredTheValet
    Participant

    Hi Slavi –

    I got the V1.1.4 update – thanks! The SKU orderby wasn’t working, so I looked at the code and it looks like there is a mix use of ‘order_by’ and ‘orderby’ in the get_products() function.

    I’ve fixed my copy here for now – if you want me to send you my changes, I’d be happy to do so.

    – Fred.

    #2178
    Slavi Marinov
    Keymaster

    Sure. Please do.
    You can use the help email or the quote form to send it.

    I thought that there might be some issues if you have numeric SKU’s because WP stores them as meta fields which are chars (by default).

    #2179
    FredTheValet
    Participant

    Didn’t think of that! Fortunately, the customer’s SKUs are all five digits, so the SQL order works just fine.

    The problem was a couple of array elements using ‘orderby’ when they should have been ‘order_by’ (or vice-versa) – I’ll email you the details, line#’s, etc.

    – Fred.

    #2180
    Slavi Marinov
    Keymaster

    Awesome thanks Fred.
    I know in the plugin I’ve used order_by where in WP orderby is used.

    #2181
    Slavi Marinov
    Keymaster

    Patch received. Thanks & a new version was released.

    #2915
    ledzep100
    Participant

    Would it be possible to order off of a different metafield/key? AKA custom order_by. My SKUs & pricing are arbitrary to the order I prefer.

    I tried adding a custom meta field under the product in the product page called “order_form”. Then of course adding a number to the new meta field (1-whatever). I then added a “_” in phpmyadmin infront to make it a meta_key so “_order_form”.
    Then I tried adding “order_form” in the array like so (line 1420):

    // the user actually wants to sort products by meta but has forgotten the underscore in front
                elseif ( in_array($filters['order_by'], array('sku', 'price', 'regular_price', 'sale_price', 'order_form')) ) {
                    $args['meta_key'] = '_' . $filters['order_by']; // autoprefix it.
                    $args['orderby'] = 'meta_value';
                } else {
                    $args['orderby'] = $filters['order_by'];
                }
    
                if (!empty($filters['order'])) {
                    $args['order'] = $filters['order'];
                }
            }

    Then in the shortcode I used the order_by=”_order_form” instead of order_by=”_sku”

    I tried troubleshooting with no luck.
    I really thought it would work since the _sku meta_key is stored in the table the same way as the custom meta fields of the product.
    I’m learning WP development and php in a trial by fire fashion. I was super proud until it didn’t work at all. I thought I was onto something. It’s probably something obvious.
    Thank you for the plugin! It’s exactly what I needed and will be recommending it to other Woo users.
    Thanks for you time!

    #2916
    Slavi Marinov
    Keymaster

    Hi,

    You were very close.

    Can you try without the leading underscore?
    The plugin prefixes the field if it’s in the array you mentioned.

    order_by="order_form"

    Slavi

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.