Modifying the buy button

Modifying the buy button

Postby admin » Tue Apr 27, 2010 8:40 am

Changing the button text

To change the button text we use a simple PHP function which will replace some text with your choice.

In the product.tpl file found in your template folder add this code at the top of the file:

Code: Select all
$this->product->pricing->buy_button = str_replace(LangAddToCart,'Buy Me Now',$this->product->pricing->buy_button);


In the above example we have changed the text from Add To Cart to Buy Me Now

Make the button open a new window when clicked

To make the button open a new window we use the same PHP function used to rename the button, this time the text being replaced will be adding new code to the form which tells your browser to open a new window.

In the product.tpl file add this code at the top:

Code: Select all
<?php
$this->product->pricing->buy_button = str_replace('method="get"','method="get" target="_blank"',$this->product->pricing->buy_button);
?>


As you can see, method="get" already exists in the form so we choose to replace that with method="get" and target="_blank" appended to the end to enable the new form behaviour.

Change buy button to use an image

1. First you will need to create a image and upload it somewhere on your webserver. If you are using the default template then I suggest uploading the image to /templates/default/image

2. modify the template's css by adding this code:

Code: Select all
input.cartSubmit {
   background:url(../image/your-image-file.png) no-repeat;
   border: none;
   cursor:pointer;
   color: transparent;
   height:36px;
   width:140px;
}


3. Remove the button text (for IE support)

At the top of product.tpl add this code to remove the button's text:

Code: Select all
$this->product->pricing->buy_button = str_replace(LangAddToCart,'',$this->product->pricing->buy_button);
User avatar
admin
Site Admin
 
Posts: 462
Joined: Sun Nov 22, 2009 7:24 pm

Re: Modifying the buy button

Postby twitch » Sat May 08, 2010 5:24 pm

Here guys I came across this site the other day it has a crap load of shopping cart buttons

http://www.getelastic.com/add-to-cart-buttons/

Enjoy :)
twitch

 
Posts: 254
Joined: Sat Feb 20, 2010 12:09 am


Return to Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

cron