Skip to content

Commit f2610ff

Browse files
authored
Avoided unnecessary payment_method_is_active event on every page load (#576) (#577)
1 parent adaafff commit f2610ff

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

app/code/core/Mage/Paypal/Block/Express/Shortcut.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ protected function _beforeToHtml()
101101
}
102102

103103
// check payment method availability
104+
if (!$config->isMethodActive($this->_paymentMethodCode)) {
105+
$this->_shouldRender = false;
106+
return $result;
107+
}
104108
$methodInstance = Mage::helper('payment')->getMethodInstance($this->_paymentMethodCode);
105109
if (!$methodInstance || !$methodInstance->isAvailable($quote)) {
106110
$this->_shouldRender = false;

app/design/frontend/base/default/layout/paypal.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
<layout version="0.1.0">
1414
<checkout_cart_index>
1515
<reference name="checkout.cart.top_methods">
16-
<block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.top" before="checkout.cart.methods.onepage.top" template="paypal/express/shortcut.phtml">
16+
<block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.top" before="checkout.cart.methods.onepage.top" template="paypal/express/shortcut.phtml" ifconfig="payment/paypal_express/active">
1717
<action method="setIsQuoteAllowed"><value>1</value></action>
1818
<action method="setShowOrPosition"><value>after</value></action>
1919
</block>
2020
</reference>
2121

2222
<reference name="checkout.cart.methods">
23-
<block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.bottom" before="checkout.cart.methods.onepage.bottom" template="paypal/express/shortcut.phtml">
23+
<block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.bottom" before="checkout.cart.methods.onepage.bottom" template="paypal/express/shortcut.phtml" ifconfig="payment/paypal_express/active">
2424
<action method="setIsQuoteAllowed"><value>1</value></action>
2525
<action method="setShowOrPosition"><value>after</value></action>
2626
</block>
@@ -80,7 +80,7 @@ Available logo types can be assigned with action="setLogoType":
8080
<block type="page/html_wrapper" name="product.info.addtocart.paypal.wrapper" translate="label">
8181
<action method="setMayBeInvisible"><value>true</value></action>
8282
<label>PayPal Express Checkout Shortcut Wrapper</label>
83-
<block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/product/shortcut.phtml">
83+
<block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/product/shortcut.phtml" ifconfig="payment/paypal_express/active">
8484
<action method="setIsInCatalogProduct"><value>1</value></action>
8585
</block>
8686
</block>
@@ -131,10 +131,10 @@ Available logo types can be assigned with action="setLogoType":
131131

132132
<default>
133133
<reference name="topCart.extra_actions">
134-
<block type="paypal/express_shortcut" name="paypal.partner.top_cart.shortcut" template="paypal/express/shortcut.phtml"/>
134+
<block type="paypal/express_shortcut" name="paypal.partner.top_cart.shortcut" template="paypal/express/shortcut.phtml" ifconfig="payment/paypal_express/active"/>
135135
</reference>
136136
<reference name="cart_sidebar.extra_actions">
137-
<block type="paypal/express_shortcut" name="paypal.partner.cart_sidebar.shortcut" template="paypal/express/minicart/shortcut.phtml"/>
137+
<block type="paypal/express_shortcut" name="paypal.partner.cart_sidebar.shortcut" template="paypal/express/minicart/shortcut.phtml" ifconfig="payment/paypal_express/active"/>
138138
</reference>
139139
</default>
140140

@@ -162,7 +162,7 @@ Available logo types can be assigned with action="setLogoType":
162162
<SHORTCUT_popup>
163163
<reference name="product.tooltip">
164164
<block type="page/html_wrapper" name="product.info.addtocart.paypal.wrapper" translate="label">
165-
<block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/shortcut.phtml">
165+
<block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/shortcut.phtml" ifconfig="payment/paypal_express/active">
166166
<action method="setIsInCatalogProduct"><value>1</value></action>
167167
<action method="setShowOrPosition"><value>after</value></action>
168168
</block>

app/design/frontend/base/default/layout/paypaluk.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<layout version="0.1.0">
1414
<checkout_cart_index>
1515
<reference name="checkout.cart.top_methods">
16-
<block type="paypaluk/express_shortcut" name="checkout.cart.methods.paypaluk_express.top" before="-" template="paypal/express/shortcut.phtml">
16+
<block type="paypaluk/express_shortcut" name="checkout.cart.methods.paypaluk_express.top" before="-" template="paypal/express/shortcut.phtml" ifconfig="payment/paypaluk_express/active">
1717
<action method="setIsQuoteAllowed"><value>1</value></action>
1818
</block>
1919
</reference>
2020
<reference name="checkout.cart.methods">
21-
<block type="paypaluk/express_shortcut" name="checkout.cart.methods.paypaluk_express.bottom" before="-" template="paypal/express/shortcut.phtml">
21+
<block type="paypaluk/express_shortcut" name="checkout.cart.methods.paypaluk_express.bottom" before="-" template="paypal/express/shortcut.phtml" ifconfig="payment/paypaluk_express/active">
2222
<action method="setIsQuoteAllowed"><value>1</value></action>
2323
</block>
2424
</reference>
@@ -67,7 +67,7 @@
6767
<label>PayPal Express Checkout (Payflow Edition) Shortcut Wrapper</label>
6868
<action method="setHtmlTagName"><tag>p</tag></action>
6969
<action method="setElementClass"><class>paypal-logo</class></action>
70-
<block type="paypaluk/express_shortcut" name="product.info.addtocart.paypaluk" template="paypal/express/shortcut.phtml">
70+
<block type="paypaluk/express_shortcut" name="product.info.addtocart.paypaluk" template="paypal/express/shortcut.phtml" ifconfig="payment/paypaluk_express/active">
7171
<action method="setIsInCatalogProduct"><value>1</value></action>
7272
</block>
7373
</block>
@@ -77,10 +77,10 @@
7777

7878
<default>
7979
<reference name="topCart.extra_actions">
80-
<block type="paypaluk/express_shortcut" name="paypaluk.partner.top_cart.shortcut" template="paypal/express/shortcut.phtml"/>
80+
<block type="paypaluk/express_shortcut" name="paypaluk.partner.top_cart.shortcut" template="paypal/express/shortcut.phtml" ifconfig="payment/paypaluk_express/active"/>
8181
</reference>
8282
<reference name="cart_sidebar.extra_actions">
83-
<block type="paypaluk/express_shortcut" name="paypaluk.partner.cart_sidebar.shortcut" template="paypal/express/shortcut.phtml"/>
83+
<block type="paypaluk/express_shortcut" name="paypaluk.partner.cart_sidebar.shortcut" template="paypal/express/shortcut.phtml" ifconfig="payment/paypaluk_express/active"/>
8484
</reference>
8585
</default>
8686

@@ -129,7 +129,7 @@
129129
<SHORTCUT_uk_popup>
130130
<reference name="product.tooltip">
131131
<block type="page/html_wrapper" name="product.info.addtocart.paypaluk.wrapper" translate="label">
132-
<block type="paypaluk/express_shortcut" name="product.info.addtocart.paypaluk" template="paypal/express/shortcut.phtml">
132+
<block type="paypaluk/express_shortcut" name="product.info.addtocart.paypaluk" template="paypal/express/shortcut.phtml" ifconfig="payment/paypaluk_express/active">
133133
<action method="setIsInCatalogProduct"><value>1</value></action>
134134
<action method="setShowOrPosition"><value>after</value></action>
135135
</block>

0 commit comments

Comments
 (0)