Skip to content

Commit

Permalink
Merge branch 'dev' into sazedul-haque
Browse files Browse the repository at this point in the history
  • Loading branch information
sazedul-haque committed Jan 20, 2025
2 parents 99fef56 + 66b8cf4 commit af3ddfb
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 34 deletions.
Binary file modified assets/fonts/tutor-v2.woff
Binary file not shown.
10 changes: 5 additions & 5 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5827,19 +5827,19 @@ public function tutor_social_share_icons() {
'facebook' => array(
'share_class' => 's_facebook',
'icon_html' => '<i class="tutor-valign-middle tutor-icon-brand-facebook"></i>',
'text' => __( 'Facebook', 'tutor' ),
'text' => '',
'color' => '#3877EA',
),
'twitter' => array(
'share_class' => 's_twitter',
'icon_html' => '<i class="tutor-valign-middle tutor-icon-brand-twitter"></i>',
'text' => __( 'Twitter', 'tutor' ),
'color' => '#4CA0EB',
'icon_html' => '<i class="tutor-valign-middle tutor-icon-brand-x-twitter"></i>',
'text' => '',
'color' => '#000000',
),
'linkedin' => array(
'share_class' => 's_linkedin',
'icon_html' => '<i class="tutor-valign-middle tutor-icon-brand-linkedin"></i>',
'text' => __( 'Linkedin', 'tutor' ),
'text' => '',
'color' => '#3967B6',
),
);
Expand Down
4 changes: 2 additions & 2 deletions ecommerce/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private function prepare_items( $item_ids, $order_type = OrderModel::TYPE_SINGLE
$item_name = get_the_title( $item_id );
$course_price = tutor_utils()->get_raw_course_price( $item_id );
if ( OrderModel::TYPE_SINGLE_ORDER !== $order_type ) {
$plan_info = apply_filters( 'tutor_checkout_plan_info', null, $item_id );
$plan_info = apply_filters( 'tutor_get_plan_info', null, $item_id );
if ( $plan_info ) {
$item_name = $plan_info->plan_name;
$course_price->regular_price = $plan_info->regular_price;
Expand Down Expand Up @@ -567,7 +567,7 @@ public static function prepare_payment_data( array $order ) {

if ( OrderModel::TYPE_SUBSCRIPTION === $order_type ) {
$plan_id = $item_id;
$plan_info = apply_filters( 'tutor_checkout_plan_info', new \stdClass(), $plan_id );
$plan_info = apply_filters( 'tutor_get_plan_info', new \stdClass(), $plan_id );
$item_name = $plan_info->plan_name ?? '';

$items[] = array(
Expand Down
20 changes: 9 additions & 11 deletions ecommerce/HooksHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function manage_earnings_and_enrollments( string $order_status, int $orde
*
* @since 3.2.0
*/
$plan_info = apply_filters( 'tutor_checkout_plan_info', new \stdClass(), $object_id );
$plan_info = apply_filters( 'tutor_get_plan_info', new \stdClass(), $object_id );
if ( $plan_info && isset( $plan_info->is_membership_plan ) && $plan_info->is_membership_plan ) {
continue;
}
Expand All @@ -325,7 +325,7 @@ public function manage_earnings_and_enrollments( string $order_status, int $orde
// Update enrollment status based on order status.
$update = tutor_utils()->update_enrollments( $enrollment_status, array( $has_enrollment->ID ) );
if ( $update ) {
if ( $this->is_bundle_order( $order, $object_id ) ) {
if ( $this->is_bundle_order( $order, $object_id ) && $this->order_model->is_single_order( $order ) ) {
if ( 'completed' === $enrollment_status ) {
BundleModel::enroll_to_bundle_courses( $object_id, $student_id );
} else {
Expand All @@ -336,7 +336,7 @@ public function manage_earnings_and_enrollments( string $order_status, int $orde
/**
* For subscription, renewal no need to update order id.
*/
if ( $this->order_model::TYPE_SINGLE_ORDER === $order->order_type ) {
if ( $this->order_model->is_single_order( $order ) ) {
update_post_meta( $has_enrollment->ID, '_tutor_enrolled_by_order_id', $order_id );

/**
Expand Down Expand Up @@ -365,21 +365,19 @@ public function manage_earnings_and_enrollments( string $order_status, int $orde
do_action( 'tutor_after_enrolled', $object_id, $student_id, $has_enrollment->ID );
}
}

if ( 'completed' === $enrollment_status ) {
do_action( 'tutor_order_enrolled', $order, $has_enrollment->ID );
}
}
} else {
if ( $order->order_status === $this->order_model::ORDER_COMPLETED ) {
// Insert enrollment.
add_filter(
'tutor_enroll_data',
function( $enroll_data ) {
$enroll_data['post_status'] = 'completed';
return $enroll_data;
}
);
add_filter( 'tutor_enroll_data', fn( $enroll_data) => array_merge( $enroll_data, array( 'post_status' => 'completed' ) ) );

$enrollment_id = tutor_utils()->do_enroll( $object_id, $order_id, $student_id );
if ( $enrollment_id ) {
if ( $this->is_bundle_order( $order, $object_id ) ) {
if ( $this->is_bundle_order( $order, $object_id ) && $this->order_model->is_single_order( $order ) ) {
BundleModel::enroll_to_bundle_courses( $object_id, $student_id );
}
update_post_meta( $enrollment_id, '_tutor_enrolled_by_order_id', $order_id );
Expand Down
2 changes: 1 addition & 1 deletion ecommerce/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function create_order( int $user_id, array $items, string $payment_status

// Add enrollment fee with total & subtotal price.
if ( $this->model::TYPE_SINGLE_ORDER !== $order_type ) {
$plan = apply_filters( 'tutor_checkout_plan_info', null, $items[0]['item_id'] );
$plan = apply_filters( 'tutor_get_plan_info', null, $items[0]['item_id'] );
if ( $plan ) {
$item_price = $this->model::calculate_order_price( $items );
$subtotal_price = $item_price->subtotal;
Expand Down
19 changes: 10 additions & 9 deletions ecommerce/PaymentGateways/Paypal/src/Payments/Paypal/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private function createAmountData($data)
{
$returnData = [
'currency_code' => $data->currency->code,
'value' => (string) $data->total_price,
'value' => number_format($data->total_price, 2, '.', ''),
];

$extraCharges = [
Expand All @@ -216,7 +216,7 @@ private function createAmountData($data)
if (isset($data->$key) && !empty($data->$key)) {
$returnData['breakdown'][$value] = [
'currency_code' => $data->currency->code,
'value' => (string) $data->$key,
'value' => number_format($data->$key, 2, '.', ''),
];
}
});
Expand Down Expand Up @@ -630,7 +630,8 @@ private function getItems(&$data): array
$items = array_map(function ($item) use ($currency, $data) {

$price = is_null($item['discounted_price']) ? $item['regular_price'] : $item['discounted_price'];

$price = number_format($price, 2, '.', '');

$data->subtotal += $price * (int) $item['quantity'];

return [
Expand All @@ -639,7 +640,7 @@ private function getItems(&$data): array
'image_url' => isset($item['image']) && $item['image'] ? Path::clean($item['image']) : null,
'unit_amount' => [
'currency_code' => $currency,
'value' => (string) $price,
'value' => $price,
],
];
}, (array) $data->items);
Expand Down Expand Up @@ -867,7 +868,7 @@ private function createAmountForRecurring($data): array
{
return [
'currency_code' => $data->currency->code,
'value' => (string) $data->total_amount,
'value' => number_format($data->total_amount, 2, '.', ''),
];
}

Expand All @@ -891,11 +892,11 @@ private function prepareDataForRefund($data): array
$this->refundLink = $this->getUrl($paymentPayload->purchase_units[0]->payments->captures[0]->links, 'refund');

return [
'custom_id' => (string) $data->order_id,
'custom_id' => (string) $data->order_id,
'note_to_payer' => $data->reason,
'amount' => (object) [
'amount' => (object) [
'currency_code' => $data->currency->code,
'value' => $data->amount,
'value' => number_format($data->amount, 2, '.', ''),
],
];
}
Expand Down Expand Up @@ -1154,4 +1155,4 @@ private function processRefund($paymentData)
throw new ErrorException($errorMessage);
}
}
}
}
18 changes: 18 additions & 0 deletions includes/tutor-general-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1729,3 +1729,21 @@ function tutor_split_amounts( $amounts ) {
}
}

if ( ! function_exists( 'tutor_is_local_env' ) ) {
/**
* Check if the current environment is local.
*
* @since 3.2.0
*
* @return bool True if the current environment is local, false otherwise.
*/
function tutor_is_local_env() {
$site_url = site_url();
return (
strpos( $site_url, '.local' ) !== false ||
strpos( $site_url, 'localhost' ) !== false
);
}
}


2 changes: 1 addition & 1 deletion models/CouponModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ public function is_coupon_requirement_meet( $item_id, object $coupon, $order_typ
foreach ( $item_ids as $item_id ) {
$course_price = tutor_utils()->get_raw_course_price( $item_id );
if ( OrderModel::TYPE_SINGLE_ORDER !== $order_type ) {
$plan_info = apply_filters( 'tutor_checkout_plan_info', null, $item_id );
$plan_info = apply_filters( 'tutor_get_plan_info', null, $item_id );
if ( $plan_info ) {
$course_price->regular_price = $plan_info->regular_price;
$course_price->sale_price = $plan_info->in_sale_price ? $plan_info->sale_price : 0;
Expand Down
14 changes: 14 additions & 0 deletions models/OrderModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,20 @@ public static function is_subscription_order( $order ) {
return $order && self::TYPE_SUBSCRIPTION === $order->order_type;
}

/**
* Check order is single order
*
* @since 3.2.0
*
* @param int|object $order order id or object.
*
* @return boolean
*/
public static function is_single_order( $order ) {
$order = self::get_order( $order );
return $order && self::TYPE_SINGLE_ORDER === $order->order_type;
}

/**
* Mark order Unpaid to Paid.
*
Expand Down
21 changes: 20 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,26 @@ Tutor LMS allows you to offer certificates to your students upon course completi

= 3.2.0 - January 20, 2024

Coming soon...
New: Added Membership support (Phase 1) in the Native Subscription system.
New: Redesigned the Native Subscription and introduced Subscriptions for Course Bundles.
New: Integrated Authorize.net payment gateway.
New: Added re-subscription option upon cancellation or expiration.
New: Added a setting to allow or restrict instructors from changing course authors.
Update: Added Support for Internationalised Characters when converting slug.
Update: Implemented a licensing system with OAuth authentication.
Update: Redesigned the Addon page and included a plugin installation feature.
Update: Improved responsive design for the course builder.
Update: Email templates now support RTL (Right-to-Left) languages.
Fix: Resolved issue with Gutenberg WooCommerce checkout page not enrolling users after guest checkout.
Fix: Adjusted instructor earnings calculation to account for discounted prices when WooCommerce coupons are applied.
Fix: Corrected access issue where students retained course access after subscription expiration in Paid Membership Pro.
Fix: Fixed error message for H5P quiz ID in Tutor quiz descriptions.
Fix: Resolved PHP warning in legacy mode on the course builder.
Fix: Fixed WPML course duplication issue in the new course builder.
Fix: The Tutor report graph now displays correctly after translation with Loco Translate.
Fix: Email verification links are now correctly encoded.
Fix: Fixed enrollment counter not updating for private courses in the student dashboard.
Fix: Resolved issue with course thumbnails not being added to WooCommerce products.

= 3.1.0 - December 12, 2024

Expand Down
2 changes: 1 addition & 1 deletion templates/dashboard/purchase_history.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
$object_title = get_the_title( $course_id );
if ( OrderModel::TYPE_SINGLE_ORDER !== $order->order_type ) {
$object_id = apply_filters( 'tutor_subscription_course_by_plan', $item->id, $order );
$plan_info = apply_filters( 'tutor_checkout_plan_info', new \stdClass(), $item->id );
$plan_info = apply_filters( 'tutor_get_plan_info', new \stdClass(), $item->id );
if ( $plan_info && isset( $plan_info->is_membership_plan ) && $plan_info->is_membership_plan ) {
$object_title = $plan_info->plan_name;
} else {
Expand Down
2 changes: 1 addition & 1 deletion templates/ecommerce/checkout-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$course_list = $courses['results'];

$plan_id = (int) Input::sanitize_request_data( 'plan' );
$plan_info = apply_filters( 'tutor_checkout_plan_info', new stdClass(), $plan_id );
$plan_info = apply_filters( 'tutor_get_plan_info', new stdClass(), $plan_id );

// Contains Course/Bundle/Plan ids.
$object_ids = array();
Expand Down
Binary file modified v2-library/fonts/fonts/tutor-v2.woff
Binary file not shown.
3 changes: 3 additions & 0 deletions v2-library/fonts/tutor-icon/tutor-icon.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
.tutor-icon-mark-light:before {
content: "\f916";
}
.tutor-icon-brand-x-twitter:before {
content: "\f917";
}

/* tutor old fonts */

Expand Down
2 changes: 1 addition & 1 deletion v2-library/fonts/tutor-icon/tutor-v2-icons.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion views/course-share.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
<div class="tutor-fs-7 tutor-color-secondary tutor-mb-12">
<?php esc_html_e( 'Page Link', 'tutor' ); ?>
</div>
<div class="tutor-mb-32">
<div class="tutor-mb-32 tutor-position-relative">
<input class="tutor-form-control" value="<?php echo esc_attr( get_permalink( get_the_ID() ) ); ?>" />
<button class="tutor-btn tutro-btn-icon tutor-copy-text tutor-position-absolute tutor-bg-white" style="right: 2px; top: 2px;" data-text="<?php echo esc_attr( get_permalink( get_the_ID() ) ); ?>">
<span class="icon tutor-icon-copy"></span>
</button>
</div>
<div>
<div class="tutor-color-black tutor-fs-6 tutor-fw-medium tutor-mb-16">
Expand Down

0 comments on commit af3ddfb

Please sign in to comment.