Skip to content

Commit

Permalink
Fixes issue adding subscription plan #369
Browse files Browse the repository at this point in the history
  • Loading branch information
andrelopez committed Oct 30, 2023
1 parent bcb65b5 commit 9f05929
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace enupal\stripe\migrations;

use craft\db\Migration;
use craft\db\Query;
use Craft;

/**
* m231030_000000_update_enupalmultipleplans_selectplan migration.
*/
class m231030_000000_update_enupalmultipleplans_selectplan extends Migration
{
/**
* @return bool
* @throws \yii\base\Exception
*/
public function safeUp()
{
$matrixTable = '{{%matrixcontent_enupalmultipleplans}}';

$field = (new Query())
->select(['*'])
->from('{{%fields}}')
->where(["name" => 'Select Plan', 'handle' => 'selectPlan', 'type' => 'craft\fields\Dropdown'])
->andWhere(['like', 'context', 'matrixBlockType:%', false])
->one();

if (empty($field)) {
Craft::error('Unable to find Stripe Payment field selectPlan', __METHOD__);
return null;
}

$column = 'field_subscriptionPlan_selectPlan_'.$field['columnSuffix'];

if ($this->db->columnExists($matrixTable, $column)) {
$this->alterColumn($matrixTable, $column, $this->string(255));
} else {
Craft::error('Unable to find Stripe Payment select plan column: '.$column, __METHOD__);
}

return true;
}

/**
* @inheritdoc
*/
public function safeDown()
{
echo "m230208_000000_add_adjustable_quantity cannot be reverted.\n";

return false;
}
}
2 changes: 1 addition & 1 deletion src/services/PaymentForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ private function createMultiplePlansMatrixField()
'handle' => 'selectPlan',
'instructions' => "Can't see your plans? Go to [Subscriptions]($subscriptionUrl) and click on Refresh Plans",
'required' => 1,
'typesettings' => '{"options":[{"label":"Select Plan...","value":"","default":""}]}',
'typesettings' => '{"columnType":"string", "options":[{"label":"Select Plan...","value":"","default":""}]}',
'translationMethod' => Field::TRANSLATION_METHOD_SITE,
],
'new2' => [
Expand Down

0 comments on commit 9f05929

Please sign in to comment.