Use new code style
This commit is contained in:
@ -107,7 +107,5 @@ class Payment_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Payment_Query;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Payments;
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Database\Engine\Enum;
|
||||
use WP_Ultimo\Database\Engine\Enum;
|
||||
|
||||
/**
|
||||
* Payment Status.
|
||||
@ -51,8 +51,7 @@ class Payment_Status extends Enum {
|
||||
static::FAILED => 'wu-bg-red-200 wu-text-red-700',
|
||||
static::CANCELLED => 'wu-bg-orange-200 wu-text-orange-700',
|
||||
);
|
||||
|
||||
} // end classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => CSS Classes.
|
||||
@ -71,8 +70,7 @@ class Payment_Status extends Enum {
|
||||
static::FAILED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-red-700',
|
||||
static::CANCELLED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-orange-700',
|
||||
);
|
||||
|
||||
} // end icon_classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
@ -91,7 +89,5 @@ class Payment_Status extends Enum {
|
||||
static::FAILED => __('Failed', 'wp-ultimo'),
|
||||
static::CANCELLED => __('Cancelled', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end labels;
|
||||
|
||||
} // end class Payment_Status;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Payments_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'paymentmeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Payments_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Payments_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_payment_id (wu_payment_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Payments_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class Payments_Schema extends Schema {
|
||||
'type' => 'varchar',
|
||||
'length' => '20',
|
||||
'default' => 'USD',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -188,5 +188,4 @@ class Payments_Schema extends Schema {
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Payments_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Payments_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'payments';
|
||||
|
||||
/**
|
||||
@ -66,8 +66,7 @@ final class Payments_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema.
|
||||
@ -102,8 +101,7 @@ final class Payments_Table extends Table {
|
||||
KEY parent_id (parent_id),
|
||||
KEY product_id (product_id),
|
||||
KEY status (status)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the refund_total column.
|
||||
@ -120,17 +118,14 @@ final class Payments_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `refund_total` decimal(13,4) default 0 AFTER `subtotal`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210417;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the refund_total column.
|
||||
@ -144,27 +139,22 @@ final class Payments_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
|
||||
|
||||
$result_set = $this->get_db()->query($query_set);
|
||||
|
||||
if ($this->is_success($result_set) === false) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `refund_total` decimal(13,4) default 0 AFTER `subtotal`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210607;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -178,21 +168,15 @@ final class Payments_Table extends Table {
|
||||
);
|
||||
|
||||
foreach ($null_columns as $column) {
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
if (!$this->is_success($result)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Payments_Table;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user