function isiCart() { $json['bool'] = 0; $totalplusdiskon = addslashes($_POST['totalplusdiskon']); $total = addslashes($_POST['total']); $diskon = addslashes($_POST['diskon']); $arr = CartWeb::myCart(); $mm = new MTranDetail(); $mm->detail_date = leap_mysqldate(); $mm->detail_diskon = $diskon; $mm->detail_price = $total; $mm->detail_price_total = $totalplusdiskon; if (MemberLogin::isLogged()) { $mm->detail_macc_id = MemberLogin::getID(); } $mm->detail_ses_id = session_id(); $mm->detail_qty = CartWeb::totalCart(); if ($mm->save()) { foreach ($arr as $obj) { $obj->status = 2; $obj->load = 1; $obj->save(); //update bought $mprod = new MProdModel(); $mprod->getByID($obj->variant_id); $mprod->updateBought(); } session_regenerate_id(); $json['bool'] = 1; } //if sukses echo json_encode($json); die; }
function mycart() { $cartModel = new CartPortal(); $arr = CartWeb::myCart(); // pr($arr); // $mm = new MTranDetail(); // $mm->printColumlistAsAttributes(); if (count($arr) > 0) { $rules = MCPRule::getRules(); $rule2varians = MCPRule::getRules2Variant(); $cart_rules = MCPRCartRule::getRules(); // $cart_rule2varians = MCPRCartRule::getRules2Variant(); // pr($cart_rule2varians); // pr($cart_rules); ?> <!-- <div class="monly" style="margin-top: 80px;"></div>--> <h1 class="tbs">YOUR SHOPPING BAG</h1> <div class="monly"> <?php $pc = new ProductAtCategory(); $total = 0; $totaldiskon = 0; foreach ($arr as $ss) { $obj = new MProdModel(); $obj->getByID($ss->variant_id); $imgurl = $pc->imgURL . $obj->BaseArticleImageFile; if ($obj->BaseArticleImageFile == "") { $imgurl = $pc->noimage; } //durchlaufen disini ..thd rule if (count($rule2varians[$obj->VariantID]) > 0) { $uuss = $rule2varians[$obj->VariantID]; //set icon $obj->rule_icon = _SPPATH . _PHOTOURL . $rules[$uuss[0]]->rule_icon; // pr($uu); //diskon $diskon = 0; foreach ($uuss as $ruleygkena) { $r = $rules[$ruleygkena]; $diskon = max($r->rule_discount, $diskon); } $obj->rule_discount = $diskon; } else { $obj->rule_icon = ""; //default rule icon $obj->rule_discount = 0; } // $totaldiskon += $obj->rule_discount/100*$obj->SellingPrice; $obj->final_price = (100 - $obj->rule_discount) / 100 * $obj->SellingPrice; $total += $ss->qty * $obj->final_price; ?> <div style="background-color: #f6f6f6; padding: 10px; margin: 5px;"> <div class="col-sm-6 col-xs-6" style="text-align: center;"> <img width="100%" src="<?php echo $imgurl; ?> "> <div style="margin-top: 10px; margin-bottom: 10px;"> <?php echo $obj->VariantNameENG; ?> </div> <a onclick="removeFromCart('<?php echo $obj->VariantID; ?> ');" class="remove">remove <i class="glyphicon glyphicon-play"></i></a> </div> <div class="col-sm-6 col-xs-6" style="padding-top: 10px;"> <div class="col-sm-6 col-xs-6" style="text-align: right;line-height: 34px;">Qty </div> <div class="col-sm-6 col-xs-6"> <select onchange="updateQtyCart('<?php echo $obj->VariantID; ?> ',$(this).val());" class="form-control"> <?php for ($x = 1; $x < 10; $x++) { ?> <option <?php if ($ss->qty == $x) { echo "selected"; } ?> value="<?php echo $x; ?> "><?php echo $x; ?> </option> <?php } ?> </select> </div> <div class="clearfix"></div> <div style="text-align: right; margin-top: 20px;"> <?php if ($obj->final_price != $obj->SellingPrice) { ?> Price <br><i class="oldprice" style="font-size: 12px; text-decoration: line-through;"><?php echo idr($obj->SellingPrice); ?> </i><br> <br> <?php } ?> Item Price <br><i class="newprice"><?php echo idr($obj->final_price); ?> </i> </div> </div> <div class="clearfix"></div> <hr class="dotted"> <h3 style="text-align: right;"> IDR <?php echo idr($ss->qty * $obj->final_price); ?> </h3> </div> <?php } ?> </div> <div class="table-responsive donly"> <table class="table tbs table-bordered table-striped"> <thead> <tr> <th> PRODUCT </th> <th>QUANTITY</th> <th>UNIT PRICE</th> <th>TOTAL</th> </tr> </thead> <tbody> <?php $pc = new ProductAtCategory(); $total = 0; $totaldiskon = 0; foreach ($arr as $ss) { $obj = new MProdModel(); $obj->getByID($ss->variant_id); $imgurl = $pc->imgURL . $obj->BaseArticleImageFile; if ($obj->BaseArticleImageFile == "") { $imgurl = $pc->noimage; } //durchlaufen disini ..thd rule if (count($rule2varians[$obj->VariantID]) > 0) { $uuss = $rule2varians[$obj->VariantID]; //set icon $obj->rule_icon = _SPPATH . _PHOTOURL . $rules[$uuss[0]]->rule_icon; // pr($uu); //diskon $diskon = 0; foreach ($uuss as $ruleygkena) { $r = $rules[$ruleygkena]; $diskon = max($r->rule_discount, $diskon); } $obj->rule_discount = $diskon; } else { $obj->rule_icon = ""; //default rule icon $obj->rule_discount = 0; } // $totaldiskon += $obj->rule_discount/100*$obj->SellingPrice; $obj->final_price = (100 - $obj->rule_discount) / 100 * $obj->SellingPrice; $total += $ss->qty * $obj->final_price; ?> <tr> <td> <div class="product_list_item_img_cart"> <img src="<?php echo $imgurl; ?> "> </div> <div class="product_name"> <?php echo $obj->VariantNameENG; ?> </div> </td> <td style="text-align: center;"> <select onchange="updateQtyCart('<?php echo $obj->VariantID; ?> ',$(this).val());" class="form-control"> <?php for ($x = 1; $x < 10; $x++) { ?> <option <?php if ($ss->qty == $x) { echo "selected"; } ?> value="<?php echo $x; ?> "><?php echo $x; ?> </option> <?php } ?> </select> <a onclick="removeFromCart('<?php echo $obj->VariantID; ?> ');" class="remove">remove <i class="glyphicon glyphicon-play"></i></a> </td> <td class="sprice"> <?php if ($obj->final_price != $obj->SellingPrice) { ?> <i class="oldprice" style="font-size: 12px; text-decoration: line-through;"><?php echo idr($obj->SellingPrice); ?> </i><br> <?php } ?> <i class="newprice"><?php echo idr($obj->final_price); ?> </i> </td> <td class="sprice"><?php echo idr($ss->qty * $obj->final_price); ?> </td> </tr> <?php } ?> </tbody> </table> <script> function updateQtyCart(id,qty){ $.post("<?php echo _SPPATH; ?> CartWeb/updateQty",{ id:id,qty:qty },function(data){ // alert(data); if(data.bool){ location.reload(); }else{ alert("Error"); } },'json'); } function removeFromCart(id){ $.post("<?php echo _SPPATH; ?> CartWeb/removeFrom",{ id:id },function(data){ // alert(data); if(data.bool){ location.reload(); }else{ alert("Error"); } },'json'); } </script> </div> <div class="col-md-7" style="padding-right: 0px; padding-left: 0px;"> <div class="col-md-6 col-sm-6 col-xs-6 donly" style="border: 1px solid #dedede; height: 150px;"> <h4 style="color: #E2007A;">Is this a Gift?</h4> <div class="col-md-4 col-sm-6 col-xs-6" style="padding-left: 0px;"> <img width="100%" src="<?php echo _SPPATH; ?> images/bagm_l.jpg"> </div> <div class="col-md-8 col-sm-6 col-xs-6" style="margin-top: 20px;"> <button class="btn btn-success" style="background-color: #7fb719;border-color: #7fb719;">ADD GIFT OPTION</button> </div> </div> <div class="col-md-6 col-sm-6 col-xs-6 donly" style="padding: 0px !important;" > <div style="1px solid #DDEBA9;background-color: #F3FAD9; margin-left: 15px; margin-right: 15px; padding: 10px; height: 150px;"> <h4 style="color: #E2007A; padding: 0; margin: 0; margin-bottom: 10px;">Promotion Codes</h4> <p style="font-size: 12px;">If you have a promotion code, please add it here...</p> <input type="text" class="form-control" placeholder="code" style="width: 100px;display: inline;"> <button class="btn btn-success" style="background-color: #7fb719;vertical-align: top;border-color: #7fb719;">VERIFY CODE</button> </div> </div> <div class="clearfix"></div> <div class="rule_applied" style="<?php if (count($cart_rules) < 1) { echo "display:none;"; } ?> "> <h5 style="margin-top: 0; padding-top: 0;">Applicable Promotions</h5> <?php $numpromo = 0; foreach ($cart_rules as $crules) { if ($crules->rule_apply_to == "by_percent") { if ($total >= $crules->rule_amount_limit) { $numpromo++; ?> *<?php echo $crules->rule_name; ?> <br> <?php } } if ($crules->rule_apply_to == "free_shipping") { if ($total >= $crules->rule_amount_limit) { $numpromo++; ?> *<?php echo $crules->rule_name; ?> <br> <?php } } } ?> </div> <div class="clearfix monly" style="margin-bottom: 10px;"></div> <script> <?php if ($numpromo < 1) { ?> $(document).ready(function(){ $('.rule_applied').hide(); }); <?php } ?> </script> <style> .rule_applied{ margin-top: 10px; background-color: #f6f6f6; padding: 10px; margin-right: 15px; } </style> </div> <div class="col-md-5" style="padding-right: 0px; padding-left: 0px;"> <?php $cartdiskon = 0; $isFreeShipping = 0; foreach ($cart_rules as $crules) { if ($crules->rule_apply_to == "by_percent") { if ($total >= $crules->rule_amount_limit) { $cartdiskon = max($cartdiskon, $crules->rule_discount); } } if ($crules->rule_apply_to == "free_shipping") { if ($total >= $crules->rule_amount_limit) { $isFreeShipping = 1; } } } $cartdikonharga = $cartdiskon / 100 * $total; $totaldiskon = $totaldiskon + $cartdikonharga; ?> <div class="subtotal"> <h4 style="color: #444444;"> <div class="col-md-7 col-sm-6 col-xs-6" style="padding: 0px;"> Subtotal </div> <div class="col-md-5 col-sm-6 col-xs-6" style="padding: 0px;"> IDR <?php echo idr($total); ?> </div> <div class="clearfix"></div> </h4> <h4 style="color: #E2007A;"> <div class="col-md-7 col-sm-6 col-xs-6" style="padding: 0px;"> Extra Discount </div> <div class="col-md-5 col-sm-6 col-xs-6" style="padding: 0px;"> IDR <?php echo idr($totaldiskon); ?> </div><div class="clearfix"></div> </h4> <!-- <h4 style="color: #E2007A;">--> <!-- <div class="col-md-7" style="padding: 0px;">--> <!-- Loyalty Programme Voucher--> <!-- </div>--> <!-- <div class="col-md-5" style="padding: 0px;">--> <!-- IDR 0--> <!-- </div><div class="clearfix"></div>--> <!-- </h4>--> <div class="clearfix"></div> <hr> <h4> <div class="col-md-7 col-sm-6 col-xs-6" style="padding: 0px;"> Delivery </div> <div class="col-md-5 col-sm-6 col-xs-6" style="padding: 0px;"> <select <?php if ($isFreeShipping) { ?> disabled<?php } ?> > <?php if ($isFreeShipping) { ?> <option>Free Delivery IDR 0</option> <?php } ?> <option>delivery1 IDR 30.000</option> <option>cepat IDR 50.000</option> </select> </div><div class="clearfix"></div> </h4> <hr> <h3>Total IDR <?php echo idr($total - $totaldiskon); ?> </h3> </div> <div style="text-align: right; padding-top: 20px;"> <button id="checkoutButton" class="btn btn-success btn-lg" style="background-color: #E2007A;border-color:#E2007A; "> CHECK OUT SECURELY NOW <i class="glyphicon glyphicon-play"></i> </button> <script> $('#checkoutButton').click(function(){ $.post("<?php echo _SPPATH; ?> CartWeb/isiCart",{ totalplusdiskon : <?php echo $total - $totaldiskon; ?> , total : <?php echo $total; ?> , diskon : <?php echo $totaldiskon; ?> },function(data){ if(data.bool){ document.location = "<?php echo _SPPATH; ?> checkout"; } else{ alert("error"); } },'json'); }); </script> </div> </div> <div class="clearfix"></div> <div class="monly" style="margin-top: 30px;"></div> <div class="lanjut"> <a href="<?php echo _SPPATH; ?> ">continue shopping</a> </div> <style> a.remove{ color: #888888; font-size: 12px; cursor: pointer; } .subtotal{ border: 1px solid #BBBBBB;color: #666666; background-color: #EBEBEB; text-align: right; padding-right: 10px; padding-left: 10px;; } .subtotal hr{ border:1px dashed #999999; } .subtotal h4{ font-size: 16px; } h1.tbs{ clear: both; color: #7FB719; margin-top:50px; font: 40px bebasneue,Impact,Charcoal,sans-serif; } .product_list_item_img_cart { width: 80px; height: 80px; overflow: hidden; margin: 5px; text-align: center; float: left; } .product_list_item_img_cart img{ max-width: 100%; max-height: 100%; } .product_name{ margin-left: 100px; height: 90px; font-weight: bold; color: #777777; line-height: 90px; text-overflow: ellipsis; overflow: hidden; /*white-space:nowrap;*/ display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; } table.tbs thead{ background-color: #dedede; } table.tbs thead th{ text-align: center; } .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{ vertical-align: middle; } .sprice{ text-align: right; font-weight: bold; color :#888888; } </style> <?php } else { ?> <h1 style="margin-top: 50px; margin-bottom: 50px; text-align: center">Empty BAG</h1> <?php } }