From bcae0dbd37d3ab2e1603b9b508a4756dc11ed605 Mon Sep 17 00:00:00 2001 From: muthulakshmi Date: Wed, 28 Dec 2022 15:04:09 +0530 Subject: [PATCH] cart summary change to price type --- app/Controllers/Api/Cart/Index.php | 24 +++++++++++++++++------- app/Controllers/Api/Checkout/Index.php | 17 ++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/Controllers/Api/Cart/Index.php b/app/Controllers/Api/Cart/Index.php index 657ffe9..4d2e434 100644 --- a/app/Controllers/Api/Cart/Index.php +++ b/app/Controllers/Api/Cart/Index.php @@ -47,12 +47,11 @@ function index(){ if($post['type']) $condition['type'] = $post['type']; - $cart = new \App\Models\Cart; $result = $this->cart->getCart('all', ['cart', 'event', 'barn', 'stall', 'product', 'tax'], $condition); if($result){ $setting = getSettings(); - $cartreservedtime = $cart->getReserved($setting['cartreservedtime']); + $cartreservedtime = $this->cart->getReserved($setting['cartreservedtime']); $timer = $cartreservedtime ? strtotime($cartreservedtime) : ''; $count = count($result); @@ -168,7 +167,7 @@ function index(){ } } - $transactionfee = number_format((($setting['transactionfee'] / 100) * $price), 2); + $transactionfee = number_format((($setting['transactionfee'] / 100) * $price), 2); $barnstallcolumn = array_column($barnstall, 'barn_id'); array_multisort($barnstallcolumn, SORT_ASC, $barnstall); $rvbarnstallcolumn = array_column($rvbarnstall, 'barn_id'); @@ -178,14 +177,18 @@ function index(){ $shavingcolumn = array_column($shaving, 'product_id'); array_multisort($shavingcolumn, SORT_ASC, $shaving); + $total =''; + $totaldue = (number_format($price,2)+ number_format($transactionfee,2)+ number_format($cleaning_fee,2)); + $resultdata = [ 'event_id' => $event_id, 'event_name' => $event_name, 'event_tax' => $tax, 'event_location' => $event_location, 'event_description' => $event_description, - 'cleaning_fee' => $cleaning_fee, - 'transactionfee' => $transactionfee, + 'cleaning_fee' => number_format($cleaning_fee,2), + 'totaldue' => number_format($totaldue,2), + 'transactionfee' => number_format($transactionfee,2), 'barnstall' => $barnstall, 'rvbarnstall' => $rvbarnstall, 'feed' => $feed, @@ -200,7 +203,7 @@ function index(){ ]; if(count($result)>0){ - $json = ['1', count($resultdata) . ' Record(s) Found', $resultdata]; + $json = ['1', count($result) . ' Record(s) Found', $resultdata]; } else { $json = ['0', 'No Record(s) Found', []]; } @@ -236,6 +239,7 @@ public function stallcartinsert(){ 'type' => 'required', 'checked' => 'required', 'flag' => 'required', + //'mwn_price' => 'required', ], [ @@ -271,10 +275,16 @@ public function stallcartinsert(){ ], 'type' => [ 'required' => 'Type is required.', - ], + ], 'flag' => [ 'required' => 'Flag is required.', ], + 'flag' => [ + 'required' => 'Flag is required.', + ], + /*'mwn_price' => [ + 'required' => 'mwn_price is required.', + ],*/ ] ); diff --git a/app/Controllers/Api/Checkout/Index.php b/app/Controllers/Api/Checkout/Index.php index f42b40b..66c8037 100644 --- a/app/Controllers/Api/Checkout/Index.php +++ b/app/Controllers/Api/Checkout/Index.php @@ -45,7 +45,7 @@ public function index() if($result){ $setting = getSettings(); - $cartreservedtime = $cart->getReserved($setting['cartreservedtime']); + $cartreservedtime = $this->cart->getReserved($setting['cartreservedtime']); $timer = $cartreservedtime ? strtotime($cartreservedtime) : ''; $count = count($result); @@ -160,8 +160,9 @@ public function index() $price += $singletotal; } } - - $transactionfee => number_format((($setting['transactionfee'] / 100) * $price), 2); + + + $transactionfee = number_format((($setting['transactionfee'] / 100) * $price), 2); $barnstallcolumn = array_column($barnstall, 'barn_id'); array_multisort($barnstallcolumn, SORT_ASC, $barnstall); $rvbarnstallcolumn = array_column($rvbarnstall, 'barn_id'); @@ -171,13 +172,16 @@ public function index() $shavingcolumn = array_column($shaving, 'product_id'); array_multisort($shavingcolumn, SORT_ASC, $shaving); + $total =''; + $totaldue = (number_format($price,2)+ number_format($transactionfee,2)+ number_format($cleaning_fee,2)+ number_format(($tax*100),2)); $resultdata = [ 'event_id' => $event_id, 'event_name' => $event_name, - 'event_tax' => $tax, + 'event_tax' => number_format(($tax*100),2), 'event_location' => $event_location, 'event_description' => $event_description, - 'cleaning_fee' => $cleaning_fee, + 'cleaning_fee' => number_format($cleaning_fee,2), + 'totaldue' => number_format($totaldue,2), 'transactionfee' => $transactionfee, 'barnstall' => $barnstall, 'rvbarnstall' => $rvbarnstall, @@ -189,7 +193,7 @@ public function index() 'price' => $price, 'type' => $type, 'timer' => $timer, - 'count' => $count + 'count' => $count, 'paymentmethod' => $paymentmethod, 'stripepublickey' => $setting['stripepublickey'], ]; @@ -245,7 +249,6 @@ public function action(){ 'shaving' => 'required', 'page' => 'required', ], - [ 'firstname' => [ 'required' => 'First Name is required.',