PDA

View Full Version : Help me finish: Discount for paid subscriptions


luroca
05-24-2005, 04:04 PM
Please, excuse my bad English.

This hack allows to assign to paid subscriptions a discount for selected usergroups. It is a very requested hack and I was tired to wait that somebody writes it. The problem is that I don?t know to code :)

It has two ?minor? bugs and a very important bug:
Minor bugs:

1) The discount is the same for all currencies (dollars, pounds, euros). It?s only a problem if you have prices in more than one currency.
2) The format of the cost changes from (for example) $5.00 to $5 (without the .00) if discount is applied. It is an aesthetic bug.

The very important bug:

3) The transaction with paypal goes OK, the user pays his subscription (with discount), he receives his receipt, he returns to the forum but no subscription it is applied to the user or writen in the database. As the doctors say: the surgery has been a success but the patient has died.

Is this forum the correct place and somebody can help me with this hack?

Thanks in advance

amykhar
05-24-2005, 04:45 PM
First very important question. Do your non-discounted subscriptions work?

luroca
05-24-2005, 05:51 PM
Very good question, I see :)

If discount = 0, OK
If discount = "", OK
If discount exists and user is not in usergroups with discount, OK

if discount exist and user has discount, FAIL

Thanks for your interest.

amykhar
05-24-2005, 06:06 PM
Next question. Look at the code where payments are accepted. In the area where it verifies the transaction and makes the usergroup switch, etc. does it check to see if the received payment equals the subscription amount that you established?

It looks like it does on this line in paypal.php


$cost = unserialize($sub['cost']);


If so, that's your problem. You are going to have to account for the discount.

luroca
05-24-2005, 06:19 PM
I have edited 3 files:

/includes/function_subscriptions.php
/admincp/subscriptions.php
/forum/subscriptions.php

but not paypal.php file. Must I edit it? Please, which values/variables are compared?

amykhar
05-24-2005, 06:38 PM
I showed you the line. And, the file you edit depends on the type of subscription service you are using.

If you are using paypal, change that line so that the cost is equal to the base cost or the discounted cost. Then, it will pass that cost off to the build_subscriptions function and you should be good to go.

luroca
05-24-2005, 06:45 PM
Thank you very much, as coder I am a pity but I´ll try.
Thanks again.