By Jason McMahon on Sunday, 24 July 2022
Posted in General Issues
Likes 0
Views 397
Votes 0
The Joomla registration integration is not good, registration using payplans using the default Joomla system has actually gone backwards since version 3. It flows horribly, and is extra steps for a user that should not be necessary. Having to create / activate an account and THEN pay a sub is a chance of losing a new customer... especially on a site that does not have a 'free' registration - its paid for only

I do like how the DEFAULT PayPlans registration integration looks, its very pro, custom fields has limitationms but will do the job and want to use it. However not being able to map core and custom fields onto actual existing Joomla4 user fields is a big gap (other than name and email of course).

What code piece of PHP in Stack Ideas does the user creation so I can modifiy a little and map custom fields AND core fields from Stack Ideas onto actual Joomla fields so that other components can use this info - Company Name , VAT, Address for example and one I have created called 'Requires Purchase Order' - which we need for other systems.

Just an aside, the other systems I use have custom fields.. and you can map them to Joomla fields.. *nudge nudge*

Unless you have another way to suggest that does not involve me buying a 3rd party componnent I dont really need? Joomla has nice custom fields out the box now and we should be able to use them simply like previous versions of payplans.
Hey Jason,

What code piece of PHP in Stack Ideas does the user creation so I can modifiy a little and map custom fields AND core fields from Stack Ideas onto actual Joomla fields so that other components can use this info - Company Name , VAT, Address for example and one I have created called 'Requires Purchase Order' - which we need for other systems.

You can change the code to save these details to Joomla fields. You will be able to find the related code in the below-mentioned file path.
root\components\com_payplans\controllers\checkout.php

Regarding Vat no, it seems you are using billing details, to save billing details to Joomla fields find the below-mentioned code and change it accordingly.

if (!$preferences) {
// if preference is empty, lets get from database.
$business = $user->getBusinessData();
$business = [
'business_name' => $business->name,
'tin' => $business->vat,
'business_address' => $business->address,
'business_city' => $business->city,
'business_state' => $business->state,
'business_zip' => $business->zip,
'business_country' => $business->country
];

foreach ($business as $key => $value) {
if ($value) {
$userPreferences->set($key, $value);
}
}

if ($business['business_country']) {
$user->setCountry($business['business_country']);
}
}

$user->setPreferences($userPreferences);

if (!isset($preferences['business_name']) && !isset($preferences['tin'])) {

$euVatApps = PPHelperApp::getAvailableApps('euvat');
if ($euVatApps) {

$userPref = new JRegistry($user->table->preference);
$userCountry = $user->getCountry();

if (!$userCountry) {
$this->info->set('COM_PP_APP_EUVAT_PLEASE_SELECT_COUNTRY', 'error');
}

// There is a possible that user has his/her preference stored already before 'Show Billing Details' settings being disabled
if (!$userCountry) {
return $this->redirectToView('checkout', '', 'invoice_key=' . $invoiceKey . $excludeTemplate);
}
}
}


To save billing details to Joomla fields find the below-mentioned code and change it accordingly.

// We need to save user params here
$params = $this->input->get('userparams', [], 'array');

$files = $this->input->files->get('userparams');

if (!empty($files) && $user->getUserName() != 'Not_Registered') {
PP::saveCustomDetailFiles($files, PP_CUSTOM_DETAILS_TYPE_USER, $user->getId());
}

if ($params && $user->getUserName() != 'Not_Registered') {
$userParams = $user->getParams();

foreach ($params as $key => $value) {
$userParams->set($key, $value);
}

$user->params = $userParams->toString();
$user->save();
}


Update us if you will have any queries.
·
Monday, 25 July 2022 12:25
·
0 Likes
·
0 Votes
·
0 Comments
·
Fantastic detail - look foeward to working through that. Accepting as answer as I only needed guidance and you went beyond
·
Monday, 25 July 2022 20:40
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jason,

You are most welcome. Glad to hear that your issue has been resolved now.

Just for your information, I have locked and marked this thread as resolved to avoid confusion in the future. Please start a new thread if you have any other issues in the future so it will be easier for us to manage your inquiries.

Thanks for understanding.
·
Tuesday, 26 July 2022 10:35
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post