Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add Constant Contact add-on to the form migration process #7145

Merged
merged 16 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DonationForms/V2/DonationFormsAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ public function getSupportedAddons(): array
'Zapier' => defined('GIVE_ZAPIER_VERSION'),
'Salesforce' => defined('GIVE_SALESFORCE_VERSION'),
'Donation Upsells for WooCommerce' => class_exists('Give_WooCommerce'),
'Constant Contact' => class_exists('Give_Constant_Contact'),
'MailChimp' => class_exists('Give_MailChimp'),
// 'Manual Donations' => class_exists('Give_Manual_Donations'),
'Funds' => defined('GIVE_FUNDS_ADDON_NAME'),
Expand All @@ -348,7 +349,6 @@ public function getSupportedAddons(): array
// 'Per Form Confirmations' => class_exists('Per_Form_Confirmations_4_GIVEWP'),
// 'Form Countdown' => class_exists('Give_Form_Countdown'),
// 'ActiveCampaign' => class_exists('Give_ActiveCampaign'),
// 'Constant Contact' => class_exists('Give_Constant_Contact'),
];

$output = [];
Expand Down
46 changes: 46 additions & 0 deletions src/FormMigration/FormMetaDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,20 @@ public function getFeeRecoverySettings(): array
/**
* @since 3.3.0
*/
public function isConstantContactEnabled(): bool
{
$isFormEnabled = give_is_setting_enabled($this->getMeta('_give_constant_contact_enable'),'true');

$isFormDisabled = give_is_setting_enabled($this->getMeta('_give_constant_contact_disable'),'true');

$isGloballyEnabled = give_is_setting_enabled(give_get_option('give_constant_contact_show_checkout_signup'), 'on');

return !($isFormDisabled || ( !$isGloballyEnabled && !$isFormEnabled));
}

/**
* @unreleased
*/
public function isMailchimpEnabled(): bool
{
$isFormEnabled = give_is_setting_enabled($this->getMeta('_give_mailchimp_enable'),'true');
Expand All @@ -525,6 +539,16 @@ public function isMailchimpEnabled(): bool
/**
* @since 3.3.0
*/
public function getConstantContactLabel(): string
{
$defaultMeta = give_get_option('give_constant_contact_label', __('Subscribe to our newsletter?'));

return $this->getMeta('_give_constant_contact_custom_label', $defaultMeta);
}

/**
* @unreleased
*/
public function getMailchimpLabel()
{
$value = $this->getMeta('_give_mailchimp_custom_label');
Expand All @@ -542,6 +566,20 @@ public function getMailchimpDefaultChecked(): bool
/**
* @since 3.3.0
*/
public function getConstantContactDefaultChecked(): bool
{
$defaultMeta = give_is_setting_enabled(
give_get_option('give_constant_contact_checked_default',
true),
'on'
);

return $this->getMeta('_give_constant_contact_checked_default', $defaultMeta);
}

/**
* @unreleased
*/
public function getMailchimpDoubleOptIn(): bool
{
return $this->getMeta('_give_mailchimp_double_opt_in');
Expand All @@ -558,6 +596,14 @@ public function getMailchimpSendDonationData(): bool
/**
* @since 3.3.0
*/
public function getConstantContactSelectedLists(): array
{
return $this->getMeta('_give_constant_contact');
}

/**
* @unreleased
*/
public function getMailchimpSendFFMData(): bool
{
return $this->getMeta('_give_mailchimp_send_ffm');
Expand Down
1 change: 1 addition & 0 deletions src/FormMigration/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function register()
Steps\FormMeta::class,
Steps\PdfSettings::class,
Steps\FeeRecovery::class,
Steps\ConstantContact::class,
Steps\PerFormGateways::class,
Steps\Mailchimp::class,
Steps\FundsAndDesignations::class,
Expand Down
37 changes: 37 additions & 0 deletions src/FormMigration/Steps/ConstantContact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Give\FormMigration\Steps;

use Give\FormMigration\Contracts\FormMigrationStep;
use Give\Framework\Blocks\BlockModel;

/**
* @unreleased
*/
class ConstantContact extends FormMigrationStep
{
/**
* @unreleased
*/
public function canHandle(): bool
jonwaldstein marked this conversation as resolved.
Show resolved Hide resolved
{
return $this->formV2->isConstantContactEnabled();
}

/**
* @unreleased
*/
public function process(): void
{
$block = BlockModel::make([
'name' => 'givewp/constantcontact',
'attributes' =>[
'label' => $this->formV2->getConstantContactLabel(),
'checked' => $this->formV2->getConstantContactDefaultChecked(),
'selectedEmailLists' => $this->formV2->getConstantContactSelectedLists(),
],
]);

$this->fieldBlocks->insertAfter('givewp/email', $block);
}
}
Loading