OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Display registration options on Paypal payment page?

Are you responsible for making OCS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, michael, John

Forum rules
What to do if you have a technical problem with OCS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

Display registration options on Paypal payment page?

Postby pagination » Wed Oct 27, 2010 4:56 am

My conference has eight registration types, all at different prices, and a dozen or so registration options, at different prices for each registration type. When the user is taken to the Paypal page, all that is displayed is the registration type and the total fees (correctly calculated). For the sake of clarity, I would like this page to display the registration options which have been selected.

I took some code from registrationForm.tpl and slotted it into paymentForm.tpl just before the Continue button, adding <table>...</table> and <form>...</form> tags, as follows:

Code: Select all
<form>
<table class="data" width="100%">
   {foreach from=$registrationOptions item=registrationOption name=registrationOptions}
{assign var=optionId value=$registrationOption->getOptionId()}
<tr valign="top">
   {if $smarty.foreach.registrationOptions.first}
      <td rowspan="{$registrationOptions|@count}" class="label">{translate key="schedConf.registration.options"}</td>
   {/if}
   <td class="value">
      <input id="registrationOptions-{$optionId|escape}" {if $registrationoptionids && in_array($optionid, $registrationoptionids)}checked="checked" {/if}type="checkbox" name="registrationOptionIds[]" value="{$optionId|escape}]"/> <label for="registrationOptions-{$optionId|escape}">{$registrationOption->getRegistrationOptionName()}</label>
   </td>
</tr>
{/foreach}
</table>
</form>


However, this does not find any registration options; the only code which is generated in the HTML page is:

Code: Select all
<form><table class="data" width="100%">
</table></form>


What other changes do I need to make in order to have the registration options displayed? It doesn't have to be only those selected which are displayed; I don't mind if the non-selected ones are displayed as well, so long as the checkbox for the selected ones is ticked. I would be grateful for any help here!

Edited to add: I'm using version 2.1.2.
pagination
 
Posts: 6
Joined: Wed Apr 28, 2010 7:29 am

Re: Display registration options on Paypal payment page?

Postby michael » Wed Oct 27, 2010 9:51 pm

Hi pagination,

This is actually a bit tricky since by the time the payment form is displayed, it really only knows the total cost of the queued payment (i.e. the payment that's waiting for a confirmation from PayPal).

What you'll need to do is pass along the selected registration options to the payment form display.

Have a look in
Code: Select all
classes/registration/form/UserRegistrationForm.inc.php


At the end of that file, you'll find an execute() function, and at the end of that function, a call to
Code: Select all
$paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment)


You could try adding a third parameter (for the selected registration options) to
Code: Select all
classes/payment/PaymentManager.inc.php::displayPaymentForm
as well as
Code: Select all
plugins/paymethod/paypal/PayPalPlugin.inc.php::displayPaymentForm


You could pass along the selected registration options and finally assign them to the display template in
Code: Select all
plugins/paymethod/paypal/PayPalPlugin.inc.php::displayPaymentForm
via a
Code: Select all
$templateMgr->assign('registrationOptions', $registrationOptions)


You can make the additional parameter to the above functions optional and unset by default, i.e.
Code: Select all
displayPaymentForm($queuedPaymentId, $queuedPayment, $registrationOptions = null)


This way it should hopefully not break anything, but your mileage may vary as these are just some initial thoughts.

Cheers,
Michael
michael
 
Posts: 405
Joined: Thu Mar 29, 2007 2:09 pm

Re: Display registration options on Paypal payment page?

Postby pagination » Thu Oct 28, 2010 5:04 am

Many thanks for your help, Michael.

I've tried this, and double-checked everything very carefully; but sadly the generated Paypal page includes only:

Code: Select all
<form>
<table class="data" width="100%">
   </table>
</form>


as before - it still doesn't seem to be looping through the {foreach...} or, if it is looping, it isn't finding anything.

Just to double-check that I understood you properly:

I amended
Code: Select all
$paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment)

or sometimes - see end of post - it was
Code: Select all
$paymentManager->displayPaymentForm($queuedPaymentId, &$queuedPayment)

to
Code: Select all
$paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment, $registrationOptions)


in the following files:
classes/registration/form/UserRegistrationForm.inc.php
classes/payment/PaymentManager.inc.php::displayPaymentForm
plugins/paymethod/paypal/PayPalPlugin.inc.php::displayPaymentForm

I amended
Code: Select all
function displayPaymentForm($queuedPaymentId, &$queuedPayment)

