I have added an additional field to the admin edit product page with this code in my custom plugin Code: // this method will be called in the product edit page function onProductForm(Am_Event $event){ $form = $event->getForm(); $form->addElement('text', 'ab_return_url', array('size' => 60, 'class'=>'translate')) ->setLabel(___("Paypal Return URL\n" . "This is the url the thanks page will redirect to after payment\n" . "You can use this for one time offers")); } and it adds it to the 'Additional' field set but the value is not saving. would you tell me what code I would need to use to add the field and it keeps its value when saved and also what code I can use to retrieve that value on the onThanksPage event?
[update] Ok I realized that it's not saving because there isn't a field available on the am_billing_plans table where everything else gets saved. I am instead going to use a custom brick so I can add the redirect url to the signup form for a product. the brick is added and it can be configured ok and the data gets saved. I am using this code Code: class Am_Form_Brick_redirectUrl extends Am_Form_Brick { protected $hideIfLoggedInPossible = self::HIDE_DONT; public function __construct($id = null, $config = null) { $this->name = ___('Thanks Redirect URL (Hidden)'); parent::__construct($id, $config); } public function initConfigForm(Am_Form $form) { $form->addText('redirect_url')->setLabel(___('Redirect URL')); } public function insertBrick(HTML_QuickForm2_Container $form) { $form->addHidden('redirect_url')->setValue($this->getConfig('redirect_url')); } } Will this data be available in the onThanksPage event? ie. Can the signup form that was used for the purchase be retrieved so I can setRedirect to use the URL that was saved to the custom brick? eg; Code: // this method will be called before rendering "thanks" page function onThanksPage(Am_Event $event) { $controller = $event->getController(); // ThanksController instance $invoice = $event->getInvoice(); // Invoice instance OR NULL (!) if (!$invoice) return; // get signup form here // get value saved in redirect_url $savedredirecturl = (how to get it?) $controller->getResponse()->setRedirect($savedredirecturl); }
No it will not be available. Here is what you need to do: 1. Set handlers for both Am_Event::SIGNUP_USER_UPDATED and Am_Event::SIGNUP_USER_ADDED events. Both will receive three parameters: $vars, $user, $form 2. get redirect url from form and store it in session. 3. on tahnks page extract it from session and use as you need.
ah of course I can use the $_SESSION global to store that because both the form and the payment would always be in the same session. I was over thinking it. thanks Alexander
sorry Alexander but I'm having trouble with getting the parameters . I keep getting a 'cannot access protected property' with this code in my custom amember plugin Code: function onSignupUserUpdated (Am_Event $event){ $vars = $event->vars; } can you give me the code to access the $vars ?
sorry Alexander, I found it. Code: $vars = $event->getvars(); I'm just getting used to the new classes but I'm getting there!