Jump to content

Restrict promo codes to Admins only and hide code from invoice? How?


bluesteam

Recommended Posts

Hi,

I have a scenario that I allow my clients to get a discount on the number of hosting packages they buy.

So if the client buys more than 10 packages, he gets a 10% discount across all his packages but the discount only applies on renewals and not initial purchases.

I don't advertise this promo code because I don't want every TomDickAndHarry using the code.

So I manually apply this promo code myself after the client has purchased the hosting package and his order is activated so that upon renewal, the new fee is applied.  I know it is very manual but I don't have another way of automating this without writing code as the system has no feature for only applying the discount on renewal and allows only ADMINS to see the code.

The reason that it is only applied on renewal is because I am already giving the client a FREE DOMAIN for the first year and one the recurring years, they have to pay for the domain and so I only want to apply the promo code for the renewal.

So 2 problems come in now:

1. When the client is being invoiced, the promo code is revealed on the invoice line description. Now the client knows the promo code that is meant to be kept hidden
2. The client now uses this code on his next new hosting purchase when he is not actually allowed to circumventing my entire discount process.

The best case scenario is to have a feature on the Promotions page to only apply the discount if the client has more than x amount of packages and also only on renewals regardless if the client knows the code or not.

But I know thats asking too much So.....

1. How do I restrict the code to ONLY be allowed to be applied by the admins

or

2. Simply HIDE this code from the invoice line description never revealing this code which sort of solves the problem.

Thanks

 

Link to comment
Share on other sites

Hello

The easiest way I am thinking for not show promo codes is apply prices manual overrides, if this clients has 10 hosting in hist account, you will go on his client summary page and edit all 10 products prices manually after calculating new prices (using a calculator) with that hidden discount that only you know, so all invoices will just display new prices you setup up. I usually do this, but like you said before, it will need always a manual intervention, so if this client do not renew for example 3 services, so his discount will be less, so another time you need to overrides all prices for this specially client. 

Let see if others have found a way to do that with some automation.

Link to comment
Share on other sites

13 hours ago, bluesteam said:

The best case scenario is to have a feature on the Promotions page to only apply the discount if the client has more than x amount of packages and also only on renewals regardless if the client knows the code or not.

at least you've been around here long enough to realise that submitting a feature request is pointless (or at least so slow to be completed that sadly it's not worth considering)... so +1 for that. 🙂

13 hours ago, bluesteam said:

1. How do I restrict the code to ONLY be allowed to be applied by the admins 

the obvious way would be to just remove the option from the viewcart template...

jkbiWuo.png

for most users that would solve the issue, but there will be some devilish rascals out there who could find out about the option of adding the code via the URL - for them, removing the promo code box is irrelevant.

you could use a ShoppingCartValidateCheckout hook to throw an error message if they have entered a promo code (either manually or in the URL) and that would prevent them from checking out until they have removed it.

<?php

# Check For Promo Code Hook
# Written by brian!

function check_for_promo_codes_hook($vars) {

    if (!empty($vars['promocode'])) {
        return 'You cannot use promotion codes with your order - click <a href="cart.php?a=removepromo">here</a> to remove the code.';
    }
}
add_hook("ShoppingCartValidateCheckout", 1, "check_for_promo_codes_hook");

N4qOx6q.png

to keep things simple, i've coded the error reply in English - if you were using a multilingual site (which I don't think you are), you could use language strings instead... the error message also includes a link that automatically removes the promo code and takes them back to viewcart - where they then have the option of checking out again, but now paying the full amount for their order.

15 hours ago, bluesteam said:

2. Simply HIDE this code from the invoice line description never revealing this code which sort of solves the problem.

there's probably two options for that - either an InvoiceCreationPreEmail that removes/replaces the specific promotion code with a different or empty string before the invoice/email is sent to the client and updates the database record - that way, the client receives the modified data and not the original.... or you do it all in the templates (both invoice templates and the email templates) with Smarty/PHP replaces.... it really depends if you want to keep the database records unaltered... and want to go to the effort of modifying the templates.

 

Link to comment
Share on other sites

2 hours ago, brian! said:

at least you've been around here long enough to realise that submitting a feature request is pointless (or at least so slow to be completed that sadly it's not worth considering)... so +1 for that. 🙂

 

Yes, I don't waste my time anymore with feature requests because I have seen that the bulk of user requests simply never get implemented. 😞

2 hours ago, brian! said:

the obvious way would be to just remove the option from the viewcart template...

jkbiWuo.png

for most users that would solve the issue, but there will be some devilish rascals out there who could find out about the option of adding the code via the URL - for them, removing the promo code box is irrelevant.

Unfortunately this removes the entire option of ever implementing future promo codes in a different scenario so that's a no go.

2 hours ago, brian! said:

you could use a ShoppingCartValidateCheckout hook to throw an error message if they have entered a promo code (either manually or in the URL) and that would prevent them from checking out until they have removed it.


<?php

# Check For Promo Code Hook
# Written by brian!

function check_for_promo_codes_hook($vars) {

    if (!empty($vars['promocode'])) {
        return 'You cannot use promotion codes with your order - click <a href="cart.php?a=removepromo">here</a> to remove the code.';
    }
}
add_hook("ShoppingCartValidateCheckout", 1, "check_for_promo_codes_hook");

N4qOx6q.png

to keep things simple, i've coded the error reply in English - if you were using a multilingual site (which I don't think you are), you could use language strings instead... the error message also includes a link that automatically removes the promo code and takes them back to viewcart - where they then have the option of checking out again, but now paying the full amount for their order.

This could work but I wonder if it's possible to only implement the hook if the customer enters the promo code that I want to ban him from using.  Like say if I have promo code 10discount and the client enters that, then the hook executes.  Anything else the hook ignores.

i.e. something like

if (!empty($vars['promocode']) AND ($vars['promocode'] = '10discount' ) {

This feels like the best option.  This should be possible right?

 

2 hours ago, brian! said:

there's probably two options for that - either an InvoiceCreationPreEmail that removes/replaces the specific promotion code with a different or empty string before the invoice/email is sent to the client and updates the database record - that way, the client receives the modified data and not the original.... or you do it all in the templates (both invoice templates and the email templates) with Smarty/PHP replaces.... it really depends if you want to keep the database records unaltered... and want to go to the effort of modifying the templates.

I prefer not to fiddle in template files so I'll give this one a skip.

Edited by bluesteam
Link to comment
Share on other sites

5 minutes ago, bluesteam said:

This feels like the best option.  This should be possible right?

you'd only need the second half...

if ($vars['promocode'] == '10discount') {

any other promo code entered should work fine.

8 minutes ago, bluesteam said:

I prefer not to fiddle in template files so I'll give this one a skip.

yeah, I just threw it in as an option - you'd end up having to edit the .tpl templates after every update.

the hook is doable, but would obviously only apply to new orders/invoice and not existing ones... and might be redundant if the cart prevents them from using the code themselves. 🙂

Link to comment
Share on other sites

1 hour ago, brian! said:

the hook is doable, but would obviously only apply to new orders/invoice and not existing ones... and might be redundant if the cart prevents them from using the code themselves. 🙂

The good thing here is that I want to prevent the use of the promo code on new orders so it will work 🙂 

Thanks Brian.  Will see if it works.

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