Hi all,

I am doing a drupal site for a client and for some reason he would like his own graphics used for the 'add to cart' button instead of the text link.

Does anyone know how to replace the code and where for the text link and replace it with a graphic button?

Kind regards

Comments

Bèr Kessels’s picture

The line in your CSS should be something like
a.cart_link {background-image: url('theme-images/cart.png'); etc.}
all A (links) with the class 'cart_link' will be changed.
You should change this in the style.css of your custom theme.

You might also want to read this post on more advnaced image replacement techniques:http://wellstyled.com/css-replace-text-by-image.html

Bèr
---
Professional | Personal
| Sympal: Development and Hosting

shaheenery’s picture

That is a very good start but then all you have is the button behind the 'add to cart' text, which looks ridiculous. I have found the code in the product.module file and it says something like:

 $links[] = l(t('add to cart'), "cart/add/$node->nid", array('class' => 'cart_link', 'title' => t('Add this item to your shopping cart.')), drupal_get_destination());

Of course if you just delete the 'add to cart' test there will be no object for your button to be the background of, you can't set height and width on an anchor tag with no text (or just a space in it for that matter)

I tried to just change it to:

$links[] = l(t("<img src='/files/images/addtobasket.gif'>"), "cart/add/$node->nid", array('class' => 'cart_link', 'title' => t('Add this item to your shopping cart.')), drupal_get_destination());

but it actually outputs the whole text the HTML doesn't get parsed

I am newer than newbie at this point, I've been poking around this file trying to see what is making this happen. I would love to see this being an option in the cart module. Can anyone help me and this other newbie?

mohan.ankur’s picture

i have the same issue. can anyone please help newbies?
many thanks

melchoir55’s picture