Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Kudos-Donations
Commits
a14a6b04
Commit
a14a6b04
authored
Feb 05, 2021
by
Michael Iseard
Browse files
Add business name to address fields and donor entity
parent
ef637086
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/Admin/Table/DonorsTable.php
View file @
a14a6b04
...
...
@@ -270,6 +270,7 @@ class DonorsTable extends WP_List_Table {
protected
function
column_address
(
array
$item
):
string
{
$address
=
[
$item
[
'business_name'
],
$item
[
'street'
],
$item
[
'postcode'
]
.
' '
.
$item
[
'city'
],
$item
[
'country'
],
...
...
app/Entity/DonorEntity.php
View file @
a14a6b04
...
...
@@ -31,6 +31,12 @@ class DonorEntity extends AbstractEntity {
* @var string
*/
public
$name
;
/**
* Business name
*
* @var string
*/
public
$business_name
;
/**
* Address: Street name
*
...
...
app/Service/ActivatorService.php
View file @
a14a6b04
...
...
@@ -2,11 +2,9 @@
namespace
Kudos\Service
;
use
Kudos\Entity\CampaignEntity
;
use
Kudos\Entity\DonorEntity
;
use
Kudos\Entity\SubscriptionEntity
;
use
Kudos\Entity\TransactionEntity
;
use
Kudos\Helpers\Campaigns
;
use
Kudos\Helpers\Settings
;
/**
...
...
@@ -40,7 +38,7 @@ class ActivatorService {
$twig
->
init
();
if
(
$old_version
)
{
self
::
run_migrations
(
$old_version
);
self
::
run_migrations
(
$old_version
);
}
self
::
create_donors_table
();
...
...
@@ -85,7 +83,7 @@ class ActivatorService {
// Apply mode to Donors
$donor_table
=
DonorEntity
::
get_table_name
();
$wpdb
->
query
(
"ALTER TABLE
$donor_table
ADD `mode` VARCHAR(45) NOT NULL"
);
$wpdb
->
query
(
"ALTER TABLE
$donor_table
ADD `mode` VARCHAR(45) NOT NULL"
);
$mapper
=
new
MapperService
(
DonorEntity
::
class
);
$donors
=
$mapper
->
get_all_by
();
/** @var DonorEntity $donor */
...
...
@@ -101,10 +99,10 @@ class ActivatorService {
if
(
version_compare
(
$old_version
,
'2.3.2'
,
'<'
)
)
{
// Setting now replaced by 'theme_colors'
$old_color
=
Settings
::
get_setting
(
'theme_color'
);
$new_colors
=
Settings
::
get_setting
(
'theme_colors'
);
$old_color
=
Settings
::
get_setting
(
'theme_color'
);
$new_colors
=
Settings
::
get_setting
(
'theme_colors'
);
$new_colors
[
'primary'
]
=
$old_color
;
Settings
::
update_setting
(
'theme_colors'
,
$new_colors
);
Settings
::
update_setting
(
'theme_colors'
,
$new_colors
);
Settings
::
remove_setting
(
'theme_color'
);
}
...
...
@@ -129,6 +127,7 @@ class ActivatorService {
last_updated datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
email VARCHAR(320) NOT NULL,
name VARCHAR(255) NOT NULL,
business_name VARCHAR(255) NOT NULL,
street VARCHAR(255),
postcode VARCHAR(255),
city VARCHAR(255),
...
...
@@ -227,35 +226,4 @@ class ActivatorService {
$settings
->
add_defaults
();
}
/**
* Creates the subscription table
*
* @since 1.1.0
*/
private
static
function
create_campaigns_table
()
{
global
$wpdb
;
$charset_collate
=
$wpdb
->
get_charset_collate
();
$table_name
=
CampaignEntity
::
get_table_name
();
$sql
=
"CREATE TABLE
$table_name
(
id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
slug VARCHAR(255),
name VARCHAR(255),
modal_title VARCHAR(255),
welcome_text VARCHAR(255),
donation_type VARCHAR(255),
amount_type VARCHAR(255),
fixed_amounts VARCHAR(255),
protected BIT,
secret VARCHAR(255),
PRIMARY KEY (id)
)
$charset_collate
"
;
require_once
ABSPATH
.
'wp-admin/includes/upgrade.php'
;
dbDelta
(
$sql
);
}
}
app/Service/PaymentService.php
View file @
a14a6b04
...
...
@@ -157,6 +157,7 @@ class PaymentService extends AbstractService {
$payment_frequency
=
isset
(
$request
[
'recurring_frequency'
]
)
?
sanitize_text_field
(
$request
[
'recurring_frequency'
]
)
:
'oneoff'
;
$recurring_length
=
isset
(
$request
[
'recurring_length'
]
)
?
intval
(
$request
[
'recurring_length'
]
)
:
0
;
$name
=
isset
(
$request
[
'name'
]
)
?
sanitize_text_field
(
$request
[
'name'
]
)
:
null
;
$business_name
=
isset
(
$request
[
'business_name'
]
)
?
sanitize_text_field
(
$request
[
'business_name'
]
)
:
null
;
$email
=
isset
(
$request
[
'email_address'
]
)
?
sanitize_email
(
$request
[
'email_address'
]
)
:
null
;
$street
=
isset
(
$request
[
'street'
]
)
?
sanitize_text_field
(
$request
[
'street'
]
)
:
null
;
$postcode
=
isset
(
$request
[
'postcode'
]
)
?
sanitize_text_field
(
$request
[
'postcode'
]
)
:
null
;
...
...
@@ -186,13 +187,14 @@ class PaymentService extends AbstractService {
// Update new/existing donor.
$donor
->
set_fields
(
[
'email'
=>
$email
,
'name'
=>
$name
,
'mode'
=>
$this
->
vendor
->
get_api_mode
(),
'street'
=>
$street
,
'postcode'
=>
$postcode
,
'city'
=>
$city
,
'country'
=>
$country
,
'email'
=>
$email
,
'name'
=>
$name
,
'business_name'
=>
$business_name
,
'mode'
=>
$this
->
vendor
->
get_api_mode
(),
'street'
=>
$street
,
'postcode'
=>
$postcode
,
'city'
=>
$city
,
'country'
=>
$country
,
]
);
...
...
@@ -243,7 +245,7 @@ class PaymentService extends AbstractService {
$result
=
$this
->
vendor
->
cancel_subscription
(
$subscription_id
);
if
(
$result
)
{
if
(
$result
)
{
// Update entity with canceled status
$subscription
->
set_fields
(
...
...
@@ -334,7 +336,7 @@ class PaymentService extends AbstractService {
}
$payment
=
$this
->
vendor
->
create_payment
(
$payment_array
);
if
(
null
===
$payment
)
{
if
(
null
===
$payment
)
{
return
false
;
}
...
...
templates/public/modal/donate.modal.html.twig
View file @
a14a6b04
...
...
@@ -90,6 +90,7 @@
{%
set
required
=
(
campaign.address_required
?
'required'
:
null
)
%}
{{
text
(
'business_name'
,
__
(
'Business name'
,
'kudos-donations'
),
'text'
,
false
)
}}
{{
text
(
'street'
,
__
(
'Street'
,
'kudos-donations'
),
'text'
,
required
)
}}
{{
text
(
'postcode'
,
__
(
'Postcode'
,
'kudos-donations'
),
'text'
,
required
)
}}
{{
text
(
'city'
,
__
(
'City'
,
'kudos-donations'
),
'text'
,
required
)
}}
...
...
@@ -109,7 +110,8 @@
<div
class=
"kudos_summary kd-text-left kd-block kd-bg-gray-200 kd-p-2 kd-border-0 kd-border-solid kd-border-t-2 kd-border-theme"
>
<p
class=
"kd-block kd-mb-0"
><strong>
{{
__
(
'Name'
,
'kudos-donations'
)
}}
:
</strong><span
class=
"summary_name"
></span></p>
<p
class=
"kd-block kd-mb-0"
><strong>
{{
__
(
'E-mail address'
,
'kudos-donations'
)
}}
:
</strong><span
<p
class=
"kd-block kd-mb-0"
><strong>
{{
__
(
'E-mail address'
,
'kudos-donations'
)
}}
:
</strong><span
class=
"summary_email"
></span></p>
<p
class=
"kd-block kd-mb-0"
><strong>
{{
__
(
'Amount'
,
'kudos-donations'
)
}}
:
</strong>
€
<span
class=
"summary_value"
></span></p>
...
...
@@ -118,10 +120,10 @@
</div>
{%
if
(
terms_link
)
%}
{{
checkbox
(
'avg'
,
__
(
'I agree with the %s'
,
'kudos-donations'
)
|
format
(
'<a class="kd-text-theme hover:kd-text-primary-dark kd-shadow-none kd-underline kd-cursor-pointer kd-ml-1" target="_blank" href=%s>%s</a>.'
|
format
(
terms_link
,
__
(
'terms and conditions'
,
'kudos-donations'
)
)
))
}}
{{
checkbox
(
'avg'
,
__
(
'I agree with the %s'
,
'kudos-donations'
)
|
format
(
'<a class="kd-text-theme hover:kd-text-primary-dark kd-shadow-none kd-underline kd-cursor-pointer kd-ml-1" target="_blank" href=%s>%s</a>.'
|
format
(
terms_link
,
__
(
'terms and conditions'
,
'kudos-donations'
)
)
))
}}
{%
endif
%}
{%
endblock
%}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment