[Skip to main content](#vessel-content)

#   show payment method if certain product in basket

##

- **[daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")**
- [![daveturner101's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/guitar.gif)](/forum/user/13550-daveturner101 "View daveturner101's Profile") Topic Author
- [ Offline](/forum/user/13550-daveturner101)

Less More

- Posts: 72
- Thank you received: 0
-
-

12 years 10 months ago -  12 years 10 months ago [\#139662](#139662) by [daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")  *[show payment method if certain product in basket](/forum/29-payment-methods/864975-show-payment-method-if-certain-product-in-basket#139662 "hi,  we've recently updated from 2.1.0 starter edition to 2.2.3 business edition.  the update has meant that some of our payment plugin customisations have been lost. this is fine, we knew it would happen.  i'm trying to add the small code customisations back into the plugins but the code looks to have changed quite a bit since we added them.  we had edited the paypal payment plugin files to only show certain payment methods if a certain product was in the basket. the code for hikashoppayment/paypal/paypal.php used to look like this: (just the first part of the file...)  and this is our custom code:  can someone tell me where to put that code in the latest hikashoppayment/paypal/paypal.php ??  is is possible to just add some customisations to the view checkout / payment.php instead?  the original code for this came from this topic:   www.hikashop.com/forum/4-how-to/16141-co...sed-on-products.html  many thanks")* was created by *[daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")*

hi,

we've recently updated from 2.1.0 starter edition to 2.2.3 business edition.

the update has meant that some of our payment plugin customisations have been lost. this is fine, we knew it would happen.

i'm trying to add the small code customisations back into the plugins but the code looks to have changed quite a bit since we added them.

we had edited the paypal payment plugin files to only show certain payment methods if a certain product was in the basket. the code for hikashoppayment/paypal/paypal.php used to look like this: (just the first part of the file...)

Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.1.0 * @author hikashop.com * @copyright (C) 2010-2012 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php class plgHikashoppaymentPaypal extends JPlugin { var $accepted_currencies = array( 'AUD','CAD','EUR','GBP','JPY','USD','NZD','CHF','HKD','SGD', 'SEK','DKK','PLN','NOK','HUF','CZK','MXN','BRL','MYR','PHP', 'TWD','THB','ILS','TRY' ); var $debugData = array(); function onPaymentDisplay(&amp;$order,&amp;$methods,&amp;$usable_methods){ if(!empty($methods)){ foreach($methods as $method){ if($method-&gt;payment_type!='paypal' &#124;&#124; !$method-&gt;enabled){ continue; } if(!empty($method-&gt;payment_zone_namekey)){ $zoneClass=hikashop_get('class.zone'); $zones = $zoneClass-&gt;getOrderZones($order); if(!in_array($method-&gt;payment_zone_namekey,$zones)){ return true; } } $currencyClass = hikashop_get('class.currency'); $null=null; if(!empty($order-&gt;total)){ $currency_id = intval(@$order-&gt;total-&gt;prices[0]-&gt;price_currency_id); $currency = $currencyClass-&gt;getCurrencies($currency_id,$null); if(!empty($currency) &amp;&amp; !in_array(@$currency[$currency_id]-&gt;currency_code,$this-&gt;accepted_currencies)){ return true; } } $show = 0; $pIds = array('1','8','9','6','13','16','121','125','129','131','133','151','152','153','154','155','156','158'); foreach($order-&gt;products as $product){ if(in_array($product-&gt;product_id, $pIds)) $show = 1; } if($show == 1) $usable_methods[$method-&gt;ordering]=$method; } } return true; } function onPaymentSave(&amp;$cart,&amp;$rates,&amp;$payment_id){ $usable = array(); $this-&gt;onPaymentDisplay($cart,$rates,$usable); $payment_id = (int) $payment_id; foreach($usable as $usable_method){ if($usable_method-&gt;payment_id==$payment_id){ return $usable_method; } } return false; }

and this is our custom code:
Code:

$show = 0; $pIds = array('1','8','9','6','13','16','121','125','129','131','133','151','152','153','154','155','156','158'); foreach($order-&gt;products as $product){ if(in_array($product-&gt;product_id, $pIds)) $show = 1; } if($show == 1)

can someone tell me where to put that code in the latest hikashoppayment/paypal/paypal.php ??

is is possible to just add some customisations to the view checkout / payment.php instead?

the original code for this came from this topic: [ www.hikashop.com/forum/4-how-to/16141-co...sed-on-products.html](http://www.hikashop.com/forum/4-how-to/16141-code-to-filter-payment-display-based-on-products.html)

many thanks

Last edit: 12 years 10 months ago by [daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NjQ5NzUtc2hvdy1wYXltZW50LW1ldGhvZC1pZi1jZXJ0YWluLXByb2R1Y3QtaW4tYmFza2V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86560
- Thank you received: 14307
-
-

12 years 10 months ago [\#139682](#139682) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[show payment method if certain product in basket](/forum/29-payment-methods/864975-show-payment-method-if-certain-product-in-basket#139682 "hi,  we've recently updated from 2.1.0 starter edition to 2.2.3 business edition.  the update has meant that some of our payment plugin customisations have been lost. this is fine, we knew it would happen.  i'm trying to add the small code customisations back into the plugins but the code looks to have changed quite a bit since we added them.  we had edited the paypal payment plugin files to only show certain payment methods if a certain product was in the basket. the code for hikashoppayment/paypal/paypal.php used to look like this: (just the first part of the file...)  and this is our custom code:  can someone tell me where to put that code in the latest hikashoppayment/paypal/paypal.php ??  is is possible to just add some customisations to the view checkout / payment.php instead?  the original code for this came from this topic:   www.hikashop.com/forum/4-how-to/16141-co...sed-on-products.html  many thanks")*

Hi,

The onPaymentDisplay function is now in the hikashopPaymentPlugin class so that not all the payment plugins need the same function copy/pasted in them.
If you want to personnalise it, simply copy that function from the file administrator/components/com_hikashop/helpers/helper.php where that class is defined and paste it in your plugin's class. Then, add again your custom code in there.

You can also customize the file "payment" of the view "checkout" via the menu Display&gt;Views. That way, you won't have to reapply your modification each time you update. But the code will have to be adapted as you don't have the products loaded in there. You can use such code to get the full cart including the products array : Code:

$class = hikashop_get('class.cart'); $cart = $class-&gt;loadFullCart();

The following user(s) said Thank You: [daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NjQ5NzUtc2hvdy1wYXltZW50LW1ldGhvZC1pZi1jZXJ0YWluLXByb2R1Y3QtaW4tYmFza2V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")**
- [![daveturner101's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/guitar.gif)](/forum/user/13550-daveturner101 "View daveturner101's Profile") Topic Author
- [ Offline](/forum/user/13550-daveturner101)

Less More

- Posts: 72
- Thank you received: 0
-
-

12 years 10 months ago [\#139743](#139743) by [daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")  Replied by *[daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")* on topic *[show payment method if certain product in basket](/forum/29-payment-methods/864975-show-payment-method-if-certain-product-in-basket#139743 "hi,  we've recently updated from 2.1.0 starter edition to 2.2.3 business edition.  the update has meant that some of our payment plugin customisations have been lost. this is fine, we knew it would happen.  i'm trying to add the small code customisations back into the plugins but the code looks to have changed quite a bit since we added them.  we had edited the paypal payment plugin files to only show certain payment methods if a certain product was in the basket. the code for hikashoppayment/paypal/paypal.php used to look like this: (just the first part of the file...)  and this is our custom code:  can someone tell me where to put that code in the latest hikashoppayment/paypal/paypal.php ??  is is possible to just add some customisations to the view checkout / payment.php instead?  the original code for this came from this topic:   www.hikashop.com/forum/4-how-to/16141-co...sed-on-products.html  many thanks")*

> nicolas wrote: Hi,
>
> The onPaymentDisplay function is now in the hikashopPaymentPlugin class so that not all the payment plugins need the same function copy/pasted in them.
> If you want to personnalise it, simply copy that function from the file administrator/components/com\_hikashop/helpers/helper.php where that class is defined and paste it in your plugin's class. Then, add again your custom code in there.
>
> You can also customize the file "payment" of the view "checkout" via the menu Display&gt;Views. That way, you won't have to reapply your modification each time you update. But the code will have to be adapted as you don't have the products loaded in there. You can use such code to get the full cart including the products array :
>
> Code:
>
> $class = hikashop_get('class.cart'); $cart = $class-&gt;loadFullCart();

thanks for the info. is it OK to remove the onPaymentDisplay function from helper.php completely and just put it into the payment plugins that i want to support?

will having different the function defined in two places cause conflict?

thanks again for the help

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NjQ5NzUtc2hvdy1wYXltZW50LW1ldGhvZC1pZi1jZXJ0YWluLXByb2R1Y3QtaW4tYmFza2V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86560
- Thank you received: 14307
-
-

12 years 10 months ago [\#139819](#139819) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[show payment method if certain product in basket](/forum/29-payment-methods/864975-show-payment-method-if-certain-product-in-basket#139819 "hi,  we've recently updated from 2.1.0 starter edition to 2.2.3 business edition.  the update has meant that some of our payment plugin customisations have been lost. this is fine, we knew it would happen.  i'm trying to add the small code customisations back into the plugins but the code looks to have changed quite a bit since we added them.  we had edited the paypal payment plugin files to only show certain payment methods if a certain product was in the basket. the code for hikashoppayment/paypal/paypal.php used to look like this: (just the first part of the file...)  and this is our custom code:  can someone tell me where to put that code in the latest hikashoppayment/paypal/paypal.php ??  is is possible to just add some customisations to the view checkout / payment.php instead?  the original code for this came from this topic:   www.hikashop.com/forum/4-how-to/16141-co...sed-on-products.html  many thanks")*

There is no need to remove it in the helper. If you add it in your payment plugins, your function will automatically override the one of the helper.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NjQ5NzUtc2hvdy1wYXltZW50LW1ldGhvZC1pZi1jZXJ0YWluLXByb2R1Y3QtaW4tYmFza2V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")**
- [![daveturner101's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/guitar.gif)](/forum/user/13550-daveturner101 "View daveturner101's Profile") Topic Author
- [ Offline](/forum/user/13550-daveturner101)

Less More

- Posts: 72
- Thank you received: 0
-
-

12 years 9 months ago [\#140111](#140111) by [daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")  Replied by *[daveturner101](/forum/user/13550-daveturner101 "View daveturner101's Profile")* on topic *[show payment method if certain product in basket](/forum/29-payment-methods/864975-show-payment-method-if-certain-product-in-basket#140111 "hi,  we've recently updated from 2.1.0 starter edition to 2.2.3 business edition.  the update has meant that some of our payment plugin customisations have been lost. this is fine, we knew it would happen.  i'm trying to add the small code customisations back into the plugins but the code looks to have changed quite a bit since we added them.  we had edited the paypal payment plugin files to only show certain payment methods if a certain product was in the basket. the code for hikashoppayment/paypal/paypal.php used to look like this: (just the first part of the file...)  and this is our custom code:  can someone tell me where to put that code in the latest hikashoppayment/paypal/paypal.php ??  is is possible to just add some customisations to the view checkout / payment.php instead?  the original code for this came from this topic:   www.hikashop.com/forum/4-how-to/16141-co...sed-on-products.html  many thanks")*

> nicolas wrote: There is no need to remove it in the helper. If you add it in your payment plugins, your function will automatically override the one of the helper.

thanks, does it matter if i have removed it? i guess not..?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NjQ5NzUtc2hvdy1wYXltZW50LW1ldGhvZC1pZi1jZXJ0YWluLXByb2R1Y3QtaW4tYmFza2V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86560
- Thank you received: 14307
-
-

12 years 9 months ago [\#140186](#140186) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[show payment method if certain product in basket](/forum/29-payment-methods/864975-show-payment-method-if-certain-product-in-basket#140186 "hi,  we've recently updated from 2.1.0 starter edition to 2.2.3 business edition.  the update has meant that some of our payment plugin customisations have been lost. this is fine, we knew it would happen.  i'm trying to add the small code customisations back into the plugins but the code looks to have changed quite a bit since we added them.  we had edited the paypal payment plugin files to only show certain payment methods if a certain product was in the basket. the code for hikashoppayment/paypal/paypal.php used to look like this: (just the first part of the file...)  and this is our custom code:  can someone tell me where to put that code in the latest hikashoppayment/paypal/paypal.php ??  is is possible to just add some customisations to the view checkout / payment.php instead?  the original code for this came from this topic:   www.hikashop.com/forum/4-how-to/16141-co...sed-on-products.html  many thanks")*

It doesn't matter if you added it in all the payment plugins you're using.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NjQ5NzUtc2hvdy1wYXltZW50LW1ldGhvZC1pZi1jZXJ0YWluLXByb2R1Y3QtaW4tYmFza2V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.074 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
