I want to change Magento add to cart to buy now and also I want to redirect the page. How to made that changes??
Magento – Rename add to cart to buy now
addtocart
Related Solutions
Kindly open app/design/frontend/package/theme/template/catalog/product/view.phtml
Add below line into <form>
Tag
<input type="hidden" name="buy_now" id="buy_now" value="" />
Put below button at anywhere where you want
<button type="button" onclick="jQuery('#buy_now').val('buy_now');productAddToCartForm.submit(this)" class="btn btn-block btn-express-buynow"><i class="cart-icon-white m-r-sm v-middle"></i>Buy Now</button>
Now open app/code/core/Mage/Checkout/controllers/CartController.php
First of all move this file into the local folder and change the code as below instructions
Put below line in _goBack()
function at very first
$buy_now = $this->getRequest()->getParam('buy_now');
FInd the line $this->getResponse()->setRedirect($backUrl); and replace this line as below code
if (!empty($buy_now)) {
$this->_redirect('onepagecheckout'); // If you are using onepagecheckout or use this $this->_redirect('checkout/onepage/')
}else{
$this->getResponse()->setRedirect($backUrl);
}
Code Taken from this link http://chandreshrana.blogspot.in/2016/01/how-to-add-buynow-button-on-product.html
Please add this in your phtml file where you want to add :
<div class="add-to-cart">
<div class="qty-view">
<?php if(!$_product->isGrouped()): ?>
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty validate-greater-than-zero-qty validate-digits" />
<?php endif; ?>
</div>
<button type="button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<button type="button" title="Buy Now" class="button btn-cart" onclick="setcheckoutLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span>Buy Now</span></span></button>
<?php echo $this->getChildHtml('', true, true) ?>
</div>
and must be added this script for Buy Now button :
<script type="text/javascript">
function setcheckoutLocation(location)
{
showLoadingAnimation();
jQuery.ajax({
type:"GET",
url:location,
success:function(data){
window.location.href = "<?php echo Mage::helper('checkout/url')->getCheckoutUrl(); ?>";
}
});
}
</script>
Best Answer
So to translate the text you can do a few things.
I would go with the theme locale option here. Just create a file
public/app/design/frontend/your_package/your_theme/locale/en_US/translate.csv
then in this file translate your string.