29 pointsStarting to get into this DEV thingI'm new here
mysolarix
Member
—
2nd February 2012 (3 months ago)
Hi,
According to the documentation, the [mp_list_products] shotcode can only sort the products by title, date, ID, author, price, sales, rand (random).
Is it any possible that we can sort the products list in additional setting, namely 'priority'.
Can it be consider to be put into the future updates of marketpress?
Is it possible for us to use custom field to be a temporary solution of sorting as the priority we set?
Hi,
According to the documentation, the [mp_list_products] shotcode can only sort the products by title, date, ID, author, price, sales, rand (random).
Is it any possible that we can sort the products list in additional setting, namely 'priority'.
Can it be consider to be put into the future updates of marketpress?
Is it possible for us to use custom field to be a temporary solution of sorting as the priority we set?
Hi Solarix,
if you'll follow the steps below you can archive the custom priority.
this will add "Custom ID" item to the "order Products By" in the presentation tab in store settings. (image 1).
once you choose it it will display the products by the numbers you will give in the custom field "my_product_id" of each product.
you will need to do a little editing in 3 files. not a big deal.
those are the steps:
1) open the file "marketplace.php" in "/wp-content/plugins/marketpress/marketpress.php"
go to line 1022 you will see this:
//get order by
if ($settings['order_by'] == 'price')
$order_by_query = '&meta_key=mp_price&orderby=mp_price';
else if ($settings['order_by'] == 'sales')
$order_by_query = '&meta_key=mp_sales_count&orderby=mp_sales_count';
else
$order_by_query = '&orderby='.$settings['order_by'];
add the line below just before the "else""
else if ($settings['order_by'] == 'custom')
$order_by_query = '&meta_key=my_product_id&orderby=my_product_id';
so now it will look like image 2.
same thing exactly you need to do in lines 1115 and 6025.
2) now same file go to line 5406. you will see this line :
3) now open the file "template-functions.php" in "/wp-content/plugins/marketpress/marketpress-includes/template-functions.php".
just below line 1238 which is :
this function will now display the custom fields of your products( image 5).
now just add a new custom field "my_product_id" and in the value you'll give each product the number you wish.
that will be it. maybe a little confusing but very simple. i quick tested on my site and it seems to work. however, i didn't get to work with the site so i am not sure it it will cause any other problems(which i believe it will not) . if you have any questions you are more then welcome to ask.
How could I thank u enough?!! Before I ask the question u already provide the solution. That is what I am going to ask, how to integrate inside the setting of the marketpress plugin.
Never mind, The question was misunderstood. I am glad it is work for you. And thank you for the points. You gave me way too many :) I really did it to help and for fun.
When I dig further down into the code, I think it is very possible to integrate the custom priority id column into the product details of the product page.
Will update here if I have successfully made it, later.
successfully add the field in the product details setting. But want to make it further at the quick edit box. Now stuck at that process. Anyone experience in adding stuff in quick edit box? Found some solution, but involve changes of wordpress core file which i would try to avoid...
Will stop try to find solution on the quick edit box, because need to concentrate on other stuff. If anyone can have a solution on the quick edit part, please share here.
Will share the code of integrate the sorting by priority here.
//get order by
if ($settings['order_by'] == 'price')
$order_by_query = '&meta_key=mp_price&orderby=mp_price';
else if ($settings['order_by'] == 'sales')
$order_by_query = '&meta_key=mp_sales_count&orderby=mp_sales_count';
else
$order_by_query = '&orderby='.$settings['order_by'];
//get order direction
$order_query = '&order='.$settings['order'];
change to
//get order by
if ($settings['order_by'] == 'price')
$order_by_query = '&meta_key=mp_price&orderby=mp_price';
else if ($settings['order_by'] == 'sales')
$order_by_query = '&meta_key=mp_sales_count&orderby=mp_sales_count';
else if ($settings['order_by'] == 'priority')
$order_by_query = '&meta_key=my_product_priority&orderby=my_product_priority';
else
$order_by_query = '&orderby='.$settings['order_by'];
//get order direction
$order_query = '&order='.$settings['order'];
line 1113
//get order by
if ($settings['order_by'] == 'price')
$order_by_query = '&meta_key=mp_price&orderby=mp_price';
else if ($settings['order_by'] == 'sales')
$order_by_query = '&meta_key=mp_sales_count&orderby=mp_sales_count';
else
$order_by_query = '&orderby='.$settings['order_by'];
//get order direction
$order_query = '&order='.$settings['order'];
change to
//get order by
if ($settings['order_by'] == 'price')
$order_by_query = '&meta_key=mp_price&orderby=mp_price';
else if ($settings['order_by'] == 'sales')
$order_by_query = '&meta_key=mp_sales_count&orderby=mp_sales_count';
else if ($settings['order_by'] == 'priority')
$order_by_query = '&meta_key=my_product_priority&orderby=my_product_priority';
else
$order_by_query = '&orderby='.$settings['order_by'];
//get order direction
$order_query = '&order='.$settings['order'];
//get order by
if ($instance['order_by']) {
if ($instance['order_by'] == 'price')
$order_by_query = '&meta_key=mp_price&orderby=mp_price';
else if ($instance['order_by'] == 'sales')
$order_by_query = '&meta_key=mp_sales_count&orderby=mp_sales_count';
else
$order_by_query = '&orderby='.$instance['order_by'];
} else {
$order_by_query = '&orderby=title';
}
//get order direction
if ($instance['order']) {
change to
//get order by
if ($instance['order_by']) {
if ($instance['order_by'] == 'price')
$order_by_query = '&meta_key=mp_price&orderby=mp_price';
else if ($instance['order_by'] == 'sales')
$order_by_query = '&meta_key=mp_sales_count&orderby=mp_sales_count';
else if ($instance['order_by'] == 'priority')
$order_by_query = '&meta_key=my_product_priority&orderby=my_product_priority';
else
$order_by_query = '&orderby='.$instance['order_by'];
} else {
$order_by_query = '&orderby=title';
}
//get order direction
if ($instance['order']) {
Responses (22)
Member — 2nd February 2012 (3 months ago) #
Hi, Solarix,
A while ago I suggested a maybe solution to what you are looking for in this topic. Take a look maybe it will be helpful for you.
Member — 2nd February 2012 (3 months ago) #
@fitoussi,
Thanks. I thought of using custom field but not sure the steps to do it. Really appreciate your reference!
Sales & Support Lead — 2nd February 2012 (3 months ago) #
Hiya,
@fitoussi, nice one. Thanks for chiming in!
I'll add this one as a feature request for now, though mysolarix, feel free to add your voice to the aforementioned thread as well.
Thanks!
Member — 3rd February 2012 (3 months ago) #
Hi Solarix,
if you'll follow the steps below you can archive the custom priority.
this will add "Custom ID" item to the "order Products By" in the presentation tab in store settings. (image 1).
once you choose it it will display the products by the numbers you will give in the custom field "my_product_id" of each product.
you will need to do a little editing in 3 files. not a big deal.
those are the steps:
1) open the file "marketplace.php" in "/wp-content/plugins/marketpress/marketpress.php"
go to line 1022 you will see this:
add the line below just before the "else""
so now it will look like image 2.
same thing exactly you need to do in lines 1115 and 6025.
2) now same file go to line 5406. you will see this line :
just below it add this line:
so now your code will look like image 3.
do the same thing in line 6142.
3) now open the file "template-functions.php" in "/wp-content/plugins/marketpress/marketpress-includes/template-functions.php".
just below line 1238 which is :
add the lines:
so now it will look like image 4.
3) open the file "functions.php of your theme.
on the top of the page just below the
<?phpinsert this linethis function will now display the custom fields of your products( image 5).
now just add a new custom field "my_product_id" and in the value you'll give each product the number you wish.
that will be it. maybe a little confusing but very simple. i quick tested on my site and it seems to work. however, i didn't get to work with the site so i am not sure it it will cause any other problems(which i believe it will not) . if you have any questions you are more then welcome to ask.
Member — 3rd February 2012 (3 months ago) #
Member — 3rd February 2012 (3 months ago) #
Hi fitoussi,
How could I thank u enough?!! Before I ask the question u already provide the solution. That is what I am going to ask, how to integrate inside the setting of the marketpress plugin.
Thanks x 1mil
Member — 3rd February 2012 (3 months ago) #
I thought I can give u more points, but seems like I don;t have enough for myself :p
Member — 3rd February 2012 (3 months ago) #
No problem, first let's make sure it works for you. About your question , did you mean how to edit the files?
Member — 3rd February 2012 (3 months ago) #
Thanks for your guidance, it sure works.
I've made some modification of your tutorial, that I only change the files of the plugin, without the need to change the theme functions.php
Anyway, really thanks for your lead.
Sorry, I dont get you..
Member — 3rd February 2012 (3 months ago) #
Never mind, The question was misunderstood. I am glad it is work for you. And thank you for the points. You gave me way too many :) I really did it to help and for fun.
Member — 3rd February 2012 (3 months ago) #
When I dig further down into the code, I think it is very possible to integrate the custom priority id column into the product details of the product page.
Will update here if I have successfully made it, later.
Member — 3rd February 2012 (3 months ago) #
It is possible and I was actually looking to do it. But I was tired and I think this will take a little more programming. Let me know if you got it.
Member — 5th February 2012 (3 months ago) #
successfully add the field in the product details setting. But want to make it further at the quick edit box. Now stuck at that process. Anyone experience in adding stuff in quick edit box? Found some solution, but involve changes of wordpress core file which i would try to avoid...
Member — 5th February 2012 (3 months ago) #
Will stop try to find solution on the quick edit box, because need to concentrate on other stuff. If anyone can have a solution on the quick edit part, please share here.
Will share the code of integrate the sorting by priority here.
First, here are the screenshots
Member — 5th February 2012 (3 months ago) #
Changes of marketpress.php
line 1022
change to
line 1113
change to
line 1513
change to
Member — 5th February 2012 (3 months ago) #
line 1538
change to
line 1793
change to
line 1852
change to
line 1912
change to
line 5395
change to
line 6021
change to
line 6133
change to
Member — 5th February 2012 (3 months ago) #
Please change the following to the file template-functions.php in the folder of marketpress-includes
line 1233
change to
Member — 5th February 2012 (3 months ago) #
That is it.
If anyone know how to deal with the quick edit box, please provide some help here...
thanks.
Member — 6th February 2012 (3 months ago) #
Finally, successfully made it.
I have integrate the custom priority into quick edit mode also.
:)
Lead Developer — 7th February 2012 (3 months ago) #
Wow guys, you've gone to town on this one!
For most users, I would just recommend changing the dates and ordering by that, as it would have the same effect and require no custom coding.
Member — 7th February 2012 (3 months ago) #
Hi aaron,
yupp.. that would be a nice work around. But learned alot thru the process :)
Member — 7th February 2012 (3 months ago) #
And that information might be useful to someone if they decided to do it.
But advisable to make backup before any changes.
cheers
Become a member