to
Code: Select all
function displayPaymentForm($queuedPaymentId, $queuedPayment, $registrationOptions)

in the file:
plugins/paymethod/paypal/PayPalPlugin.inc.php::displayPaymentForm

I added the line
Code: Select all
$templateMgr->assign('registrationOptions', $registrationOptions);
to the file
plugins/paymethod/paypal/PayPalPlugin.inc.php
at the very end of the function, after all the other $templateMgr lines.
(Brief panic when the whole system whited-out, because I had forgotten to add the semi-colon at the end of the line!)

I retained the code mentioned in my first post which I had added to
plugins/paymethod/paypal/templates/paymentForm.tpl

(I admit I was rather confused when some of the function calls included ampersands and others did not; but in the end I tried both versions - still without success.)

Is there anything else that I can try?
pagination
 
Posts: 6
Joined: Wed Apr 28, 2010 7:29 am

Re: Display registration options on Paypal payment page?

Postby tshore » Thu Oct 28, 2010 7:06 am

I've done this a few times. These kinds of changes make upgrading difficult, so I usually have to redo the changes each year. First, you might also want to see this related post for an idea of what else can be done:

http://pkp.sfu.ca/support/forum/viewtopic.php?f=13&t=5941

Back to what you are trying to do right now. I didn't really read through your post, but I found the function I think you need to change:

classes/payment/ocs/OCSQueuedPayment.inc.php:getDescription

And here's the function:
Code: Select all
   function getDescription() {
      switch ($this->type) {
         case QUEUED_PAYMENT_TYPE_REGISTRATION:
            $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
            $registration =& $registrationDao->getRegistration($this->getAssocId());

            $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO');
            $registrationType =& $registrationTypeDao->getRegistrationType(
               $registration?$registration->getTypeId():0
            );
            $registrationOptionCosts = $registrationTypeDao->getRegistrationOptionCosts($registration->getTypeId());

            $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
            $registrationOptions =& $registrationOptionDao->getRegistrationOptions($this->getAssocId());

            $options = '';
            foreach ($registrationOptions as $optionId) {
               $options .= ' + ' . $registrationOptionDao->getRegistrationOptionName($optionId) . ' ($' .  $registrationOptionCosts[$optionId] . ')';            
            }
            
            $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
            $schedConf =& $schedConfDao->getSchedConf(
               $registrationType?$registrationType->getSchedConfId():0
            );

            return Locale::translate('payment.type.conferenceRegistration', array(
               'schedConfTitle' => ($schedConf?$schedConf->getSchedConfAcronym():Locale::translate('common.none')),
               'registrationTypeName' => ($registrationType?$registrationType->getRegistrationTypeName():Locale::translate('common.none')) . ' ($' . $registrationType->getCost() . ')',
            )) . $options;
      }
   }

It just tacks the option info onto the description and you can run into problems with this being truncated (can't remember the max length). I have done it the right way in the past - by adding an item for each option to the "cart", but I just didn't have time last year.
tshore
 
Posts: 264
Joined: Fri Nov 18, 2005 12:48 pm
Location: Hamilton, Ontario

Re: Display registration options on Paypal payment page?

Postby pagination » Thu Oct 28, 2010 8:37 am

Hooray - this works!! Many thanks, Trudi!
pagination
 
Posts: 6
Joined: Wed Apr 28, 2010 7:29 am

Re: Display registration options on Paypal payment page?

Postby asmecher » Fri Oct 29, 2010 9:53 am

Hi Trudy,

That sounds useful; I've filed a Bugzilla entry at http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=6086 and will have a look at including this for the next release.

Thanks,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Re: Display registration options on Paypal payment page?

Postby tshore » Fri Oct 29, 2010 10:08 am

If/when you do get to implementing this. It would be much better to do is as a cart and have each option be a separate line on the PayPal page. I'll try to look and see what OCS version I last did this for and see if any of the code would still be useful.
tshore
 
Posts: 264
Joined: Fri Nov 18, 2005 12:48 pm
Location: Hamilton, Ontario

Re: Display registration options on Paypal payment page?

Postby pagination » Fri Oct 29, 2010 10:34 am

I've included a large notice on the payment form page warning the user to print the page for their records, as the information will get truncated by Paypal after 127 characters - but assuring them that it's safely stored in the database!
pagination
 
Posts: 6
Joined: Wed Apr 28, 2010 7:29 am


Return to OCS Technical Support

Who is online

Users browsing this forum: No registered users and 3 guests