creative-mountains

Magento - Change Place Order Button for Paypal Button

It recently occurred to us that people seem to be very confused by the place order button on the one page checkout, when Paypal is selected as prefered payment method. Normally when checking out with paypal you expect a Proceed to Paypal button to avoid any confusion. Magento already sends an order notification email once you press the place order button so anyone in their right mind could think they have struck gold and that the order has already been accepted without paying. So, here is my new solution that will allow you to change the place order button for a proceed to paypal button, if paypal is selected.

For our example I'll be using the paypal standard method.

Firstly open up your template folder and go to Checkout/Onepage/review.phtml and replace your current checkout button with the following.

<span id="paypal-buttons" class="a-center" style="display:none;">
<
input type="image" src="<?php echo $this->getSkinUrl('images/btn_paypal_checkout.gif') ?>" onclick="review.save();" value="<?php echo $this->__('Continue to Paypal') ?>" />
</
span>
<
span id="review-buttons-container" class="a-center" style="display:block;">
<
input type="image" src="<?php echo $this->getSkinUrl('images/btn_place_order.gif') ?>" onclick="review.save();" value="<?php echo $this->__('Place Order') ?>" />
</
span>

Once you've done this, you can then add this javascript to the base of the review.phtml file. This is the trigger for the change in button.

<script language="javascript">
function
checkoutbuttons()
{
if (document.getElementById("p_method_paypal_standard").checked == true) {
document
.getElementById("paypal-buttons").style.display = "block";
document.getElementById("review-buttons-container").style.display = "none";
}
if (document.getElementById("p_method_paypal_standard").checked == false) {
document
.getElementById("paypal-buttons").style.display = "none";
document.getElementById("review-buttons-container").style.display = "block";
}
}
</script>

Finally, you'll need to open up methods.phtml, also in the checkout/onepage folder and replace the onlick function to the following.

onclick="payment.switchMethod('<?php echo $_code ?>'); checkoutbuttons()"

Save both the files and you'll be set.
creative-trees