php


Wecoomerce custom query to filter products loop


I need to filter my products when user selects order by option on my website. I need to show produtcs ordered by the user option and if _sku equals to 'NONE' it need to go to the end of the list of the products.
For example:
My produtcs:
_sku title
1 Aprodu
2 Dprodu
NONE Bprodu
3 Cprodu
NONE Eprodu
So if the user selects to order by title. The products will have to get this result:
1 Aprodu
3 Cprodu
2 Dprodu
NONE Bprodu
NONE Eprodu
The first three items are ordered by title is this case and if _sku equals 'NONE' it will be going to the end of the list.
I tried:
add_filter( 'posts_orderby', 'filter_case' );
function filter_case($orderby = '') {
$orderby .= 'CASE WHEN posts._sku = 'NONE' THEN 0';
return $orderby;
}

Related Links

Oracle SQL PHP INSERT speed optimization? [closed]
How to check if there is an added record on the database
A Database Error Occurred Error Number: 1064
Is it possible to retrieve a document stored in DocuWare via PHP?
Customize Codeiniter Pagination
Output date in YYYY-MM-DDThh:mmTZD format in php
MySQL INSERT IGNORE Adding 1 to Non-Indexed column
PHP - How to rename the uploaded file? [duplicate]
Using YML file in Laravel
Mysql Statement to pull info from database in particular order with subsets
PHP cookies and session
Add reCaptcha code to php script (CakePhp)
Insert form data into MySQL database table
how to find out missing date in mysql using php
PHP curl_exec() not working online but works fine on localhost as CURLOPT_POSTFIELDS not attaching data to http post request
Unable to call method using facade in laravel 5.1

Categories

HOME
elasticsearch
yahoo-weather-api
kendo-dropdown
header
visualforce
share
repair
cocotb
azure-logic-apps
gtk
scrape
nexus3
parsley.js
jodatime
adminlte
restier
pdf.js
jpa-2.1
plyr
msdeploy
echosign
jackrabbit-oak
history.js
oracleforms
premake
reporting
fotorama
caesar-cipher
winrm
payeezy
ftp-server
cargo
telephonymanager
gitolite
get-event-store
classnotfoundexception
contactless-smartcard
dbcc
jqgrid-asp.net
git-tfs
daz3d
roracle
comm
android-webservice
google-news
pecl
msxml
front-camera
bpms
yui3
ftp-client
perforce-integrate
deferred-rendering
jeditable
teensy
godeps
android-mapview
variable-length-array
ibm-was
ora-04091
ngcordova
vdm-sl
angular-amd
nssortdescriptor
debug-symbols
tkx
fat32
phonegap-facebook-plugin
thoughtworks-go
adhoc-polymorphism
window-resize
xhprof
back
.htpasswd
hyperloglog
preorder
particle-swarm
visual-c++-2005
quickgraph
microformats
websphere-6.1
netstream
gwt-celltable
qtextbrowser
boost-foreach
startupscript
kext
servlet-container
icicles
aspbutton
ning
efs
twitter-feed
downloadfile

Resources

Encrypt Message