Hi there,
I have spent the last 4 hours trying to add a 'remove' item button to my Ubercart. I have tried installing the 'Empty Cart Button' but that doesn't work. Also, I tried adding the following code to my Ubercart PHP:
uc_cart_empty(uc_cart_get_id());
If you want to add 'empty cart button' use this code:
function uc_empty_cart_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'uc_cart_view_form') {
$form['empty'] = array(
'#type' => 'submit',
'#value' => t('Empty Cart'),
);
$form['#submit'][] = 'uc_empty_cart_cart_view_form_submit';
}
}
function
uc_empty_cart_cart_view_form_submit($form, &$form_state) {
switch ($form_state['values']['op']) {
case t('Empty cart'):
uc_cart_empty(uc_cart_get_id());
$form_state['redirect'] = 'cart';
}
}
Finally, I tried installing: uc_atctweaks
It says to "From any of your product nodes, click the "Features" tab, add the ubercart-tweaks feature and radio to empty cart when purchased." However, there is no 'radio to empty cart when purchased'.
I am at a complete loss as to how to do this. It seems to me like a very basic function.
Can anyone please help?
Thanks,
M
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Screen Shot 2012-05-11 at 9.35.03 AM.png | 13 KB | lilbebel |
Comments
Comment #1
tr commentedAre you asking about a "Remove item" button or an "Empty cart" button? 7.x-3.1 already has "Remove" buttons. Please format your code with <code></code> tags - it's difficult to read as-is. Did you create a uc_empty module? That code needs to be in a module. "Doesn't work" is not at all helpful - if you want assistance with this you're going to have to provide better information. If you have a question about uc_atctweaks you should post it in the issue queue for that module, not here.
Comment #2
lilbebel commentedHello,
I would like a "Remove item" button. The code above is not my code. I copied and pasted it from a forum. I am a designer and not a developer so am not savy with writing code. I didn't create a uc_empty module. Again, this reference was copied and pasted from a help forum. I got it from the link below:
http://stackoverflow.com/questions/4225537/ubercart-how-to-empty-the-cart
Sorry if I am unclear. I assure you it is not deliberate. I am just very confused about how to implement this function. You mention that 7.x-3.1 already has 'Remove' buttons. Can you please tell me where they are? I've been through the configuration settings (admin/store/settings/) many times and can't find a 'Remove item' button. The only button reference I can find is in 'Cart' - 'continue shopping elements'.
Thank you for any further help you can provide. It is much appreciated.
M
Comment #3
lilbebel commentedI have a solution here for anyone else who needs it.
Look at this module http://drupal.org/project/uc_ajax_cart
It is now compatible with D7 so there is no need to alter the .js file as discussed in the module threads.
Comment #4
tr commentedApparently you are talking about the cart *block*, which is quite different than the cart page.
Comment #5
lilbebel commentedI didn't mind if it was on the block or page or both so long as it was there. This is a very suitable solution and work around for my previous issue. I can simply place the ajax cart in whichever node I want and the problem is solved. If you have a solution to add the remove item to the cart page itself, that would be great.
Comment #6
tr commentedAs I said above, there are already "Remove item" buttons by default for each cart item on the cart page.
Comment #7
lilbebel commentedHello,
I have attached an image to show what my cart looked like before. I now understand that the "Remove Item" button is not available on the cart block but is available on the cart page. Sorry for my confusion. I had assumed both would be the same as they serve the same function. In order to have "Remove Item" buttons on the cart block, Ajax cart needs to be used instead of the Shopping Cart block.
Thanks for your patience.
M