0
votes

i just want to ask what are the codes in catalog folder does i need to open if i want to descending the list of products that i added in the shopping cart in opencart. for example, i have three (3) products, product A = $3.00, product B = $2.75 and product c = $1.50,

I have tried to look and add an ORDER BY price DESC in $product_query at the cart.php (\system\library\cart.php) but I failed to order by the lists of products present in the shopping cart.

is there a solution that can I descend the lists of product in the shopping cart? thanks in advance

1

1 Answers

1
votes

These are the PHP commands you need to be focussed on for OpenCart Found in the /catalog/controller/checkout/cart.php

if ($this->cart->hasProducts() || (isset($this->session->data['vouchers']) && $this->session->data['vouchers'])) { // look for hasProducts

$products = $this->cart->getProducts(); // look for this

The files are also in

system/library/cart.php
system/library/product.php

You need to edit public function getProducts() {

$sql = "SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)";

There are some more edits, just do a find in folder for those functions in the OpenCart zip. You can add your ORDER BY and other functions within these SQL commands. I would advise downloading a OpenCart version that matches yours and keep the zip extracted - never touch the source so you can refer back to it, always save original work as .bk or .php.backup or .compress if using WordCompress

Update

Not all the files are structured in the MVC format. Some files are in the system folders and some files and functions have been combined.