Skip to content

Instantly share code, notes, and snippets.

@sekanderb
sekanderb / tutor-quiz.sql
Created July 6, 2021 03:26
If you are unable to create quiz options, please import this file into your database to create the necessary tables.
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: May 29, 2021 at 05:03 AM
-- Server version: 5.7.31
-- PHP Version: 7.3.21
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
@sekanderb
sekanderb / do_enrol.php
Last active October 4, 2023 04:07
Enroll students programmatically in Tutor LMS. Documentation link- https://docs.themeum.com/tutor-lms/developers/programmatically-enroll-students/
public function do_enroll($course_id = 0, $order_id = 0, $user_id = 0){
if ( ! $course_id){
return false;
}
do_action('tutor_before_enroll', $course_id);
$user_id = $this->get_user_id($user_id);
$title = __('Course Enrolled', 'tutor')." – ".date_i18n(get_option('date_format')) .' @ '.date_i18n(get_option('time_format') ) ;
@sekanderb
sekanderb / add-more-to-cart.php
Created July 3, 2019 12:30
Adds the feature to add multiple products on WooCommerce Cart
class add_more_to_cart {
private $prevent_redirect = false; //used to prevent WC from redirecting if we have more to process
function __construct() {
if ( ! isset( $_REQUEST[ 'add-more-to-cart' ] ) ) return; //don't load if we don't have to
$this->prevent_redirect = 'no'; //prevent WC from redirecting so we can process additional items
add_action( 'wp_loaded', [ $this, 'add_more_to_cart' ], 21 ); //fire after WC does, so we just process extra ones
add_action( 'pre_option_woocommerce_cart_redirect_after_add', [ $this, 'intercept_option' ], 9000 ); //intercept the WC option to force no redirect
}