Commit fc69a48d by Ali Arshad

added payment gateway 50%

parent b5f8d493
Pipeline #196 passed with stage
in 0 seconds
<?php
/**
* Created by PhpStorm.
* User: ali
* Date: 21/01/2018
* Time: 4:26 PM
*/
\ No newline at end of file
<?php
add_action('admin_menu', 'vq_lms_settings_page');
add_action('admin_init', 'vq_lms_settings_init');
add_action('admin_init', 'vq_lms_payment_settings_init');
function vq_lms_payment_settings_init()
{
register_setting('vq_lms_settings', 'vq_lms_payment_merchant_id');
register_setting('vq_lms_settings', 'vq_lms_payment_merchant_name');
register_setting('vq_lms_settings', 'vq_lms_payment_company_name');
register_setting('vq_lms_settings', 'vq_lms_payment_merchant_key');
add_settings_section(
'vq_lms_payment_settings_section',
'Payment Gateway Settings',
'vq_lms_general_settings_section_cb',
'vq_lms_settings'
);
add_settings_field(
'vq_lms_payment_settings_merchant_id',
'Merchant ID',
'vq_lms_payment_settings_merchant_id',
'vq_lms_settings',
'vq_lms_payment_settings_section'
);
add_settings_field(
'vq_lms_payment_merchant_name',
'Merchant Name',
'vq_lms_payment_merchant_name',
'vq_lms_settings',
'vq_lms_payment_settings_section'
);
add_settings_field(
'vq_lms_payment_company_name',
'Company Name',
'vq_lms_payment_company_name',
'vq_lms_settings',
'vq_lms_payment_settings_section'
);
add_settings_field(
'vq_lms_payment_merchant_key',
'Merchant Key',
'vq_lms_payment_merchant_key',
'vq_lms_settings',
'vq_lms_payment_settings_section'
);
}
function vq_lms_general_settings_section_cb()
{
echo "Settings related to payment gateway.";
}
function vq_lms_payment_merchant_key()
{
$merchant_key = get_option('vq_lms_payment_merchant_key');
?>
<input type="text"
name="vq_lms_payment_merchant_key"
value="<?php echo $merchant_key; ?>"
/>
<p class="description">
<?php esc_html_e('Specify Merchant Key of payment gateway.', 'vq_lms_settings'); ?>
</p>
<?php
}
function vq_lms_payment_company_name()
{
$company_name = get_option('vq_lms_payment_company_name');
?>
<input type="text"
name="vq_lms_payment_company_name"
value="<?php echo $company_name; ?>"
/>
<p class="description">
<?php esc_html_e('Specify Company Name of payment gateway.', 'vq_lms_settings'); ?>
</p>
<?php
}
function vq_lms_payment_merchant_name()
{
$merchant_name = get_option('vq_lms_payment_merchant_name');
?>
<input type="text"
name="vq_lms_payment_merchant_name"
value="<?php echo $merchant_name; ?>"
/>
<p class="description">
<?php esc_html_e('Specify Merchant Name of payment gateway.', 'vq_lms_settings'); ?>
</p>
<?php
}
add_action( 'admin_menu', 'vq_lms_settings_page' );
add_action( 'admin_init', 'vq_lms_settings_init' );
function vq_lms_settings_init() {
register_setting( 'vq_lms_settings', 'vq_lms_settings_options' );
add_settings_section(
'vq_lms_settings_section_developers',
'General Settings',
'vq_lms_settings_section_developers_cb',
'vq_lms_settings'
);
add_settings_field(
'vq_lms_settings_field_general_price',
'Default Course Price',
'vq_lms_settings_field_price_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_general_price',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
add_settings_field(
'vq_lms_settings_field_shortcode',
'Banner Shortcode',
'vq_lms_settings_field_shortcode_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers'
);
add_settings_field(
'vq_lms_settings_field_currency_name',
'Currency Name',
'vq_lms_settings_field_currency_name_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_currency_name',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
add_settings_field(
'vq_lms_settings_field_currency_symbol',
'Currency Symbol',
'vq_lms_settings_field_currency_symbol_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_currency_symbol',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
add_settings_field(
'vq_lms_settings_field_video',
'Video',
'vq_lms_settings_field_video_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_video',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
function vq_lms_payment_settings_merchant_id()
{
$merchant_id = get_option('vq_lms_payment_merchant_id');
?>
<input type="text"
name="vq_lms_payment_merchant_id"
value="<?php echo $merchant_id; ?>"
/>
<p class="description">
<?php esc_html_e('Specify Merchant ID of payment gateway.', 'vq_lms_settings'); ?>
</p>
<?php
}
function vq_lms_settings_init()
{
register_setting('vq_lms_settings', 'vq_lms_settings_options');
add_settings_section(
'vq_lms_settings_section_developers',
'General Settings',
'vq_lms_settings_section_developers_cb',
'vq_lms_settings'
);
add_settings_field(
'vq_lms_settings_field_general_price',
'Default Course Price',
'vq_lms_settings_field_price_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_general_price',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
add_settings_field(
'vq_lms_settings_field_shortcode',
'Banner Shortcode',
'vq_lms_settings_field_shortcode_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers'
);
add_settings_field(
'vq_lms_settings_field_currency_name',
'Currency Name',
'vq_lms_settings_field_currency_name_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_currency_name',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
add_settings_field(
'vq_lms_settings_field_currency_symbol',
'Currency Symbol',
'vq_lms_settings_field_currency_symbol_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_currency_symbol',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
add_settings_field(
'vq_lms_settings_field_video',
'Video',
'vq_lms_settings_field_video_cb',
'vq_lms_settings',
'vq_lms_settings_section_developers',
[
'label_for' => 'vq_lms_settings_field_video',
'class' => 'vq_lms_settings_row',
'vq_lms_settings_custom_data' => 'custom',
]
);
}
function vq_lms_settings_section_developers_cb( $args ) {
function vq_lms_settings_section_developers_cb($args)
{
}
function vq_lms_settings_field_price_cb( $args ) {
$options = get_option( 'vq_lms_settings_options' );
?>
<input type="text"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]"
value="<?php echo $options[$args['label_for']]; ?>"
>
<p class="description">
<?php esc_html_e( 'Your entered price will be listed as default price for all courses unless specified for each.', 'vq_lms_settings' ); ?>
</p>
<?php
function vq_lms_settings_field_price_cb($args)
{
$options = get_option('vq_lms_settings_options');
?>
<input type="text"
name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>"
>
<p class="description">
<?php esc_html_e('Your entered price will be listed as default price for all courses unless specified for each.', 'vq_lms_settings'); ?>
</p>
<?php
}
function vq_lms_settings_field_currency_name_cb($args) {
$options = get_option( 'vq_lms_settings_options' );
?>
<input type="text"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]"
value="<?php echo $options[$args['label_for']]; ?>"
>
<p class="description">
<?php esc_html_e( 'Your entered currency will be used for whole LMS system listing.', 'vq_lms_settings' ); ?>
</p>
<?php
function vq_lms_settings_field_currency_name_cb($args)
{
$options = get_option('vq_lms_settings_options');
?>
<input type="text"
name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>"
>
<p class="description">
<?php esc_html_e('Your entered currency will be used for whole LMS system listing.', 'vq_lms_settings'); ?>
</p>
<?php
}
function vq_lms_settings_field_currency_symbol_cb($args) {
$options = get_option( 'vq_lms_settings_options' );
?>
<input type="text"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]"
value="<?php echo $options[$args['label_for']]; ?>"
>
<p class="description">
<?php esc_html_e( 'Enter Currency Symbol.', 'vq_lms_settings' ); ?>
</p>
<?php
function vq_lms_settings_field_currency_symbol_cb($args)
{
$options = get_option('vq_lms_settings_options');
?>
<input type="text"
name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>"
>
<p class="description">
<?php esc_html_e('Enter Currency Symbol.', 'vq_lms_settings'); ?>
</p>
<?php
}
function vq_lms_settings_field_video_cb($args) {
function vq_lms_settings_field_video_cb($args)
{
wp_enqueue_media();
$options = get_option( 'vq_lms_settings_options' );
$options = get_option('vq_lms_settings_options');
if($options[$args['label_for']]) {
?>
if ($options[$args['label_for']]) {
?>
<div style="width: 200px;" id="video_holder">
<video id="vid" src="<?php echo $options[$args['label_for']]; ?>">
<video id="vid" src="<?php echo $options[$args['label_for']]; ?>">
</video>
</div>
<?php
}
?>
?>
<input type="button"
id="vq_lms_video"
......@@ -152,20 +270,20 @@ function vq_lms_settings_field_video_cb($args) {
<input type="hidden"
id="vq_lms_video_hidden"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]"
value="<?php echo $options[$args['label_for']]; ?>">
name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>">
<p class="description">
<?php esc_html_e( 'video attachment to show.', 'vq_lms_settings' ); ?>
<?php esc_html_e('video attachment to show.', 'vq_lms_settings'); ?>
</p>
<script>
var mediaUploader;
jQuery("#vq_lms_remove_video").on('click', function() {
jQuery("#vq_lms_remove_video").on('click', function () {
jQuery("#vq_lms_video_hidden").val('');
jQuery("#vid").attr('src', '');
});
jQuery('#vq_lms_video').on('click', function ( e ) {
jQuery('#vq_lms_video').on('click', function (e) {
e.preventDefault();
if (mediaUploader) {
mediaUploader.open();
......@@ -187,49 +305,52 @@ function vq_lms_settings_field_video_cb($args) {
});
</script>
<?php
<?php
}
function vq_lms_settings_field_shortcode_cb() {
echo '[vq_short_banner bgClr="" btnBg="" txt="" txtClr="" btnClr="" btnLink="" btnTxt=""]';
function vq_lms_settings_field_shortcode_cb()
{
echo '[vq_short_banner bgClr="" btnBg="" txt="" txtClr="" btnClr="" btnLink="" btnTxt=""]';
}
function vq_lms_settings_page() {
function vq_lms_settings_page()
{
add_submenu_page('edit.php?post_type=vq_course',
'Test Page',
'Settings',
'manage_options',
'vq_lms_settings',
'vq_lms_settings_page_html'
);
add_submenu_page('edit.php?post_type=vq_course',
'Test Page',
'Settings',
'manage_options',
'vq_lms_settings',
'vq_lms_settings_page_html'
);
}
function vq_lms_settings_page_html() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
if ( isset( $_GET['settings-updated'] ) ) {
add_settings_error(
'vq_lms_settings_messages',
'vq_lms_settings_message',
'Settings Saved',
'updated'
);
}
settings_errors( 'vq_lms_settings_messages' );
?>
<div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<form action="options.php" method="post">
<?php
settings_fields( 'vq_lms_settings' );
do_settings_sections( 'vq_lms_settings' );
submit_button( 'Save Settings' );
?>
</form>
</div>
<?php
function vq_lms_settings_page_html()
{
if (!current_user_can('manage_options')) {
return;
}
if (isset($_GET['settings-updated'])) {
add_settings_error(
'vq_lms_settings_messages',
'vq_lms_settings_message',
'Settings Saved',
'updated'
);
}
settings_errors('vq_lms_settings_messages');
?>
<div class="wrap">
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
<form action="options.php" method="post">
<?php
settings_fields('vq_lms_settings');
do_settings_sections('vq_lms_settings');
submit_button('Save Settings');
?>
</form>
</div>
<?php
}
\ No newline at end of file
......@@ -12,216 +12,390 @@ require_once('admin/lms-setting.php');
add_action('init', 'vq_apex_custom_posts');
add_action('init', 'vq_apex_custom_posts');
add_action('init', 'vq_apex_custom_taxonomies');
add_action('wp_ajax_processOrder', 'vq_lms_process_order');
add_action('wp_ajax_nopriv_processOrder', 'vq_lms_process_order');
add_filter('wp_nav_menu_items', 'vq_add_lms_navigation', 10, 2);
add_filter( 'query_vars', 'vq_query_vars_filter' );
add_filter('query_vars', 'vq_query_vars_filter');
add_shortcode('vq_short_banner', 'vq_render_short_banner');
add_filter( 'query_vars', 'vq_query_vars_filter' );
add_filter('query_vars', 'vq_query_vars_filter');
add_shortcode('vq_course_banner', 'vq_render_course_banner');
function vq_apex_custom_posts() {
/* Course Post Type */
$labels = array(
'name' => __( 'LMS Courses'),
'singular_name' => __( 'LMS Course'),
'menu_name' => __( 'LMS Courses'),
'name_admin_bar' => __( 'LMS Course'),
'add_new' => __( 'Add New', 'course'),
'add_new_item' => __( 'Add New LMS Course'),
'new_item' => __( 'New LMS Course'),
'edit_item' => __( 'Edit LMS Course'),
'view_item' => __( 'View LMS Course'),
'all_items' => __( 'All LMS Courses'),
'search_items' => __( 'Search LMS Courses'),
'parent_item_colon' => __( 'Parent LMS Courses:'),
'not_found' => __( 'No lms courses found.'),
'not_found_in_trash' => __( 'No lms courses found in Trash.')
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'lms-course' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail')
);
register_post_type( 'vq_course', $args );
/* Download Request Post Type */
$labels = array(
'name' => __( 'Download Requests'),
'singular_name' => __( 'Download Request'),
'menu_name' => __( 'Download Requests'),
'name_admin_bar' => __( 'Download Requests'),
'add_new' => __( 'Add New', 'download_request'),
'add_new_item' => __( 'Add New Download Request'),
'new_item' => __( 'New Download Request'),
'edit_item' => __( 'Edit Download Request'),
'view_item' => __( 'View Download Request'),
'all_items' => __( 'Download Requests'),
'search_items' => __( 'Search Download Requests'),
'parent_item_colon' => __( 'Parent Download Requests:'),
'not_found' => __( 'No Download Request found.'),
'not_found_in_trash' => __( 'No Download Request found in Trash.')
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.'),
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => "edit.php?post_type=vq_course",
'query_var' => true,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail')
);
register_post_type( 'vq_lms_drequest', $args );
/* Pricing Requests Post Type */
$labels = array(
'name' => __( 'Pricing Requests'),
'singular_name' => __( 'Pricing Request'),
'menu_name' => __( 'Pricing Requests'),
'name_admin_bar' => __( 'Pricing Requests'),
'add_new' => __( 'Add New', 'download_request'),
'add_new_item' => __( 'Add New Pricing Request'),
'new_item' => __( 'New Pricing Request'),
'edit_item' => __( 'Edit Pricing Request'),
'view_item' => __( 'View Pricing Request'),
'all_items' => __( 'Pricing Requests'),
'search_items' => __( 'Search Pricing Requests'),
'parent_item_colon' => __( 'Parent Pricing Requests:'),
'not_found' => __( 'No Pricing Request found.'),
'not_found_in_trash' => __( 'No Pricing Request found in Trash.')
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.'),
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => "edit.php?post_type=vq_course",
'query_var' => true,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail')
);
register_post_type( 'vq_lms_prequest', $args );
function vq_lms_process_order()
{
if (!isset($_POST['data'])) {
echo "Unable to process your request";
die;
}
$data = json_decode(stripslashes($_POST['data']), true);
if (count($data) === 0) {
echo "Unable to process your request";
die;
}
$options = get_option('vq_lms_settings_options');
$itemsXML = "";
$totalCost = 0;
$postContent = "<h2>Items:</h2>";
foreach ($data as $user) {
$coursesId = array_column($user['courses'], "id");
foreach ($coursesId as $cid) {
$course = get_post($cid);
$item = $course->post_title . " (" . $user['fname'] . ")";
$cost = get_post_meta($course->ID, "course_fee", true);
if (!$cost) {
$cost = $options['vq_lms_settings_field_general_price'];
}
if (!$cost) {
echo "Unable to process your request";
die;
}
$totalCost += floatval($cost);
$itemsXML .= "<Items><itemname>".$item."</itemname><quantity>1</quantity><amount>".number_format((float)$cost,
2, '.', '')."</amount></Items>";
$postContent .= $item." 1 ".number_format((float)$cost,2, '.', '')."<br />";
$postContent .= $user['email']."<br />";
$postContent .= $user['phone']."<br /><hr />";
}
}
echo wp_insert_post(array(
"post_content" => $postContent,
"post_title" => date("Y-m-d h:i:sa"),
"post_type" => "vq_lms_orders",
"post_status" => "publish"
));
$learner = $data[0];
$name = explode(' ', $learner['fname']);
$_mid = get_option("vq_lms_payment_merchant_id");
$_requestid = substr(uniqid(), 0, 13);
$_noturl = site_url("lms-notify");; // url where response is posted
$_resurl = site_url("lms-payment-confirm"); //url of merchant landing page
$_cancelurl = site_url("lms-cancel"); //url of merchant landing page
$_fname = $name[0]; // kindly set this to first name of the cutomer
$_lname = $name[1]; // kindly set this to last name of the cutomer
$_addr1 = "online"; // kindly set this to address1 of the cutomer
$_sec3d = "try3d"; //
$_email = $learner["email"]; // kindly set this to email of the cutomer
$_phone = $learner["phone"]; // kindly set this to phone number of the cutomer
$_clientip = $_SERVER['REMOTE_ADDR'];
$_amount = number_format((float)$totalCost, 2, '.', ''); // kindly set this to the total amount of the
// transaction. Set the amount to 2 decimal
// point before generating signature.
$_currency = $options['vq_lms_settings_field_currency_symbol'];
$forSign = $_mid . $_requestid . $_noturl . $_resurl . $_fname . $_lname . $_addr1 . $_email . $_phone .
$_clientip . $_amount . $_currency . $_sec3d;
$cert = get_option("vq_lms_payment_merchant_key");
$_sign = hash("sha512", $forSign . $cert);
$strxml = "";
$strxml = $strxml . "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$strxml = $strxml . "<Request>";
$strxml = $strxml . "<orders>";
$strxml = $strxml . "<items>";
// $strxml = $strxml . "<Items>";
$strxml = $strxml . $itemsXML;//"<itemname>item 1</itemname><quantity>1</quantity><amount>10.00</amount>"; // pls
// change this value to the preferred item to be seen by customer. (eg. Room Detail (itemname - Beach Villa, 1 Room, 2 Adults quantity - 0 amount - 10)) NOTE : total amount of item/s should be equal to the amount passed in amount xml node below.
// $strxml = $strxml . "</Items>";
$strxml = $strxml . "</items>";
$strxml = $strxml . "</orders>";
$strxml = $strxml . "<mid>" . $_mid . "</mid>";
$strxml = $strxml . "<request_id>" . $_requestid . "</request_id>";
// $strxml = $strxml . "<ip_address>" . $_ipaddress . "</ip_address>";
$strxml = $strxml . "<notification_url>" . $_noturl . "</notification_url>";
$strxml = $strxml . "<response_url>" . $_resurl . "</response_url>";
$strxml = $strxml . "<cancel_url>" . $_cancelurl . "</cancel_url>";
$strxml = $strxml . "<mtac_url></mtac_url>"; // pls set this to the url where your terms and conditions are hosted
$strxml = $strxml . "<descriptor_note>''</descriptor_note>"; // pls set this to the descriptor of the merchant ""
$strxml = $strxml . "<fname>" . $_fname . "</fname>";
$strxml = $strxml . "<lname>" . $_lname . "</lname>";
// $strxml = $strxml . "<mname>" . $_mname . "</mname>";
$strxml = $strxml . "<address1>" . $_addr1 . "</address1>";
// $strxml = $strxml . "<address2>" . $_addr2 . "</address2>";
// $strxml = $strxml . "<city>" . $_city . "</city>";
// $strxml = $strxml . "<state>" . $_state . "</state>";
// $strxml = $strxml . "<country>" . $_country . "</country>";
// $strxml = $strxml . "<zip>" . $_zip . "</zip>";
$strxml = $strxml . "<secure3d>" . $_sec3d . "</secure3d>";
$strxml = $strxml . "<trxtype>sale</trxtype>";
$strxml = $strxml . "<email>" . $_email . "</email>";
$strxml = $strxml . "<phone>" . $_phone . "</phone>";
// $strxml = $strxml . "<mobile>" . $_mobile . "</mobile>";
$strxml = $strxml . "<client_ip>" . $_clientip . "</client_ip>";
$strxml = $strxml . "<amount>" . $_amount . "</amount>";
$strxml = $strxml . "<currency>" . $_currency . "</currency>";
$strxml = $strxml . "<mlogo_url></mlogo_url>";// pls set this to the url where your logo is hosted
$strxml = $strxml . "<pmethod></pmethod>";
$strxml = $strxml . "<signature>" . $_sign . "</signature>";
$strxml = $strxml . "</Request>";
echo base64_encode($strxml);
die;
}
function vq_apex_custom_posts()
{
/* Course Post Type */
$labels = array(
'name' => __('LMS Courses'),
'singular_name' => __('LMS Course'),
'menu_name' => __('LMS Courses'),
'name_admin_bar' => __('LMS Course'),
'add_new' => __('Add New', 'course'),
'add_new_item' => __('Add New LMS Course'),
'new_item' => __('New LMS Course'),
'edit_item' => __('Edit LMS Course'),
'view_item' => __('View LMS Course'),
'all_items' => __('All LMS Courses'),
'search_items' => __('Search LMS Courses'),
'parent_item_colon' => __('Parent LMS Courses:'),
'not_found' => __('No lms courses found.'),
'not_found_in_trash' => __('No lms courses found in Trash.')
);
$args = array(
'labels' => $labels,
'description' => __('Description.'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'lms-course'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('vq_course', $args);
/* Download Request Post Type */
$labels = array(
'name' => __('Download Requests'),
'singular_name' => __('Download Request'),
'menu_name' => __('Download Requests'),
'name_admin_bar' => __('Download Requests'),
'add_new' => __('Add New', 'download_request'),
'add_new_item' => __('Add New Download Request'),
'new_item' => __('New Download Request'),
'edit_item' => __('Edit Download Request'),
'view_item' => __('View Download Request'),
'all_items' => __('Download Requests'),
'search_items' => __('Search Download Requests'),
'parent_item_colon' => __('Parent Download Requests:'),
'not_found' => __('No Download Request found.'),
'not_found_in_trash' => __('No Download Request found in Trash.')
);
$args = array(
'labels' => $labels,
'description' => __('Description.'),
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => "edit.php?post_type=vq_course",
'query_var' => true,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('vq_lms_drequest', $args);
/* Pricing Requests Post Type */
$labels = array(
'name' => __('Pricing Requests'),
'singular_name' => __('Pricing Request'),
'menu_name' => __('Pricing Requests'),
'name_admin_bar' => __('Pricing Requests'),
'add_new' => __('Add New', 'download_request'),
'add_new_item' => __('Add New Pricing Request'),
'new_item' => __('New Pricing Request'),
'edit_item' => __('Edit Pricing Request'),
'view_item' => __('View Pricing Request'),
'all_items' => __('Pricing Requests'),
'search_items' => __('Search Pricing Requests'),
'parent_item_colon' => __('Parent Pricing Requests:'),
'not_found' => __('No Pricing Request found.'),
'not_found_in_trash' => __('No Pricing Request found in Trash.')
);
$args = array(
'labels' => $labels,
'description' => __('Description.'),
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => "edit.php?post_type=vq_course",
'query_var' => true,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('vq_lms_prequest', $args);
/* Pricing Requests Post Type */
$labels = array(
'name' => __('Orders'),
'singular_name' => __('Order'),
'menu_name' => __('Orders'),
'name_admin_bar' => __('Orders'),
'add_new' => __('Add New', 'download_request'),
'add_new_item' => __('Add New Order'),
'new_item' => __('New Order'),
'edit_item' => __('Edit Order'),
'view_item' => __('View Order'),
'all_items' => __('Orders'),
'search_items' => __('Search Orders'),
'parent_item_colon' => __('Parent Orders:'),
'not_found' => __('No Orders found.'),
'not_found_in_trash' => __('No Orders found in Trash.')
);
$args = array(
'labels' => $labels,
'description' => __('LMS Orders.'),
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => "edit.php?post_type=vq_course",
'query_var' => true,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'supports' => array('title', 'editor')
);
register_post_type('vq_lms_orders', $args);
}
function vq_apex_custom_taxonomies() {
$labels = array(
'name' => 'LMS Category',
'add_new_item' => 'Add New LMS Category',
'new_item_name' => 'New LMS Category'
);
register_taxonomy(
'vq_course_taxonomy',
'vq_course',
array(
$labels,
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'e-learning', 'with_front' => false ),
)
);
function vq_apex_custom_taxonomies()
{
$labels = array(
'name' => 'LMS Category',
'add_new_item' => 'Add New LMS Category',
'new_item_name' => 'New LMS Category'
);
register_taxonomy(
'vq_course_taxonomy',
'vq_course',
array(
$labels,
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array('slug' => 'e-learning', 'with_front' => false),
)
);
}
function vq_add_lms_navigation($items, $args) {
$items .= '<li id="menu-item-786" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-786"><a href="'.site_url('lms').'">E-Learning</a></li>';
return $items;
function vq_add_lms_navigation($items, $args)
{
$items .= '<li id="menu-item-786" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-786"><a href="' . site_url('lms') . '">E-Learning</a></li>';
return $items;
}
function vq_query_vars_filter( $vars ){
$vars[] = "course";
return $vars;
function vq_query_vars_filter($vars)
{
$vars[] = "course";
return $vars;
}
function vq_render_short_banner($attr) {
function vq_render_short_banner($attr)
{
$bgColor = isset($attr['bgclr']) ? $attr['bgclr'] : "#000";
$btnBg = isset($attr['btnbg']) ? $attr['btnbg'] : "#00f";
$txt = isset($attr['txt']) ? $attr['txt'] : "Heading";
$txtClr = isset($attr['txtclr']) ? $attr['txtclr'] : "#fff";
$btnClr = isset($attr['btnclr']) ? $attr['btnclr'] : "#fff";
$btnLink = isset($attr['btnlink']) ? $attr['btnlink'] : 'https://google.com';
$btnTxt = isset($attr['btntxt']) ? $attr['btntxt'] : 'Click Here';
$bgColor = isset($attr['bgclr']) ? $attr['bgclr'] : "#000";
$btnBg = isset($attr['btnbg']) ? $attr['btnbg'] : "#00f";
$txt = isset($attr['txt']) ? $attr['txt'] : "Heading";
$txtClr = isset($attr['txtclr']) ? $attr['txtclr'] : "#fff";
$btnClr = isset($attr['btnclr']) ? $attr['btnclr'] : "#fff";
$btnLink = isset($attr['btnlink']) ? $attr['btnlink'] : 'https://google.com';
$btnTxt = isset($attr['btntxt']) ? $attr['btntxt'] : 'Click Here';
$banner = file_get_contents(__DIR__ . '/admin/includes/short-banner.html');
$banner = file_get_contents(__DIR__ . '/admin/includes/short-banner.html');
$banner = str_replace('[[TXT]]', $txt, $banner);
$banner = str_replace('[[TXT]]', $txt, $banner);
$banner = str_replace('[[BTN_TXT]]', $btnTxt, $banner);
$banner = str_replace('[[BANNER_BG]]', $bgColor, $banner);
$banner = str_replace('[[BTN_LINK]]', $btnLink, $banner);
$banner = str_replace('[[BTN_BG]]', $btnBg, $banner);
$banner = str_replace('[[TXT_CLR]]', $txtClr, $banner);
$banner = str_replace('[[BTN_CLR]]', $btnClr, $banner);
$banner = str_replace('[[BTN_TXT]]', $btnTxt, $banner);
$banner = str_replace('[[BANNER_BG]]', $bgColor, $banner);
$banner = str_replace('[[BTN_LINK]]', $btnLink, $banner);
$banner = str_replace('[[BTN_BG]]', $btnBg, $banner);
$banner = str_replace('[[TXT_CLR]]', $txtClr, $banner);
$banner = str_replace('[[BTN_CLR]]', $btnClr, $banner);
return $banner;
return $banner;
}
function vq_render_course_banner($attr) {
function vq_render_course_banner($attr)
{
if(!isset($attr['id'])) {
return 'No Course Found';
} else {
$cid = $attr['id'];
}
if (!isset($attr['id'])) {
return 'No Course Found';
} else {
$cid = $attr['id'];
}
$page = get_post($cid);
$page = get_post($cid);
$fee = get_post_meta($page->ID, 'course_fee', true);
$fee = get_post_meta($page->ID, 'course_fee', true);
if(empty($fee) || $fee <= 0) {
$settings = get_option('vq_lms_settings_options');
$fee = $settings['vq_lms_settings_field_general_price'];
}
if (empty($fee) || $fee <= 0) {
$settings = get_option('vq_lms_settings_options');
$fee = $settings['vq_lms_settings_field_general_price'];
}
$banner = file_get_contents(__DIR__ . '/admin/includes/large-banner.html');
$banner = file_get_contents(__DIR__ . '/admin/includes/large-banner.html');
$banner = str_replace('[[BANNER_HEADING]]', $page->post_title, $banner);
$banner = str_replace('[[BANNER_HEADING]]', $page->post_title, $banner);
$banner = str_replace('[[BANNER_DESCRIPTION]]', $page->post_content, $banner);
$banner = str_replace('[[BANNER_DESCRIPTION]]', $page->post_content, $banner);
$banner = str_replace('[[BG_IMG]]', get_the_post_thumbnail_url($page->id), $banner);
$banner = str_replace('[[BG_IMG]]', get_the_post_thumbnail_url($page->id), $banner);
$banner = str_replace('[[REDIRECT_URL]]', get_permalink($page->ID), $banner);
$banner = str_replace('[[REDIRECT_URL]]', get_permalink($page->ID), $banner);
$banner = str_replace('[[FEE]]', $fee, $banner);
$banner = str_replace('[[FEE]]', $fee, $banner);
return $banner;
return $banner;
}
<?php
$lmsVersion = "0.3";
$lmsVersion = "0.4";
add_action('wp_enqueue_scripts', 'enqueue_admin_css');
add_filter('template_include', 'use_lms_template', 99);
......
......@@ -664,4 +664,9 @@
line-height: 20px;
overflow: hidden;
text-overflow: ellipsis;
}
.bootstrap-iso .disabled {
pointer-events: none;
opacity: 0.8;
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ $courses = new WP_Query($args);
<?php the_post_thumbnail('thumbnail') ?>
</div>
<div class="col-sm-6">
<div class="course-heading">
<div class="course-heading" style="max-height: 105px; overflow: hidden;">
<h3><?php the_title(); ?> </h3>
<?php the_content(); ?>
</div>
......
......@@ -49,7 +49,7 @@
courseLearner[course.id].forEach(function (learner, index) {
var lmsSummerySingleElem = $(lmsSummerySingleLearner);
lmsSummerySingleElem.find(".index").html(index + 1);
lmsSummerySingleElem.find(".name").html(learner.name);
lmsSummerySingleElem.find(".name").html(learner.fname);
lmsSummerySingleElem.find(".email").html(learner.email);
lmsSummerySingleElem.find(".phone").html(learner.phone);
lmsSummerySingleElem.find(".price").html(course.cost + " " + lmsSettings.vq_lms_settings_field_currency_symbol);
......@@ -67,7 +67,7 @@
learners.forEach(function (item, index) {
var learnerFormElement = $(learnerFormTemplate);
learnerFormElement.find(".lmsIndex").html(index + 1);
learnerFormElement.find("input[name='name']").val(item.name);
learnerFormElement.find("input[name='fname']").val(item.fname);
learnerFormElement.find("input[name='email']").val(item.email);
learnerFormElement.find("input[name='confirmEmail']").val(item.confirmEmail);
learnerFormElement.find("input[name='phone']").val(item.phone);
......@@ -152,7 +152,7 @@
function addEmptyLearner() {
var lerner = {
name: "",
fname: "",
email: "",
confirmEmail: "",
phone: "",
......@@ -177,14 +177,46 @@
lmsCheckoutForm.submit(function (e) {
e.preventDefault();
var paymentBtn = $("#lmsProcessPayment");
var learnersWithNoCourse = learners.filter(function (learner) {
return learner.courses.length === 0;
});
var learnersMismatchEmails = learners.filter(function (learner) {
return learner.email !== learner.confirmEmail;
});
if (learnersWithNoCourse.length > 0) {
alert("Please select courses with all learners.");
e.preventDefault();
return;
}
if (learnersMismatchEmails.length > 0) {
alert("Confirm email mismatched.");
return;
}
paymentBtn.html("Please wait.");
paymentBtn.addClass("disabled");
$.post(ajaxurl, {
action: "processOrder",
data: JSON.stringify(learners)
}, function (data){
if(data == "Unable to process your request"){
alert(data);
paymentBtn.html("Proceed to payment");
paymentBtn.removeClass("disabled");
} else {
$("#paymentrequest").val(data);
$("#payserv").submit();
}
});
});
})(jQuery);
\ No newline at end of file
......@@ -5,6 +5,10 @@ $courses = new WP_Query(array('post_type' => 'vq_course'));
while (have_posts()):
the_post();
?>
<form name="payserv" id="payserv" method="post" action="https://testpti.payserv
.net/webpaymentv2/default.aspx">
<input type="hidden" name="paymentrequest" id="paymentrequest" value="" />
</form>
<div class="bootstrap-iso">
<div class="e-learning-banner">
<div class="container">
......@@ -60,7 +64,8 @@ while (have_posts()):
</div>
</div>
<div class="col-sm-12">
<button type="submit" class="payment-course-button">Proceed to payment</button>
<button type="submit" id="lmsProcessPayment" class="payment-course-button">Proceed to
payment</button>
</div>
</div>
</div>
......@@ -78,7 +83,7 @@ while (have_posts()):
</div>
<div class="col-sm-8 col-padding">
<input class="form-control text-feild" placeholder="Name"
maxlength="200" type="string" name="name" required />
maxlength="200" type="string" name="fname" required />
<input class="form-control text-feild" placeholder="Email"
maxlength="200" type="email" name="email" required />
<input class="form-control text-feild" placeholder="Confirm Email"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment