Commit d6b233b2 by Muhammad Usman

promo fix

parent 0ab6c275
...@@ -122,6 +122,24 @@ function vq_lms_process_order() ...@@ -122,6 +122,24 @@ 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);
}
}
}
foreach ($data as $user) { foreach ($data as $user) {
$coursesId = array_column($user['courses'], "id"); $coursesId = array_column($user['courses'], "id");
...@@ -137,7 +155,9 @@ function vq_lms_process_order() ...@@ -137,7 +155,9 @@ function vq_lms_process_order()
echo "Unable to process your request"; echo "Unable to process your request";
die; die;
} }
if($val != -1 ) {
$cost = ceil(((100 - $val)/100) * $cost);
}
$totalCost += floatval($cost); $totalCost += floatval($cost);
$itemsXML .= "<Items><itemname>".$item."</itemname><quantity>1</quantity><amount>".number_format((float)$cost, $itemsXML .= "<Items><itemname>".$item."</itemname><quantity>1</quantity><amount>".number_format((float)$cost,
2, '.', '')."</amount></Items>"; 2, '.', '')."</amount></Items>";
...@@ -149,32 +169,6 @@ function vq_lms_process_order() ...@@ -149,32 +169,6 @@ 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) { if($oid > 0) {
......
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