Magento - Proceed to Checkout button location in theme
-
23-06-2021 - |
题
I am looking to track down the file (and it's location) that generates the "Proceed to Checkout" button in the Magento cart.
Try adding a product to the cart, and then proceeding to the cart. The "Proceed to Checkout" button is on the right hand side of the cart.
I am using a hacked-about variation of the blank theme, if that makes any difference.
Thanks in advance for your help.
解决方案
The code that produces the Proceed to Checkout link is in templates/checkout/onepage/link.phtml
By default the block for it is in checkout.xml;
<block type="core/text_list" name="checkout.cart.methods" as="methods" translate="label">
<label>Payment Methods After Checkout Button</label>
<block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
<block type="checkout/multishipping_link" name="checkout.cart.methods.multishipping" template="checkout/multishipping/link.phtml"/>
</block>
其他提示
app/design/frontend/your_package/your_theme/template/checkout/onepage/link.phtml
The "Proceed to Checkout" button that leads to the onepage checkout, is generated with this template : checkout/onepage/link.phtml
.
You should be able to know what buttons are added with which templates by looking at the checkout_cart_index
handle of the checkout.xml
layout file. The block named checkout.cart.methods
contains all the buttons, and the two base checkout buttons should be added to it directly in the same file.
Go to System -> Configuration -> Developer change a Current Configuration Scope to some of your websites or stores than go to Debug section - and change Template Path Hints setting to "Yes". Now, on frontend, you'll see an full path to your template file on a filesystem for every block that rendered, so now you can see where your template (that renders a link) exists.
Open this path in your root directory
/app/design/frontend/base/default/template/checkout/onepage/link.phtml
find this code
<?php if ($this->isPossibleOnepageCheckout()):?>
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Proceed to Checkout')) ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php endif?>