@@ -117,7 +117,7 @@ class BuyCoursesPlugin extends Plugin
117117 public function __construct ()
118118 {
119119 parent ::__construct (
120- '7.1 ' ,
120+ '7.5 ' ,
121121 '
122122 Jose Angel Ruiz - NoSoloRed (original author) <br/>
123123 Francis Gonzales and Yannick Warnier - BeezNest (integration) <br/>
@@ -363,6 +363,16 @@ public function update(): void
363363 if (!$ res ) {
364364 echo Display::return_message ($ this ->get_lang ('ErrorUpdateFieldDB ' ), 'warning ' );
365365 }
366+ } else {
367+ // An empty tax rate must be stored as NULL so the service falls back to the
368+ // global tax rate. Older installations created this column as NOT NULL.
369+ $ column = Database::fetch_assoc ($ res );
370+ if (isset ($ column ['Null ' ]) && 'NO ' === $ column ['Null ' ]) {
371+ $ res = Database::query ("ALTER TABLE $ table MODIFY tax_perc int unsigned NULL " );
372+ if (!$ res ) {
373+ echo Display::return_message ($ this ->get_lang ('ErrorUpdateFieldDB ' ), 'warning ' );
374+ }
375+ }
366376 }
367377
368378 $ table = Database::get_main_table (self ::TABLE_SALE );
@@ -576,6 +586,17 @@ public function update(): void
576586 ) " ;
577587 Database::query ($ sql );
578588
589+ // An empty tax rate must be stored as NULL so the subscription falls back to the
590+ // global tax rate. Older installations created this column as NOT NULL.
591+ $ res = Database::query ("SHOW COLUMNS FROM $ table WHERE Field = 'tax_perc' " );
592+ $ column = Database::fetch_assoc ($ res );
593+ if (isset ($ column ['Null ' ]) && 'NO ' === $ column ['Null ' ]) {
594+ $ res = Database::query ("ALTER TABLE $ table MODIFY tax_perc int unsigned NULL " );
595+ if (!$ res ) {
596+ echo Display::return_message ($ this ->get_lang ('ErrorUpdateFieldDB ' ), 'warning ' );
597+ }
598+ }
599+
579600 $ table = Database::get_main_table (self ::TABLE_SUBSCRIPTION_SALE );
580601 $ sql = "CREATE TABLE IF NOT EXISTS $ table (
581602 id int unsigned NOT NULL AUTO_INCREMENT,
0 commit comments