Aladdin Posted March 9, 2017 Share Posted March 9, 2017 I have 3 payment gateways set up as currently most of my customers are local. PayPal, Bacs and Cheque. When I create a product I can easily select which methods to use and assign for this product. Recently I have started selling domains and I would like to set up domain sales only using PayPal Gateway. But I cannot find this option. Please can someone help me to set this up or point me where the setting is if there is one. Thanks Aladdin 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 9, 2017 Share Posted March 9, 2017 there isn't a similar setting for non-product items - you'd need to customise your installation... one way might be via a quick template edit to checkout.tpl, .e.g if you're using Standard Cart, you would change... <div class="text-center"> {foreach key=num item=gateway from=$gateways} <label class="radio-inline"> <input type="radio" name="paymentmethod" value="{$gateway.sysname}" class="payment-methods{if $gateway.type eq "CC"} is-credit-card{/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /> {$gateway.name} </label> {/foreach} </div> to... <div class="text-center"> {foreach key=num item=gateway from=$gateways} <label class="radio-inline"> {if $domains|@count gt 0 and $products|@count eq 0 and $gateway.sysname eq "paypal"}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" class="payment-methods{if $gateway.type eq "CC"} is-credit-card{/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /> {$gateway.name} {elseif $products|@count gt 0}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" class="payment-methods{if $gateway.type eq "CC"} is-credit-card{/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /> {$gateway.name} {/if} </label> {/foreach} </div> that will hide the other gateways if there are only domains in the cart (so only PayPal is visible), or show all available gateways for that group, if there are products in the cart. 0 Quote Link to comment Share on other sites More sharing options...
companyglue Posted February 10, 2021 Share Posted February 10, 2021 On 9/03/2017 at 8:42 AM, brian! said: there isn't a similar setting for non-product items - you'd need to customise your installation... one way might be via a quick template edit to checkout.tpl, .e.g if you're using Standard Cart, you would change... <div class="text-center"> {foreach key=num item=gateway from=$gateways} <label class="radio-inline"> <input type="radio" name="paymentmethod" value="{$gateway.sysname}" class="payment-methods{if $gateway.type eq "CC"} is-credit-card{/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /> {$gateway.name} </label> {/foreach} </div> to... <div class="text-center"> {foreach key=num item=gateway from=$gateways} <label class="radio-inline"> {if $domains|@count gt 0 and $products|@count eq 0 and $gateway.sysname eq "paypal"}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" class="payment-methods{if $gateway.type eq "CC"} is-credit-card{/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /> {$gateway.name} {elseif $products|@count gt 0}<input type="radio" name="paymentmethod" value="{$gateway.sysname}" class="payment-methods{if $gateway.type eq "CC"} is-credit-card{/if}"{if $selectedgateway eq $gateway.sysname} checked{/if} /> {$gateway.name} {/if} </label> {/foreach} </div> that will hide the other gateways if there are only domains in the cart (so only PayPal is visible), or show all available gateways for that group, if there are products in the cart. Hi Brian, is there a way to achieve this in WHMCS +8.0? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 3, 2021 Share Posted March 3, 2021 On 10/02/2021 at 21:04, companyglue said: Hi Brian, is there a way to achieve this in WHMCS +8.0? you could use an action hook... <?php # Remove Gateways for Domain Registrations Hook # Written by brian! function cart_gateway_removal_for_domains($vars) { if ($vars['templatefile']=='viewcart'){ $gateways = $vars['gateways']; $allowed = ['mailin','paypal','stripe']; foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$allowed) and count($vars['domains'] > 0)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } } add_hook("ClientAreaPageCart", 1, "cart_gateway_removal_for_domains"); bear in mind that there are a lot of different PayPal gateway options available now, so yours might not necessarily be called 'paypal', but viewing the page source in the browser should tell you what the payment gateway name is and so what to use in the $allowed array. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.