diff --git a/CHANGELOG.md b/CHANGELOG.md index 4900065..e8e29a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +## v2.1.0 - 2025-08-05 + +### [2.1.0](https://github.com/openedx/openedx-wordpress-ecommerce/compare/v2.0.7...v2.1.0) (2025-08-05) + +#### Features + +* feat: add publish to wordpress svn action (#103) +* feat: Save enrollment action preferences (#111) + +#### Bug Fixes + +* fix: add parent property to avoid dynamic property warning (#109) +* fix: updating i18n management (2025 best practices) (#114) + +### Documentation + +* docs: add automatic installation info and change github docs links to rtd docs (#108) + +### Maintenance + +* chore: actions auto updates. +* chore: Tag this repo as part of named releases (#110) + ## v2.0.7 - 2024-11-05 ### [2.0.7](https://github.com/openedx/openedx-wordpress-ecommerce/compare/v2.0.6...v2.0.7) (2024-11-05) diff --git a/README.txt b/README.txt index 8172823..2b9eabf 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Tags: openedx, open edx, ecommerce, lms, courses Requires at least: 6.3 Tested up to: 6.8 Requires PHP: 8.0 -Stable tag: 2.0.7 +Stable tag: 2.1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/admin/class-openedx-commerce-admin.php b/admin/class-openedx-commerce-admin.php index 80dc75b..5af280f 100644 --- a/admin/class-openedx-commerce-admin.php +++ b/admin/class-openedx-commerce-admin.php @@ -498,11 +498,23 @@ public function select_course_items( $items, $is_refunded = false ) { */ public function items_enrollment_request( $courses, $order_id, $billing_email, $request_type ) { + $force_enrollment = get_option( 'openedx-enrollment-force', false ); + $allow_non_existing = get_option( 'openedx-enrollment-allowed', false ); + + if ( $force_enrollment && $allow_non_existing ) { + $action = 'openedx_enrollment_allowed_force'; + } elseif ( $force_enrollment ) { + $action = 'openedx_enrollment_force'; + } elseif ( $allow_non_existing ) { + $action = 'openedx_enrollment_allowed'; + } else { + $action = 'enrollment_process'; + } + foreach ( $courses as $item_id => $item ) { $course_id = get_post_meta( $item['course_item']->get_product_id(), '_course_id', true ); $course_mode = get_post_meta( $item['course_item']->get_product_id(), '_mode', true ); - $action = 'enrollment_process'; $enrollment_arr = array( 'openedx_enrollment_course_id' => $course_id, diff --git a/admin/views/class-openedx-commerce-settings.php b/admin/views/class-openedx-commerce-settings.php index b9d8713..64aeba6 100644 --- a/admin/views/class-openedx-commerce-settings.php +++ b/admin/views/class-openedx-commerce-settings.php @@ -125,6 +125,22 @@ public function openedx_settings_init() { 'openedx-settings-section' ); + add_settings_field( + 'openedx-enrollment-force', + __( 'Force Enrollment', 'openedx-commerce' ), + array( $this, 'openedx_enrollment_force_callback' ), + 'openedx-settings', + 'openedx-settings-section' + ); + + add_settings_field( + 'openedx-enrollment-allowed', + __( 'Allow Non-Existing Users', 'openedx-commerce' ), + array( $this, 'openedx_enrollment_allowed_callback' ), + 'openedx-settings', + 'openedx-settings-section' + ); + register_setting( 'openedx-settings-group', 'openedx-domain', @@ -149,6 +165,26 @@ public function openedx_settings_init() { 'sanitize_text_field' ); + register_setting( + 'openedx-settings-group', + 'openedx-enrollment-force', + array( + 'type' => 'boolean', + 'sanitize_callback' => 'rest_sanitize_boolean', + 'default' => false, + ) + ); + + register_setting( + 'openedx-settings-group', + 'openedx-enrollment-allowed', + array( + 'type' => 'boolean', + 'sanitize_callback' => 'rest_sanitize_boolean', + 'default' => false, + ) + ); + if ( ! isset( $_POST['openedx_commerce_new_token_nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['openedx_commerce_new_token_nonce'] ) ), 'openedx_commerce_token' ) ) { @@ -324,5 +360,35 @@ public function openedx_settings_section_callback() { 'Configuring the necessary parameters here to establish the connection between this plugin and your Open edX platform. For more information, you can visit the how-to Create an Open edX Application for the Plugin Settings in the documentation.' ); } + + /** + * Output the enrollment force settings field. + * + * Retrieves the saved enrollment force value and outputs a checkbox input field and description text. + * + * @return void + */ + public function openedx_enrollment_force_callback() { + $force_enrollment = get_option( 'openedx-enrollment-force', false ); + ?> + > + + + > + +