Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

showing the most recently added item in the shopping cart on the top


juniorprg

Recommended Posts

my customers have difficultly finding out which is the latest added product in the basket, does any one know how to sort the basket content so that the latest added product shows in the very top, pushing down the one added into basket before that...

 

anyone know how to sort this, please help

 

thanks

l8ter

Link to comment
Share on other sites

is this somthing done in the

 

catalog/includes/boxes/shopping_cart.php

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

$cur_row = sizeof($info_box_contents);

 

or is this done at includes/classes/shopping_cart.php

tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

 

somone pls help

l8ter

Link to comment
Share on other sites

YET AGAIN I SOLVE THIS!!!

 

it can be sorted using the customers_basket_id in the customers_basket table

 

it anyone faces this issue, change the sorting order , change the classes/shopping_cart.php

 

SEARCH FOR function add_cart .. within this function look for

 

SEARCH FOR $this->cleanup();

 

 

INSERT THE FOLLOWING JUST ABOVE THAT LINE

 

$this->reset(false);

 

$products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' order by customers_basket_id DESC ");

while ($products = tep_db_fetch_array($products_query)) {

$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);

// attributes

$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");

while ($attributes = tep_db_fetch_array($attributes_query)) {

$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];

}

}

 

AFTER THIS INSERT...THE MOST RECENTLY ADDED ITEM IN THE CART WILL BE SHOWN FIRST FOLLOWED BY THE ONES THAT WERE ADDED BEFORE THIS...

l8ter

Link to comment
Share on other sites

i dont know if anyone is goin to help me , but this is the overview of my problem now

 

I've been trying to sort the items in the shopping cart box and in page in descending order, means the the last add items top of the box followed by the ones added before them...I'm able to achieve this when the customer is logged in by making the following changes in the classes/shopping_cart.php

 

under this function:

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true)

 

at the end of this function i added the following :

 

$this->reset(false);

$products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' order by customers_basket_id DESC ");

while ($products = tep_db_fetch_array($products_query)) {

 

$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);

// attributes

$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");

while ($attributes = tep_db_fetch_array($attributes_query)) {

$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];

}

}

----

 

but my problem is this works well when a customer is signed in... but if he isnt, he is not able to add anything into the cart...

i suspect this codeis to be blamed for:

$this->reset(false);

 

---- so i checked the reset function in the same page

 

function reset($reset_database = false) {

global $customer_id;

$this->contents = array();

$this->total = 0;

$this->weight = 0;

//LINE ADDED: MOD - indvship

$this->shiptotal = 0;

$this->content_type = false;

 

if (tep_session_is_registered('customer_id') && ($reset_database == true)) {

 

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");

}

 

unset($this->cartID);

if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');

}

----------

 

i dont know how to fix this, anyhelp will be appreciated and plus i feel this a cool feature, because like my site having more than 4000 items and if there are more than 10 items in the cart, its easy for customer to see what they added last.... thanks

l8ter

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...