17 replies [Last post]
deciti's picture
Offline
Joined: 11/11/2007
Juice: 7
Was this information Helpful?

Hi everyone,

When a product is in the shopping cart it shows the product name as a link that is clickable to the product page. I would like to remove the link so just the product's static name is listed.

I've been looking for the code to modify but have been having an unusually hard time locating it. Is it within uc_cart.module?

Thanks!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Remove product links from shopping cart

deciti, it's because somewhere along the line it got relegated to a function called uc_product_cart_display(). Your best bet would be to use hook_form_alter() in a custom module and change that part of the form array before it gets rendered. The form ID to look for is 'uc_cart_view_form'.

deciti's picture
Offline
Joined: 11/11/2007
Juice: 7
Re: Re: Remove product links from shopping cart

Hey thanks Ryan, I'll check it out.

ricecooker's picture
Offline
Joined: 01/02/2008
Juice: 16
remove product links from shopping cart

hi deciti, can I have a look at the custom module you made to remove product links from shopping cart? I have a need for this as well. Thanks

cYu
cYu's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 11/19/2007
Juice: 850
Re: remove product links from shopping cart

Ricecooker, I think something like this would work for you if you create a new module and add this form alter in...

<?php
function your_module_form_alter($form_id, &$form) {
  if(
$form_id == 'uc_cart_view_form') {
    foreach(
$form['items'] as $key => $item) {
      if(!empty(
$item['title']['#value'])) {
       
$form['items'][$key]['title']['#value'] = strip_tags($item['title']['#value']);
      }
    }
  }
}
?>
ricecooker's picture
Offline
Joined: 01/02/2008
Juice: 16
Thanks!

Thanks for that! Really appreciate it.

simonaustin's picture
Offline
Joined: 10/04/2009
Juice: 2
Slight change required
cYu wrote:

Ricecooker, I think something like this would work for you if you create a new module and add this form alter in...

<?php
function your_module_form_alter($form_id, &$form) {
  if(
$form_id == 'uc_cart_view_form') {
    foreach(
$form['items'] as $key => $item) {
      if(!empty(
$item['title']['#value'])) {
       
$form['items'][$key]['title']['#value'] = strip_tags($item['title']['#value']);
      }
    }
  }
}
?>

I needed to change the order of arguments and "title" to "desc" to get this to work for me:

<?php
function your_module_form_alter(&$form, &$form_state, $form_id) {
  if(
$form_id == 'uc_cart_view_form') {
    foreach(
$form['items'] as $key => $item) {
      if(!empty(
$item['desc']['#value'])) {
       
$form['items'][$key]['desc']['#value'] = strip_tags($item['desc']['#value']);
      }
    }
  }
}
?>
Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Slight change required

Considering the time it was posted, I'm sure cYu's comment was referring to Drupal 5 and UC 1. This code should work for D6 and UC 2.

Abilnet's picture
Offline
Uber DonorBug Finder
Joined: 12/28/2007
Juice: 718
Re: Re: Slight change required

+1 for "removing product links from shopping cart" ...it's good for business, because it's eliminating one possibility to abandon shopping cart.

valariems's picture
Offline
Joined: 09/10/2009
Juice: 14
Re: Re: Re: Slight change required

Thanks for this info. I am trying to do the same thing as noted in this post from a few days ago.

However, I am unable to get this to work, probably because I don't know how to write a module. I tried, but I'm clearly doing something wrong, probably something very simple and basic. My skills set is on the design side of things, not the coding, though I'm trying to learn.

If anyone is willing to turn this into a module, please let me know. I could really use this functionality. The link in the shopping cart is confusing too many of my users due to the pay-per-node node checkout aspects of my site. Meanwhile, I'll keep trying to make the code above into a module.

EDIT TO ADD: What this pathetic non-programmer needs is what goes in the .info and .module files. I've tried multiple times to get this to work, and I'm about to give up and totally acknowledge my stupid. And does an ubercart module go into sites>all>modules, or sites>all>modules>ubercart>contrib? Tried it both ways. Not showing up in admin>build>modules. I'm doing something wrong that is very basic, I'm sure. Help? Might be able to PayPal you if can tell me what it would cost.

jpstuddard's picture
Offline
Joined: 08/28/2009
Juice: 27
We need this functionality

We need this functionality as well so I have created a simple module to remove the links from the product image and the description (title) in the cart summary table on the cart page. Hope this helps.

http://www.ubercart.org/contrib/14653

Abilnet's picture
Offline
Uber DonorBug Finder
Joined: 12/28/2007
Juice: 718
Re: We need this functionality

Thanks jpstuddard for your contribution, your hard work appreciated!

bsenftner's picture
Offline
Joined: 07/09/2009
Juice: 107
I thank you too!

This is similar to what I'm seeking (removal of the link on the product image node) and may provide necessary hints...

valtx's picture
Offline
Joined: 03/18/2010
Juice: 18
Thank you!

I downloaded, installed and activated your module and it worked like a charm. Thanks so much for your effort and for contributing it to the community, especially for the php-impaired like myself.

rico3030's picture
Offline
Joined: 11/24/2010
Juice: 3
Thanks

Good work! It was exactly what we needed!
Thanks!

taintmovie's picture
Offline
Joined: 12/06/2010
Juice: 12
Re: We need this functionality

Do you know if there's a way to remove links from the cart block as well?

Thanks for making this btw!

kirikintha's picture
Offline
Joined: 01/27/2009
Juice: 26
I had to do something a little different
  if($form_id == 'uc_cart_view_form') {
    foreach($form['items'] as $key => $item) {
      if (is_array($item)) {
        //Change the original Item.
        if (!empty($item['title']['#value'])) {
          $value = $item['title']['#value'];
          if (strstr($item['title']['#value'], 'href=')) {
            $form['items'][$key]['title']['#value'] = strip_tags($form['items'][$key]['title']['#value'], '<div>,<ul>,<li>,<br>,<p>');
          }
        }
        if (is_numeric($key)) {
          //Recursively look through arrays to find anchor tags.
          foreach ($item as $piece => $value) {
            if (strstr($value['#value'], 'href=')) {
              $form['items'][$key][$piece]['#value'] = strip_tags($form['items'][$key][$piece]['#value'], '<div>,<ul>,<li>,<br>,<p>');
            }
          }
        }
      }
    }
  }

Nothing unreal exists.

wwwoliondorcom's picture
Offline
Joined: 08/18/2010
Juice: 14
Enable the REMOVE ITEM checkbox in the shopping cart ?

Hi,

Sorry to write here but i cannot find where to enable the REMOVE ITEM checkbox in the shopping cart ?

thanks.