Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Struggling With Changing Sorting On Cart.cart_List - Tried Everything Rate Topic   - - - - -

 
  • hostandname
  • Senior Member
  • Members
  • Join Date: 05-Jan 06
  • 199 posts

Posted 02 February 2016 - 03:57 AM #1

Hope someone can help, as been trying for hours and hours tonight to crack this:

 

admin.php?dispatch=cart.cart_list

 

By default it is sorting by customer and i can see in

 

app/controllers/backend/cart.php

$sorting = db_sort($params, $sortings, 'customer', 'asc');

Now i know i can simply add or rather replace with:

$sorting = db_sort($params, $sortings, 'date', 'desc');

which does work, but i want to override this really within my addon, ive tried with a hook from what hook i found in that file, tried with cart.post.php and under $mode to do a redirect with fn_redirect and another method but then broke search... im sure im missing some real easy way of doing this? can someone help?


Host & Name Ltd - your reliable & trustworthy media provider (www.hostandname.co.uk)
Approved CS-Cart Developers and Official CS-Cart Licensing Supplier
Web Hosting | Cloud Hosting | Dedicated Servers | VPS | Domains | Emails | Design | Development | Marketing | Management


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 20910 posts

Posted 02 February 2016 - 07:55 AM #2

Try to create the cart.pre.php and use the following code for the cart_list mode:

if (empty($_REQUEST['sort_by'])) {
    $_REQUEST['sort_by'] = 'date';
}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • hostandname
  • Senior Member
  • Members
  • Join Date: 05-Jan 06
  • 199 posts

Posted 03 February 2016 - 11:10 PM #3

 

Try to create the cart.pre.php and use the following code for the cart_list mode:

if (empty($_REQUEST['sort_by'])) {
    $_REQUEST['sort_by'] = 'date';
}

 

Thanks for getting back to me mate, i removed the cart.post.php file i added and created cart.pre.php file in /app/addons/abandoned_cart_extended/controllers/backend/ with the following code:

<?php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

if ($mode == 'cart_list') {

	if (empty($_REQUEST['sort_by'])) {
	    $_REQUEST['sort_by'] = 'date';
	}

}

But when i went to: 

 

admin.php?dispatch=cart.cart_list 

 

Did not seem to do anything, just defaulted to the Customer sorting as defined in cart.php default backend controller file

 

Any ideas? really want to avoid editing the cart.php controller ideally.

 

Thanks again mate


Host & Name Ltd - your reliable & trustworthy media provider (www.hostandname.co.uk)
Approved CS-Cart Developers and Official CS-Cart Licensing Supplier
Web Hosting | Cloud Hosting | Dedicated Servers | VPS | Domains | Emails | Design | Development | Marketing | Management


 
  • hostandname
  • Senior Member
  • Members
  • Join Date: 05-Jan 06
  • 199 posts

Posted 03 February 2016 - 11:23 PM #4

Ok worked it out, thought would try it directly in the URL and did not sort by date, but if i also done sort_order=desc it worked so with the following it done the trick! so simple, i tried for hours and hours yesterday trying different things, php, js work arounds haha

 

Thanks for your help mate as just got me in the right direction, for anyone else this is the solution:

if ($mode == 'cart_list') {

	if (empty($_REQUEST['sort_by'])) {
	    $_REQUEST['sort_by'] = 'date';
	    $_REQUEST['sort_order'] = 'desc';
	}

}

Host & Name Ltd - your reliable & trustworthy media provider (www.hostandname.co.uk)
Approved CS-Cart Developers and Official CS-Cart Licensing Supplier
Web Hosting | Cloud Hosting | Dedicated Servers | VPS | Domains | Emails | Design | Development | Marketing | Management


 
  • crazyshark20
  • Junior Member
  • Members
  • Join Date: 19-Aug 09
  • 336 posts

Posted 12 August 2020 - 12:58 PM #5

Works 4.6 like this

 

app/functions/fn_cart.php

 
Change This
 
   
 $sorting = db_sort($params, $sortings, 'customer', 'asc');
 
To This
 
    
$sorting = db_sort($params, $sortings, 'date', 'desc'); 
 
 
But how can i add in
 
app/addons/my_changes


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 20910 posts

Posted 12 August 2020 - 01:50 PM #6

Unfortunately, the fn_get_carts function does not have hooks

 

Try to use cart.pre.php controller and add something like this

 

<?php


use Tygh\Registry;


if (!defined('BOOTSTRAP')) { die('Access denied'); }


if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    return;
}


if ($mode == 'cart_list' && !isset($_REQUEST['sort_by'])) {
    $_REQUEST['sort_by'] = 'date';
}
 
(!) Not tested

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)