Re: Re: Re: Re: Custom add to cart redirect

Posts: 4368
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

hehe Well, you might try a query... first, a big picture of how the shopping cart works. There's a database table called uc_cart_products where for every unique product in a cart, we store the qty and data array using the user ID or session ID of the customer as a key. The function uc_cart_get_items(), for example, loads up the items from this table and does stuff with them.

Your function can simply delete anything from that table that doesn't match this product's nid (which I'm assuming is 495?).

<?php
  db_query
("DELETE FROM {uc_cart_products} WHERE cart_id = '%s' AND nid != 495", uc_cart_get_id());
?>

You can do other queries to adjust the qty if you need to, too.

You should check out the Drupal API for db_query() for more info.

Custom add to cart redirect By: tom-d (4 replies) Tue, 05/13/2008 - 08:57