Jump to content

PayPal payment only for Domains


Aladdin

Recommended Posts

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

Link to comment
Share on other sites

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. :idea:

Link to comment
Share on other sites

  • 3 years later...
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. :idea:

Hi Brian, is there a way to achieve this in WHMCS +8.0?

Thanks!

Link to comment
Share on other sites

  • 3 weeks later...
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated