Commit 0ab6c275 by Muhammad Usman

promo working

parent c5c9ae5c
Pipeline #315 passed with stage
in 0 seconds
......@@ -100,6 +100,11 @@ function vq_lms_process_order()
}
$data = json_decode(stripslashes($_POST['data']), true);
$code = "";
if(isset($data['pcode'])) {
$code = $data['pcode'];
}
print_r(json_decode($_POST));
if (count($data['data']) === 0) {
echo "Unable to process your request";
......@@ -144,6 +149,34 @@ function vq_lms_process_order()
}
}
if($code != ""){
$val = -1;
$terms = get_terms(array(
'taxonomy' => 'vq_course_promo',
'hide_empty' => false,
));
foreach($terms as $term) {
if($code === $term->name) {
$val = get_term_meta($term->term_id, 'vq_course_promo_value', true);
}
}
if($val != -1) {
$discount = (($val/100) * $totalCost) * -1;
$itemsXML .= "<Items><itemname> Discount ({$val}%) </itemname><quantity>1</quantity><amount>". number_format($discount, 2) ."</amount></Items>";
$postContent .= "<b>Discount ({$val}%)</b>: " .number_format((float)$discount,2, '.', '')."<br />";
$totalCost += $discount;
}
}
if($oid > 0) {
$post = array(
'ID' => $oid,
......
......@@ -74,7 +74,7 @@
});
if(promoValue > 0) {
totalCost = ((100 - promoValue)/100) * totalCost;
totalCost = Math.ceil(((100 - promoValue)/100) * totalCost);
}
});
......@@ -231,6 +231,7 @@
var data = {};
data.data = learners;
data.pcode = $("#pcode-value").val();
data.id = parseInt(pid);
......
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