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 <?php
add_action('admin_menu', 'vq_lms_settings_page');
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');
add_action( 'admin_init', 'vq_lms_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');
function vq_lms_settings_init() { add_settings_section(
register_setting( 'vq_lms_settings', 'vq_lms_settings_options' ); '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
}
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( add_settings_section(
'vq_lms_settings_section_developers', 'vq_lms_settings_section_developers',
...@@ -78,59 +191,64 @@ function vq_lms_settings_init() { ...@@ -78,59 +191,64 @@ function vq_lms_settings_init() {
); );
} }
function vq_lms_settings_section_developers_cb( $args ) { function vq_lms_settings_section_developers_cb($args)
{
} }
function vq_lms_settings_field_price_cb( $args ) { function vq_lms_settings_field_price_cb($args)
$options = get_option( 'vq_lms_settings_options' ); {
$options = get_option('vq_lms_settings_options');
?> ?>
<input type="text" <input type="text"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]" name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>" value="<?php echo $options[$args['label_for']]; ?>"
> >
<p class="description"> <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' ); ?> <?php esc_html_e('Your entered price will be listed as default price for all courses unless specified for each.', 'vq_lms_settings'); ?>
</p> </p>
<?php <?php
} }
function vq_lms_settings_field_currency_name_cb($args) { function vq_lms_settings_field_currency_name_cb($args)
$options = get_option( 'vq_lms_settings_options' ); {
$options = get_option('vq_lms_settings_options');
?> ?>
<input type="text" <input type="text"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]" name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>" value="<?php echo $options[$args['label_for']]; ?>"
> >
<p class="description"> <p class="description">
<?php esc_html_e( 'Your entered currency will be used for whole LMS system listing.', 'vq_lms_settings' ); ?> <?php esc_html_e('Your entered currency will be used for whole LMS system listing.', 'vq_lms_settings'); ?>
</p> </p>
<?php <?php
} }
function vq_lms_settings_field_currency_symbol_cb($args) { function vq_lms_settings_field_currency_symbol_cb($args)
$options = get_option( 'vq_lms_settings_options' ); {
$options = get_option('vq_lms_settings_options');
?> ?>
<input type="text" <input type="text"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]" name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>" value="<?php echo $options[$args['label_for']]; ?>"
> >
<p class="description"> <p class="description">
<?php esc_html_e( 'Enter Currency Symbol.', 'vq_lms_settings' ); ?> <?php esc_html_e('Enter Currency Symbol.', 'vq_lms_settings'); ?>
</p> </p>
<?php <?php
} }
function vq_lms_settings_field_video_cb($args) { function vq_lms_settings_field_video_cb($args)
{
wp_enqueue_media(); 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"> <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']]; ?>">
...@@ -152,20 +270,20 @@ function vq_lms_settings_field_video_cb($args) { ...@@ -152,20 +270,20 @@ function vq_lms_settings_field_video_cb($args) {
<input type="hidden" <input type="hidden"
id="vq_lms_video_hidden" id="vq_lms_video_hidden"
name="vq_lms_settings_options[<?php echo esc_attr( $args['label_for'] ); ?>]" name="vq_lms_settings_options[<?php echo esc_attr($args['label_for']); ?>]"
value="<?php echo $options[$args['label_for']]; ?>"> value="<?php echo $options[$args['label_for']]; ?>">
<p class="description"> <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> </p>
<script> <script>
var mediaUploader; 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("#vq_lms_video_hidden").val('');
jQuery("#vid").attr('src', ''); jQuery("#vid").attr('src', '');
}); });
jQuery('#vq_lms_video').on('click', function ( e ) { jQuery('#vq_lms_video').on('click', function (e) {
e.preventDefault(); e.preventDefault();
if (mediaUploader) { if (mediaUploader) {
mediaUploader.open(); mediaUploader.open();
...@@ -190,11 +308,13 @@ function vq_lms_settings_field_video_cb($args) { ...@@ -190,11 +308,13 @@ function vq_lms_settings_field_video_cb($args) {
<?php <?php
} }
function vq_lms_settings_field_shortcode_cb() { function vq_lms_settings_field_shortcode_cb()
{
echo '[vq_short_banner bgClr="" btnBg="" txt="" txtClr="" btnClr="" btnLink="" btnTxt=""]'; 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', add_submenu_page('edit.php?post_type=vq_course',
'Test Page', 'Test Page',
...@@ -205,12 +325,13 @@ function vq_lms_settings_page() { ...@@ -205,12 +325,13 @@ function vq_lms_settings_page() {
); );
} }
function vq_lms_settings_page_html() { function vq_lms_settings_page_html()
if ( ! current_user_can( 'manage_options' ) ) { {
if (!current_user_can('manage_options')) {
return; return;
} }
if ( isset( $_GET['settings-updated'] ) ) { if (isset($_GET['settings-updated'])) {
add_settings_error( add_settings_error(
'vq_lms_settings_messages', 'vq_lms_settings_messages',
'vq_lms_settings_message', 'vq_lms_settings_message',
...@@ -219,15 +340,15 @@ function vq_lms_settings_page_html() { ...@@ -219,15 +340,15 @@ function vq_lms_settings_page_html() {
); );
} }
settings_errors( 'vq_lms_settings_messages' ); settings_errors('vq_lms_settings_messages');
?> ?>
<div class="wrap"> <div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1> <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
<form action="options.php" method="post"> <form action="options.php" method="post">
<?php <?php
settings_fields( 'vq_lms_settings' ); settings_fields('vq_lms_settings');
do_settings_sections( 'vq_lms_settings' ); do_settings_sections('vq_lms_settings');
submit_button( 'Save Settings' ); submit_button('Save Settings');
?> ?>
</form> </form>
</div> </div>
......
...@@ -12,78 +12,247 @@ require_once('admin/lms-setting.php'); ...@@ -12,78 +12,247 @@ 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_posts');
add_action('init', 'vq_apex_custom_taxonomies'); 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('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_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'); add_shortcode('vq_course_banner', 'vq_render_course_banner');
function vq_apex_custom_posts() { 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 */ /* Course Post Type */
$labels = array( $labels = array(
'name' => __( 'LMS Courses'), 'name' => __('LMS Courses'),
'singular_name' => __( 'LMS Course'), 'singular_name' => __('LMS Course'),
'menu_name' => __( 'LMS Courses'), 'menu_name' => __('LMS Courses'),
'name_admin_bar' => __( 'LMS Course'), 'name_admin_bar' => __('LMS Course'),
'add_new' => __( 'Add New', 'course'), 'add_new' => __('Add New', 'course'),
'add_new_item' => __( 'Add New LMS Course'), 'add_new_item' => __('Add New LMS Course'),
'new_item' => __( 'New LMS Course'), 'new_item' => __('New LMS Course'),
'edit_item' => __( 'Edit LMS Course'), 'edit_item' => __('Edit LMS Course'),
'view_item' => __( 'View LMS Course'), 'view_item' => __('View LMS Course'),
'all_items' => __( 'All LMS Courses'), 'all_items' => __('All LMS Courses'),
'search_items' => __( 'Search LMS Courses'), 'search_items' => __('Search LMS Courses'),
'parent_item_colon' => __( 'Parent LMS Courses:'), 'parent_item_colon' => __('Parent LMS Courses:'),
'not_found' => __( 'No lms courses found.'), 'not_found' => __('No lms courses found.'),
'not_found_in_trash' => __( 'No lms courses found in Trash.') 'not_found_in_trash' => __('No lms courses found in Trash.')
); );
$args = array( $args = array(
'labels' => $labels, 'labels' => $labels,
'description' => __( 'Description.'), 'description' => __('Description.'),
'public' => true, 'public' => true,
'publicly_queryable' => true, 'publicly_queryable' => true,
'show_ui' => true, 'show_ui' => true,
'show_in_menu' => true, 'show_in_menu' => true,
'query_var' => true, 'query_var' => true,
'rewrite' => array( 'slug' => 'lms-course' ), 'rewrite' => array('slug' => 'lms-course'),
'capability_type' => 'post', 'capability_type' => 'post',
'has_archive' => true, 'has_archive' => true,
'hierarchical' => false, 'hierarchical' => false,
'menu_position' => null, 'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail') 'supports' => array('title', 'editor', 'thumbnail')
); );
register_post_type( 'vq_course', $args ); register_post_type('vq_course', $args);
/* Download Request Post Type */ /* Download Request Post Type */
$labels = array( $labels = array(
'name' => __( 'Download Requests'), 'name' => __('Download Requests'),
'singular_name' => __( 'Download Request'), 'singular_name' => __('Download Request'),
'menu_name' => __( 'Download Requests'), 'menu_name' => __('Download Requests'),
'name_admin_bar' => __( 'Download Requests'), 'name_admin_bar' => __('Download Requests'),
'add_new' => __( 'Add New', 'download_request'), 'add_new' => __('Add New', 'download_request'),
'add_new_item' => __( 'Add New Download Request'), 'add_new_item' => __('Add New Download Request'),
'new_item' => __( 'New Download Request'), 'new_item' => __('New Download Request'),
'edit_item' => __( 'Edit Download Request'), 'edit_item' => __('Edit Download Request'),
'view_item' => __( 'View Download Request'), 'view_item' => __('View Download Request'),
'all_items' => __( 'Download Requests'), 'all_items' => __('Download Requests'),
'search_items' => __( 'Search Download Requests'), 'search_items' => __('Search Download Requests'),
'parent_item_colon' => __( 'Parent Download Requests:'), 'parent_item_colon' => __('Parent Download Requests:'),
'not_found' => __( 'No Download Request found.'), 'not_found' => __('No Download Request found.'),
'not_found_in_trash' => __( 'No Download Request found in Trash.') '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( $args = array(
'labels' => $labels, 'labels' => $labels,
'description' => __( 'Description.'), 'description' => __('Description.'),
'public' => false, 'public' => false,
'publicly_queryable' => false, 'publicly_queryable' => false,
'show_ui' => true, 'show_ui' => true,
...@@ -93,33 +262,33 @@ function vq_apex_custom_posts() { ...@@ -93,33 +262,33 @@ function vq_apex_custom_posts() {
'capability_type' => 'post', 'capability_type' => 'post',
'has_archive' => false, 'has_archive' => false,
'hierarchical' => false, 'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail') 'supports' => array('title', 'editor', 'thumbnail')
); );
register_post_type( 'vq_lms_drequest', $args ); register_post_type('vq_lms_prequest', $args);
/* Pricing Requests Post Type */ /* Pricing Requests Post Type */
$labels = array( $labels = array(
'name' => __( 'Pricing Requests'), 'name' => __('Orders'),
'singular_name' => __( 'Pricing Request'), 'singular_name' => __('Order'),
'menu_name' => __( 'Pricing Requests'), 'menu_name' => __('Orders'),
'name_admin_bar' => __( 'Pricing Requests'), 'name_admin_bar' => __('Orders'),
'add_new' => __( 'Add New', 'download_request'), 'add_new' => __('Add New', 'download_request'),
'add_new_item' => __( 'Add New Pricing Request'), 'add_new_item' => __('Add New Order'),
'new_item' => __( 'New Pricing Request'), 'new_item' => __('New Order'),
'edit_item' => __( 'Edit Pricing Request'), 'edit_item' => __('Edit Order'),
'view_item' => __( 'View Pricing Request'), 'view_item' => __('View Order'),
'all_items' => __( 'Pricing Requests'), 'all_items' => __('Orders'),
'search_items' => __( 'Search Pricing Requests'), 'search_items' => __('Search Orders'),
'parent_item_colon' => __( 'Parent Pricing Requests:'), 'parent_item_colon' => __('Parent Orders:'),
'not_found' => __( 'No Pricing Request found.'), 'not_found' => __('No Orders found.'),
'not_found_in_trash' => __( 'No Pricing Request found in Trash.') 'not_found_in_trash' => __('No Orders found in Trash.')
); );
$args = array( $args = array(
'labels' => $labels, 'labels' => $labels,
'description' => __( 'Description.'), 'description' => __('LMS Orders.'),
'public' => false, 'public' => false,
'publicly_queryable' => false, 'publicly_queryable' => false,
'show_ui' => true, 'show_ui' => true,
...@@ -129,13 +298,14 @@ function vq_apex_custom_posts() { ...@@ -129,13 +298,14 @@ function vq_apex_custom_posts() {
'capability_type' => 'post', 'capability_type' => 'post',
'has_archive' => false, 'has_archive' => false,
'hierarchical' => false, 'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail') 'supports' => array('title', 'editor')
); );
register_post_type( 'vq_lms_prequest', $args ); register_post_type('vq_lms_orders', $args);
} }
function vq_apex_custom_taxonomies() { function vq_apex_custom_taxonomies()
{
$labels = array( $labels = array(
'name' => 'LMS Category', 'name' => 'LMS Category',
'add_new_item' => 'Add New LMS Category', 'add_new_item' => 'Add New LMS Category',
...@@ -150,22 +320,25 @@ function vq_apex_custom_taxonomies() { ...@@ -150,22 +320,25 @@ function vq_apex_custom_taxonomies() {
'show_ui' => true, 'show_ui' => true,
'show_tagcloud' => false, 'show_tagcloud' => false,
'hierarchical' => true, 'hierarchical' => true,
'rewrite' => array( 'slug' => 'e-learning', 'with_front' => false ), 'rewrite' => array('slug' => 'e-learning', 'with_front' => false),
) )
); );
} }
function vq_add_lms_navigation($items, $args) { 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>'; {
$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; return $items;
} }
function vq_query_vars_filter( $vars ){ function vq_query_vars_filter($vars)
{
$vars[] = "course"; $vars[] = "course";
return $vars; return $vars;
} }
function vq_render_short_banner($attr) { function vq_render_short_banner($attr)
{
$bgColor = isset($attr['bgclr']) ? $attr['bgclr'] : "#000"; $bgColor = isset($attr['bgclr']) ? $attr['bgclr'] : "#000";
$btnBg = isset($attr['btnbg']) ? $attr['btnbg'] : "#00f"; $btnBg = isset($attr['btnbg']) ? $attr['btnbg'] : "#00f";
...@@ -192,10 +365,11 @@ function vq_render_short_banner($attr) { ...@@ -192,10 +365,11 @@ function vq_render_short_banner($attr) {
} }
function vq_render_course_banner($attr) { function vq_render_course_banner($attr)
{
if(!isset($attr['id'])) { if (!isset($attr['id'])) {
return 'No Course Found'; return 'No Course Found';
} else { } else {
$cid = $attr['id']; $cid = $attr['id'];
...@@ -205,7 +379,7 @@ function vq_render_course_banner($attr) { ...@@ -205,7 +379,7 @@ function vq_render_course_banner($attr) {
$fee = get_post_meta($page->ID, 'course_fee', true); $fee = get_post_meta($page->ID, 'course_fee', true);
if(empty($fee) || $fee <= 0) { if (empty($fee) || $fee <= 0) {
$settings = get_option('vq_lms_settings_options'); $settings = get_option('vq_lms_settings_options');
$fee = $settings['vq_lms_settings_field_general_price']; $fee = $settings['vq_lms_settings_field_general_price'];
} }
......
<?php <?php
$lmsVersion = "0.3"; $lmsVersion = "0.4";
add_action('wp_enqueue_scripts', 'enqueue_admin_css'); add_action('wp_enqueue_scripts', 'enqueue_admin_css');
add_filter('template_include', 'use_lms_template', 99); add_filter('template_include', 'use_lms_template', 99);
......
...@@ -665,3 +665,8 @@ ...@@ -665,3 +665,8 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; 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); ...@@ -36,7 +36,7 @@ $courses = new WP_Query($args);
<?php the_post_thumbnail('thumbnail') ?> <?php the_post_thumbnail('thumbnail') ?>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="course-heading"> <div class="course-heading" style="max-height: 105px; overflow: hidden;">
<h3><?php the_title(); ?> </h3> <h3><?php the_title(); ?> </h3>
<?php the_content(); ?> <?php the_content(); ?>
</div> </div>
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
courseLearner[course.id].forEach(function (learner, index) { courseLearner[course.id].forEach(function (learner, index) {
var lmsSummerySingleElem = $(lmsSummerySingleLearner); var lmsSummerySingleElem = $(lmsSummerySingleLearner);
lmsSummerySingleElem.find(".index").html(index + 1); 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(".email").html(learner.email);
lmsSummerySingleElem.find(".phone").html(learner.phone); lmsSummerySingleElem.find(".phone").html(learner.phone);
lmsSummerySingleElem.find(".price").html(course.cost + " " + lmsSettings.vq_lms_settings_field_currency_symbol); lmsSummerySingleElem.find(".price").html(course.cost + " " + lmsSettings.vq_lms_settings_field_currency_symbol);
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
learners.forEach(function (item, index) { learners.forEach(function (item, index) {
var learnerFormElement = $(learnerFormTemplate); var learnerFormElement = $(learnerFormTemplate);
learnerFormElement.find(".lmsIndex").html(index + 1); 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='email']").val(item.email);
learnerFormElement.find("input[name='confirmEmail']").val(item.confirmEmail); learnerFormElement.find("input[name='confirmEmail']").val(item.confirmEmail);
learnerFormElement.find("input[name='phone']").val(item.phone); learnerFormElement.find("input[name='phone']").val(item.phone);
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
function addEmptyLearner() { function addEmptyLearner() {
var lerner = { var lerner = {
name: "", fname: "",
email: "", email: "",
confirmEmail: "", confirmEmail: "",
phone: "", phone: "",
...@@ -177,14 +177,46 @@ ...@@ -177,14 +177,46 @@
lmsCheckoutForm.submit(function (e) { lmsCheckoutForm.submit(function (e) {
e.preventDefault();
var paymentBtn = $("#lmsProcessPayment");
var learnersWithNoCourse = learners.filter(function (learner) { var learnersWithNoCourse = learners.filter(function (learner) {
return learner.courses.length === 0; return learner.courses.length === 0;
}); });
var learnersMismatchEmails = learners.filter(function (learner) {
return learner.email !== learner.confirmEmail;
});
if (learnersWithNoCourse.length > 0) { if (learnersWithNoCourse.length > 0) {
alert("Please select courses with all learners."); 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); })(jQuery);
\ No newline at end of file
...@@ -5,6 +5,10 @@ $courses = new WP_Query(array('post_type' => 'vq_course')); ...@@ -5,6 +5,10 @@ $courses = new WP_Query(array('post_type' => 'vq_course'));
while (have_posts()): while (have_posts()):
the_post(); 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="bootstrap-iso">
<div class="e-learning-banner"> <div class="e-learning-banner">
<div class="container"> <div class="container">
...@@ -60,7 +64,8 @@ while (have_posts()): ...@@ -60,7 +64,8 @@ while (have_posts()):
</div> </div>
</div> </div>
<div class="col-sm-12"> <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> </div>
</div> </div>
...@@ -78,7 +83,7 @@ while (have_posts()): ...@@ -78,7 +83,7 @@ while (have_posts()):
</div> </div>
<div class="col-sm-8 col-padding"> <div class="col-sm-8 col-padding">
<input class="form-control text-feild" placeholder="Name" <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" <input class="form-control text-feild" placeholder="Email"
maxlength="200" type="email" name="email" required /> maxlength="200" type="email" name="email" required />
<input class="form-control text-feild" placeholder="Confirm Email" <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