1

How to empty the cart automatically before adding a new item to the cart in ubercart ver 6?

Is it possible adding uc_cart_empty($cart_id) ; in uc_cart module?

2 Answers 2

1

You can clear the cart using the following function

uc_cart_empty(uc_cart_get_id());

Use the above function in your module when you want clear cart. To empty the cart automatically before adding a new item to the cart call the function in hook_add_to_cart().

eg:

function MODULE_NAME__add_to_cart($nid, $qty, $data) {
  uc_cart_empty(uc_cart_get_id());
  drupal_set_message("Previous item cleared");
}
0
0

This is correct answer:

function MODULE_NAME_uc_add_to_cart($nid, $qty, $data) { uc_cart_empty(uc_cart_get_id()); drupal_set_message("Previous item cleared"); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.