By Xangis on
I'm building a storefront using the ecommerce module, but there's one simple thing I don't see how to do.
Right now a product page shows ">> Add to Cart" link at the bottom of the product. I want to replace this with a button that says the same thing and performs the same function (shoppers like easy-to-find buttons). How would I go about doing this?
Comments
Add a CSS class
You could add a class to the link in your template and style it with CSS.
Example HTML:
<a href="cart" class="btn-add">Add to cart</a>Example CSS:
You could add a background image if you like as well.
it works
I can verify that this technique works in ecommerce. This is what I had to do specifically (for other newbies like me!):
1) Add this to the top of the style.css file for my theme:
2) In product.module for ecommerce, find the function product_link (around line 281) and replace this (around line 302):
'attributes' => array('class' => 'cart_add', 'title' => t('Add this item to your shopping cart.')),with this:
'attributes' => array('class' => 'btn-add', 'title' => t('Add this item to your shopping cart.')),Why did you change the class
Why did you change the class name?
Every time you upgrade E-Commerce you'll have to change it again.
The point of using classes is that you should never have to change their names - just change the CSS.
good point
I guess I just changed it without thinking about it because the code in the first comment changed it. You're right, though -- there's no need to change the class name.
Using class=cart-link
The same we did for Read More button
Add the following to your style.css, and upload the button to the theme folder
Replace read-more in each above to cart-link (or is it something else?)
To see the effect, see http://almuslimin.org (The blue Read More button which turns to red upon mouse over)
*I cant remember what is the default class="?" for the `Add to Cart' link for Drupal 5.1 but for 4.7.x, the E-commerce module has already created class="something" for ad to cart