Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apex_micro_site
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Ali Arshad
apex_micro_site
Commits
5e70005d
Commit
5e70005d
authored
Jan 24, 2018
by
Muhammad Usman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order update
parent
99d6176c
Pipeline
#222
passed with stage
in 0 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
16 deletions
+166
-16
handle-metaboxes.php
...ontent/plugins/apex_global_lms/admin/handle-metaboxes.php
+30
-0
handle-post.php
.../wp-content/plugins/apex_global_lms/admin/handle-post.php
+27
-0
order-info.html
...nt/plugins/apex_global_lms/admin/includes/order-info.html
+16
-0
styles.css
...A/wp-content/plugins/apex_global_lms/admin/src/styles.css
+9
-0
functions.php
WWW_DATA/wp-content/plugins/apex_global_lms/functions.php
+46
-10
lms.js
...ATA/wp-content/plugins/apex_global_lms/template/js/lms.js
+25
-6
learner-detail.php
...ntent/plugins/apex_global_lms/template/learner-detail.php
+13
-0
No files found.
WWW_DATA/wp-content/plugins/apex_global_lms/admin/handle-metaboxes.php
View file @
5e70005d
...
@@ -58,5 +58,35 @@ function vq_add_custom_meta_boxes() {
...
@@ -58,5 +58,35 @@ function vq_add_custom_meta_boxes() {
'high'
'high'
);
);
add_meta_box
(
'vq_lms_orders_meta_box'
,
'Order Information'
,
'vq_render_lms_order_metabox'
,
'vq_lms_orders'
,
'normal'
,
'default'
);
}
}
function
vq_render_lms_order_metabox
()
{
$price
=
get_post_meta
(
get_the_ID
(),
'total_amount'
,
true
);
$payment_status
=
get_post_meta
(
get_the_ID
(),
'payment_status'
,
true
);
if
(
$price
==
null
)
$price
=
""
;
if
(
$payment_status
==
null
)
$payment_status
=
"IN QUEUE"
;
wp_enqueue_style
(
'vq-lms-admin-custom'
,
plugin_dir_url
(
__FILE__
)
.
'src/styles.css'
);
$file
=
file_get_contents
(
__DIR__
.
'/includes/order-info.html'
);
$file
=
str_replace
(
'[[PRICE]]'
,
$price
,
$file
);
$file
=
str_replace
(
'[[PAY_STAT]]'
,
$payment_status
,
$file
);
echo
$file
;
}
WWW_DATA/wp-content/plugins/apex_global_lms/admin/handle-post.php
View file @
5e70005d
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
add_action
(
'save_post_vq_course'
,
'vq_handle_course_post'
);
add_action
(
'save_post_vq_course'
,
'vq_handle_course_post'
);
add_action
(
'save_post_vq_lms_orders'
,
'vq_handle_order_post'
);
add_action
(
'manage_vq_lms_orders_posts_custom_column'
,
'vq_render_order_columns_data'
,
10
,
2
);
add_filter
(
'manage_vq_lms_orders_posts_columns'
,
'vq_render_order_columns'
);
function
vq_handle_course_post
()
{
function
vq_handle_course_post
()
{
if
(
isset
(
$_POST
[
'course_attachment_id'
]))
{
if
(
isset
(
$_POST
[
'course_attachment_id'
]))
{
...
@@ -17,4 +20,27 @@ function vq_handle_course_post() {
...
@@ -17,4 +20,27 @@ function vq_handle_course_post() {
if
(
isset
(
$_POST
[
'course_fee'
]))
{
if
(
isset
(
$_POST
[
'course_fee'
]))
{
update_post_meta
(
get_the_ID
(),
'course_fee'
,
$_POST
[
'course_fee'
]);
update_post_meta
(
get_the_ID
(),
'course_fee'
,
$_POST
[
'course_fee'
]);
}
}
}
function
vq_handle_order_post
()
{
$price
=
isset
(
$_POST
[
'price'
])
?
$_POST
[
'price'
]
:
''
;
$payment_status
=
isset
(
$_POST
[
'payment_status'
])
?
$_POST
[
'payment_status'
]
:
''
;
update_post_meta
(
get_the_ID
(),
'price'
,
$price
);
update_post_meta
(
get_the_ID
(),
'payment_status'
,
$payment_status
);
}
function
vq_render_order_columns
(
$columns
)
{
$new_columns
=
array
(
'price'
=>
'Cost'
,
'payment_status'
=>
'Payment Status'
,
);
return
array_merge
(
$columns
,
$new_columns
);
}
function
vq_render_order_columns_data
(
$column
,
$post_id
)
{
echo
get_post_meta
(
$post_id
,
$column
,
true
);
}
}
\ No newline at end of file
WWW_DATA/wp-content/plugins/apex_global_lms/admin/includes/order-info.html
0 → 100644
View file @
5e70005d
<h5>
Order Info
</h5>
<div
class=
"order-info-form"
>
<div
class=
"field"
>
<label
for=
""
>
Price:
</label>
<input
type=
"number"
name=
"price"
class=
"form-control"
value=
"[[PRICE]]"
/>
</div>
<div
class=
"field"
>
<label
for=
""
>
Payment Status:
</label>
<input
type=
"text"
name=
"payment_status"
class=
"form-control"
value=
"[[PAY_STAT]]"
/>
</div>
</div>
WWW_DATA/wp-content/plugins/apex_global_lms/admin/src/styles.css
0 → 100644
View file @
5e70005d
.field
{
display
:
flex
;
margin-bottom
:
8px
;
}
.field
label
{
width
:
110px
;
}
\ No newline at end of file
WWW_DATA/wp-content/plugins/apex_global_lms/functions.php
View file @
5e70005d
...
@@ -24,6 +24,8 @@ add_filter('wp_nav_menu_items', 'vq_add_lms_navigation', 10, 2);
...
@@ -24,6 +24,8 @@ 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_filter
(
'single_template'
,
'vq_render_order_single_page'
,
10
,
2
);
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'
);
...
@@ -41,7 +43,7 @@ function vq_lms_process_order()
...
@@ -41,7 +43,7 @@ function vq_lms_process_order()
$data
=
json_decode
(
stripslashes
(
$_POST
[
'data'
]),
true
);
$data
=
json_decode
(
stripslashes
(
$_POST
[
'data'
]),
true
);
if
(
count
(
$data
)
===
0
)
{
if
(
count
(
$data
[
'data'
]
)
===
0
)
{
echo
"Unable to process your request"
;
echo
"Unable to process your request"
;
die
;
die
;
}
}
...
@@ -52,6 +54,11 @@ function vq_lms_process_order()
...
@@ -52,6 +54,11 @@ function vq_lms_process_order()
$totalCost
=
0
;
$totalCost
=
0
;
$postContent
=
"<h2>Items:</h2>"
;
$postContent
=
"<h2>Items:</h2>"
;
$oid
=
$data
[
'id'
];
$data
=
$data
[
'data'
];
foreach
(
$data
as
$user
)
{
foreach
(
$data
as
$user
)
{
$coursesId
=
array_column
(
$user
[
'courses'
],
"id"
);
$coursesId
=
array_column
(
$user
[
'courses'
],
"id"
);
...
@@ -79,12 +86,30 @@ function vq_lms_process_order()
...
@@ -79,12 +86,30 @@ function vq_lms_process_order()
}
}
}
}
wp_insert_post
(
array
(
if
(
$oid
>
0
)
{
"post_content"
=>
$postContent
,
$post
=
array
(
"post_title"
=>
date
(
"Y-m-d h:i:sa"
),
'ID'
=>
$oid
,
"post_type"
=>
"vq_lms_orders"
,
'post_content'
=>
$postContent
,
"post_status"
=>
"publish"
"post_title"
=>
date
(
"Y-m-d h:i:sa"
),
));
"post_type"
=>
"vq_lms_orders"
,
"post_status"
=>
"publish"
);
wp_update_post
(
$post
);
}
else
{
$oid
=
wp_insert_post
(
array
(
"post_content"
=>
$postContent
,
"post_title"
=>
date
(
"Y-m-d h:i:sa"
),
"post_type"
=>
"vq_lms_orders"
,
"post_status"
=>
"publish"
));
}
update_post_meta
(
$oid
,
'order_data'
,
$data
);
$learner
=
$data
[
0
];
$learner
=
$data
[
0
];
$name
=
explode
(
' '
,
$learner
[
'fname'
]);
$name
=
explode
(
' '
,
$learner
[
'fname'
]);
...
@@ -104,6 +129,8 @@ function vq_lms_process_order()
...
@@ -104,6 +129,8 @@ function vq_lms_process_order()
$_clientip
=
$_SERVER
[
'REMOTE_ADDR'
];
$_clientip
=
$_SERVER
[
'REMOTE_ADDR'
];
$_amount
=
number_format
((
float
)
$totalCost
,
2
,
'.'
,
''
);
// kindly set this to the total amount of the
$_amount
=
number_format
((
float
)
$totalCost
,
2
,
'.'
,
''
);
// kindly set this to the total amount of the
update_post_meta
(
$oid
,
'total_amount'
,
$_amount
);
// transaction. Set the amount to 2 decimal
// transaction. Set the amount to 2 decimal
// point before generating signature.
// point before generating signature.
$_currency
=
$options
[
'vq_lms_settings_field_currency_symbol'
];
$_currency
=
$options
[
'vq_lms_settings_field_currency_symbol'
];
...
@@ -292,12 +319,12 @@ function vq_apex_custom_posts()
...
@@ -292,12 +319,12 @@ function vq_apex_custom_posts()
$args
=
array
(
$args
=
array
(
'labels'
=>
$labels
,
'labels'
=>
$labels
,
'description'
=>
__
(
'LMS Orders.'
),
'description'
=>
__
(
'LMS Orders.'
),
'public'
=>
fals
e
,
'public'
=>
tru
e
,
'publicly_queryable'
=>
fals
e
,
'publicly_queryable'
=>
tru
e
,
'show_ui'
=>
true
,
'show_ui'
=>
true
,
'show_in_menu'
=>
"edit.php?post_type=vq_course"
,
'show_in_menu'
=>
"edit.php?post_type=vq_course"
,
'query_var'
=>
true
,
'query_var'
=>
true
,
'rewrite'
=>
false
,
'rewrite'
=>
array
(
'slug'
=>
'order'
)
,
'capability_type'
=>
'post'
,
'capability_type'
=>
'post'
,
'has_archive'
=>
false
,
'has_archive'
=>
false
,
'hierarchical'
=>
false
,
'hierarchical'
=>
false
,
...
@@ -409,3 +436,11 @@ function vq_render_inquiry_form() {
...
@@ -409,3 +436,11 @@ function vq_render_inquiry_form() {
return
$file
;
return
$file
;
}
}
function
vq_render_order_single_page
(
$single_template
)
{
global
$post
;
if
(
$post
->
post_type
==
'vq_lms_orders'
)
{
$single_template
=
dirname
(
__FILE__
)
.
'/template/learner-detail.php'
;
}
return
$single_template
;
}
\ No newline at end of file
WWW_DATA/wp-content/plugins/apex_global_lms/template/js/lms.js
View file @
5e70005d
...
@@ -9,7 +9,17 @@
...
@@ -9,7 +9,17 @@
var
lmsSummerySingleLearner
=
$
(
"#lmsSummerySingleLearner"
).
html
();
var
lmsSummerySingleLearner
=
$
(
"#lmsSummerySingleLearner"
).
html
();
var
addLearnerBtn
=
$
(
"#lms-add-learner"
);
var
addLearnerBtn
=
$
(
"#lms-add-learner"
);
var
learners
=
[];
var
learners
=
[];
var
status
=
'PENDING'
;
var
pid
=
-
1
;
window
.
initializeLearners
=
function
(
obj
,
oid
,
ostatus
)
{
learners
=
obj
;
pid
=
oid
;
status
=
ostatus
;
renderLearnersPage
();
};
function
renderLearnersPage
()
{
function
renderLearnersPage
()
{
renderLearnersForm
();
renderLearnersForm
();
...
@@ -199,13 +209,18 @@
...
@@ -199,13 +209,18 @@
return
;
return
;
}
}
var
data
=
{};
data
.
data
=
learners
;
data
.
id
=
parseInt
(
pid
);
paymentBtn
.
html
(
"Please wait."
);
paymentBtn
.
html
(
"Please wait."
);
paymentBtn
.
addClass
(
"disabled"
);
paymentBtn
.
addClass
(
"disabled"
);
$
.
post
(
ajaxurl
,
{
$
.
post
(
ajaxurl
,
{
action
:
"processOrder"
,
action
:
"processOrder"
,
data
:
JSON
.
stringify
(
learners
)
data
:
JSON
.
stringify
(
data
)
},
function
(
data
){
},
function
(
data
){
if
(
data
==
"Unable to process your request"
){
if
(
data
==
"Unable to process your request"
){
alert
(
data
);
alert
(
data
);
...
@@ -221,9 +236,12 @@
...
@@ -221,9 +236,12 @@
var
courseList
=
$
(
"#course_list"
);
var
courseList
=
$
(
"#course_list"
);
courseList
.
html
(
""
);
courseList
.
html
(
""
);
crsList
.
forEach
(
function
(
item
)
{
if
(
typeof
crsList
!=
'undefined'
)
{
var
option
=
"<option value='"
+
item
+
"'>"
+
item
+
"</option>"
;
crsList
.
forEach
(
function
(
item
)
{
courseList
.
append
(
option
);
var
option
=
"<option value='"
+
item
+
"'>"
+
item
+
"</option>"
;
});
courseList
.
append
(
option
);
});
}
})(
jQuery
);
})(
jQuery
);
\ No newline at end of file
WWW_DATA/wp-content/plugins/apex_global_lms/template/learner-detail.php
View file @
5e70005d
<?php
<?php
get_header
();
get_header
();
$lmsSettings
=
get_option
(
"vq_lms_settings_options"
);
$lmsSettings
=
get_option
(
"vq_lms_settings_options"
);
$orderData
=
get_post_meta
(
get_the_ID
(),
'order_data'
,
true
);
if
(
count
(
$orderData
)
>
0
&&
$orderData
!=
""
)
{
$id
=
get_the_ID
();
$status
=
get_post_meta
(
get_the_ID
(),
'payment_status'
,
true
);
echo
"<script>
var orderData = "
.
json_encode
(
$orderData
)
.
";
var id = '"
.
$id
.
"';
var status = '"
.
$status
.
"';
jQuery(document).ready(function() {
initializeLearners(orderData, id, status);
});
</script>"
;
}
$courses
=
new
WP_Query
(
array
(
'post_type'
=>
'vq_course'
));
$courses
=
new
WP_Query
(
array
(
'post_type'
=>
'vq_course'
));
while
(
have_posts
())
:
while
(
have_posts
())
:
the_post
();
the_post
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment