MembershipPro - Payment plugin to add one more field to Subscription Plan

  • VietHoang
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #135940 by VietHoang
Hi admin,

I'm a newbie for Joomla + MembershipPro. I want to develop a payment plugin for Membership Pro using Stripe Connect payment gateway (which you are still does not support now).

I created a Membership Pro Payment Plugin follow the document at: membershipprodoc.joomservices.com/develo...n/dev-payment-plugin

However, I want to add 1 more field in the Subscription Plan setting page. So, I created another Membership Pro normal plugin follow the document at: membershipprodoc.joomservices.com/develo...mentation/dev-plugin

But, I don't know how to do them in just 1 plugin.

Could you please give some help in this case? some suggestions or documents, anything can help.

Many thanks,

Please Log in or Create an account to join the conversation.

  • Richard
  • Offline
  • Junior Member
  • Junior Member
  • I am a freelance web developer
More
3 years 8 months ago #135942 by Richard
Hi Tuan,

I'd be interested in this too. I will be glad if I can be able to create a custom field in the plan edit page.

Something like the Paypal Email field that I can easily retrieve in the payment plugin using the sample code below.

$rowPlan = OSMembershipHelperDatabase::getPlan($row->plan_id);

$rowPlan->my_custom_field;

Please, I need this info too in order to add recurring payment ability to one of my existing payment plugin.

Regards,
Richard

--

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #135955 by Tuan Pham Ngoc
Hi both

Unfortunately, there is no way to handle it using a single plugin. Maybe the simplest way would be adding file default_custom_settings.php to folder administrator/components/com_osmembership/view/plan/tmpl and add the fields you want there

Otherwise, you will need to add a second plugin to add the fields you want to plan setup

Tuan

Please Log in or Create an account to join the conversation.

  • Richard
  • Offline
  • Junior Member
  • Junior Member
  • I am a freelance web developer
More
3 years 8 months ago #135971 by Richard
@Tuan,

As usual, thanks for your response.

However, I would like to ask, would the system automatically pick up the extra field(s) provided in the default_custom_settings.php file?

Secondly, would I still be able to fetch the field content using the method described in my previous comment in my payment plugin?

Regards,
Rich

Please Log in or Create an account to join the conversation.

  • Richard
  • Offline
  • Junior Member
  • Junior Member
  • I am a freelance web developer
More
3 years 8 months ago #136050 by Richard
Hi Tuan,

It seems I have hijacked this topic. I'm sorry about that, but in anyway, we're all learning.

Back to the topic, I have followed your instruction to create a default_custom_settings.php file in administrator/components/com_osmembership/view/plan/tmpl, but the problem I'm having is that the custom fields do appear on the plan edit page but they don't save when I save the plan.

The changes I make to the custom settings before saving will always get lost.

When I do var_dump($this->item) in the frontend plan template, I don't see my custom settings anywhere in the output.

Attached is the code I have in the default_custom_settings.php file.

I don't know what I'm doing wrong, but I can't seem to get the custom settings working.

Your help will be highly appreciated.

Regards,
Rich
---
Attachments:

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #136077 by Tuan Pham Ngoc
Hi Richard

You need to add the fields you want to store data for these fields into #__osmemembership_plans table (name of the fields must be the same with name of the input) and the entered data should be stored automatically

Regards,

Tuan

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #136079 by Tuan Pham Ngoc
BTW, please remove the link/advertisement you added to your signature. We do not allow advertisement / back links on our website

Hope you understand

Tuan

Please Log in or Create an account to join the conversation.

  • VietHoang
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #136165 by VietHoang
Hi Tuan,

How can I add a field to the database table with a Membership Pro Payment plugin?

Thanks,

Viet

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #136167 by Tuan Pham Ngoc
Hi Viet

Exactly what fields you want to add? If it's not complicated, I would suggest you to store data of these fields params field in #__osmembership_plans table. That field store some extra data (could be added by plugins) in json format. You can have a look at plugins/osmembership/joomlagroups/joomlagroups.php, method onAfterSaveSubscriptionPlan to see how we use that fields to get and store data for Joomla groups plugin

Tuan

Please Log in or Create an account to join the conversation.

  • Richard
  • Offline
  • Junior Member
  • Junior Member
  • I am a freelance web developer
More
3 years 8 months ago - 3 years 8 months ago #136286 by Richard
Hi Tuan,

Thanks for your response.

I just want to save and retrieve the extra fields I specified in the default_custom_settings.php file in administrator/components/com_osmembership/view/plan/tmpl.

Please, can you guide me, step by step, on how to achieve the above. Do I need to write a new plugin for that.

Edited
Sorry, I have been able to get it working after I created the needed custom fields in the #__osmembership_plans database table

However, will an update affect this, I mean the extra database columns?

Regards,
Richard
Last edit: 3 years 8 months ago by Richard.

Please Log in or Create an account to join the conversation.