Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
14 changes: 13 additions & 1 deletion admin/class-openedx-commerce-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,23 @@
*/
public function items_enrollment_request( $courses, $order_id, $billing_email, $request_type ) {

$force_enrollment = get_option( 'openedx-enrollment-force', false );

Check warning on line 501 in admin/class-openedx-commerce-admin.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 2 spaces
$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,
Expand Down
76 changes: 76 additions & 0 deletions admin/views/class-openedx-commerce-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@
'openedx-settings-section'
);

add_settings_field(
'openedx-enrollment-force',
'Force Enrollment',
array( $this, 'openedx_enrollment_force_callback' ),
'openedx-settings',
'openedx-settings-section'
);

Check failure on line 135 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Whitespace found at end of line
add_settings_field(
'openedx-enrollment-allowed',
'Allow Non-Existing Users',
array( $this, 'openedx_enrollment_allowed_callback' ),
'openedx-settings',
'openedx-settings-section'
);

register_setting(
'openedx-settings-group',
'openedx-domain',
Expand All @@ -149,6 +165,36 @@
'sanitize_text_field'
);

register_setting(
'openedx-settings-group',
'openedx-enrollment-force',
array(
'type' => 'boolean',

Check warning on line 172 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Array double arrow not aligned correctly; expected 14 space(s) between "'type'" and double arrow, but found 1.
'sanitize_callback' => 'rest_sanitize_boolean',
'default' => false,

Check warning on line 174 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Array double arrow not aligned correctly; expected 11 space(s) between "'default'" and double arrow, but found 1.
)
);

register_setting(
'openedx-settings-group',
'openedx-enrollment-allowed',
array(
'type' => 'boolean',

Check warning on line 182 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Array double arrow not aligned correctly; expected 14 space(s) between "'type'" and double arrow, but found 1.
'sanitize_callback' => 'rest_sanitize_boolean',
'default' => false,

Check warning on line 184 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Array double arrow not aligned correctly; expected 11 space(s) between "'default'" and double arrow, but found 1.
)
);

Check failure on line 187 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Whitespace found at end of line
register_setting(
'openedx-settings-group',
'openedx-enrollment-allowed',
array(
'type' => 'boolean',

Check warning on line 192 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Array double arrow not aligned correctly; expected 14 space(s) between "'type'" and double arrow, but found 1.
'sanitize_callback' => 'rest_sanitize_boolean',
'default' => false,

Check warning on line 194 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Array double arrow not aligned correctly; expected 11 space(s) between "'default'" and double arrow, but found 1.
)
);

if ( ! isset( $_POST['openedx_commerce_new_token_nonce'] ) ||
! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['openedx_commerce_new_token_nonce'] ) ), 'openedx_commerce_token' )
) {
Expand Down Expand Up @@ -324,5 +370,35 @@
'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 <a href="https://docs.openedx.org/projects/wordpress-ecommerce-plugin/en/latest/how-tos/create_an_openedx_app.html">Create an Open edX Application for the Plugin Settings</a> 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);

Check failure on line 382 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces before closing parenthesis; 0 found

Check failure on line 382 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces after opening parenthesis; 0 found
?>
<input type="checkbox" id="openedx-enrollment-force" name="openedx-enrollment-force" value="1" <?php checked(1, $force_enrollment, true); ?>>

Check failure on line 384 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces before closing parenthesis; 0 found

Check failure on line 384 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces after opening parenthesis; 0 found
<label for="openedx-enrollment-force"><?php esc_html_e('Use the "force" flag. Disregard the course\'s enrollment end dates.', 'openedx-commerce'); ?></label>

Check failure on line 385 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces before closing parenthesis; 0 found

Check failure on line 385 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces after opening parenthesis; 0 found
<?php
}

/**
* Output the enrollment allowed settings field.
*
* Retrieves the saved enrollment allowed value and outputs a checkbox input field and description text.
*
* @return void
*/
public function openedx_enrollment_allowed_callback() {
$allow_non_existing = get_option('openedx-enrollment-allowed', false);

Check failure on line 397 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces before closing parenthesis; 0 found

Check failure on line 397 in admin/views/class-openedx-commerce-settings.php

View workflow job for this annotation

GitHub Actions / PHPCS check

Expected 1 spaces after opening parenthesis; 0 found
?>
<input type="checkbox" id="openedx-enrollment-allowed" name="openedx-enrollment-allowed" value="1" <?php checked(1, $allow_non_existing, true); ?>>
<label for="openedx-enrollment-allowed"><?php esc_html_e('Create course enrollment allowed if the user doesn\'t exist in the Open edX platform.', 'openedx-commerce'); ?></label>
<?php
}
}

4 changes: 2 additions & 2 deletions openedx-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Open edX Commerce
* Plugin URI: https://github.com/openedx/openedx-wordpress-ecommerce
* Description: Easily connect your WooCommerce store to Open edX.
* Version: 2.0.7
* Version: 2.0.8
* Author: Open edX Community
* Author URI: https://github.com/openedx/openedx-wordpress-ecommerce
* License: GPL-2.0+
Expand Down Expand Up @@ -32,7 +32,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'OPENEDX_COMMERCE_VERSION', '2.0.7' );
define( 'OPENEDX_COMMERCE_VERSION', '2.0.8' );

/**
* The code that runs during plugin activation.
Expand Down
Loading