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);