Subversion Repositories SmartDukaan

Rev

Rev 17524 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<script src="<?=base_url().$this->config->item('current_client')?>/js/cart.js?version=<?=$this->config->item('cdn_version');?>" type="text/javascript"></script>
<script data-pace-options='{ "elements": { "selectors": [".confirm-qty"] }, "startOnPageLoad": false }' src="assets/js/pace.js"></script>
        <?php
        if(isset($carts[0]->lines) && !empty($carts[0]->lines)){
          $cartCount = sizeof($carts[0]->lines);
          if($carts[0]->discountedPrice >=0 && isset($carts[0]->couponCode)){
            $discount = ($carts[0]->totalPrice - $carts[0]->discountedPrice);
            $discount = number_format((float)$discount,0,'.','');
          }
        }
        $authorized = $this->session->userdata('authorized');
        if(isset($authorized['isLoggedIn']) && !empty($authorized['isLoggedIn'])){
          $isLoggedIn = 1;
        }
        else{
          $isLoggedIn = 0;
        }
        if(isset($authorized['pincode']) && !empty($authorized['pincode'])){
          $pinCode = $authorized['pincode'];
        }
        else{
          $pinCode = '';
        }
         
        $shipingCharges = 0;
        $grandTotalPrice = $carts[0]->totalPrice;
        if(isset($discount)){
            $grandTotalPrice = $grandTotalPrice - $discount;
        }
        if(!empty($authorized['isPrivateDealUser'])){
                if($carts[0]->totalPrice < 500){
                    $shipingCharges = 100;
                } elseif($carts[0]->totalPrice >= 500 && $carts[0]->totalPrice <1000){
                    $shipingCharges = 50;
                }
        }
        $grandTotalPrice = $grandTotalPrice + $shipingCharges;
        $cartlineitems = array();
        ?>
        <div class="cart-cont">
          <div id="error" class="error_msg" style="display:none"></div>  
          <?php if(isset($carts[0]->lines) && !empty($carts[0]->lines)){?>
          <div class="cart-head clearfix">
            <div>cart summary(<?php if($cartCount >1){ echo $cartCount.' items)'; } else{ echo $cartCount.' item)';}?> </div>
            <!-- <div>Delivery time for pin: 122001 <a href="#"></a></div> -->
            <div><input type="text" id="pincode" value="<?php echo $pinCode;?>" onKeyDown="if(event.keyCode==13) checkShipping();"/><div onclick="checkShipping()" class="btn">Change Pin</div></div>
          </div><!--cart-head-->
          <?php if(!empty($carts[0]->message) && isset($carts[0]->message)){?>
            <div id="cart-quantity-msg" class="cart-quantity-msg" style="display:block;">
                <?php echo $carts[0]->message;?>
            </div>
             <?php } ?>
            <div id="max-quantity-msg" class="max-quantity-msg" style="display:none;">You can not order more than 20 units of the same product</div>
          <div class="added-pd-hldr">           
          <?php 
           $i=0;
           $notServiceableLocation = 0;
           $item = array();
           foreach($carts[0]->lines as $items){
            array_push($cartlineitems, $items->itemId);
            $theftinsurance = ($items->actualPrice * $items->quantity * $this->config->item('insurance'))/100;
            $theftinsurance = round($theftinsurance);
            $item[$i]['id'] = $items->itemId;
            $item[$i]['quantity'] = $items->quantity;
            $i++;
            if(($items->logisticsInfo->delivery_estimate) && ($items->logisticsInfo->delivery_estimate == -1)){
              $notServiceableLocation++;
            }
            ?>
          <div class="added-pd clearfix">
            <div class="pd-img" style="background:url('<?php echo $items->imageUrl;?>')no-repeat center center;background-size:contain;"></div>
            <div class="pd-info">
              <div class="pd-name">
                <span onclick="removeItem(<?php echo $items->itemId;?>)"class="cancel"></span>
                <div><?php echo $items->name;?></div>
                <?php if(isset($items->color) && !empty($items->color)) {?>
                <div class="spec">Color: <?php echo $items->color;?></div>
                <?php } ?>
                <div id="<?php echo $items->itemId;?>" class="dealdiv spec">
                <?php if(isset($items->dealText) && !empty($items->dealText)):?>
                        <?php echo $items->dealText;?>
                <?php endif; ?>
                </div>
                <div id="<?php echo $items->itemId.'delivery';?>" class="spec" style="display:<?php if(isset($items->logisticsInfo->delivery_estimate) && ($items->logisticsInfo->delivery_estimate != -1)){ echo 'block'; } else {echo 'none';}?>"><?php if(empty($authorized['isPrivateDealUser'])){ ?>Free <?php }?>Delivery by <span id="<?php echo $items->itemId.'del';?>"><?php echo $items->logisticsInfo->delivery_estimate;?></span></div>
                <div id="<?php echo $items->itemId.'otg';?>" class="spec" style="display:<?php if(isset($items->logisticsInfo->on_time_guarantee) && !empty($items->logisticsInfo->on_time_guarantee)){ echo 'block'; } else {echo 'none';}?>"><span>On Time Guarantee</span></div>
                <div id="<?php echo $items->itemId.'cod';?>" class="spec" style="display:<?php if(isset($items->logisticsInfo->is_cod_available_for_location) && ($items->logisticsInfo->is_cod_available_for_location == 1)){ echo 'block'; } else {echo 'none';}?>"><span>You Can Pay By Cash On Delivery</span></div>
                <div id="<?php echo $items->itemId.'service';?>" style="display:<?php if(($items->logisticsInfo->delivery_estimate) && ($items->logisticsInfo->delivery_estimate == -1)){ echo 'block';} else { echo 'none'; }?>">Location is not servicable</div>
              </div>
              
            </div><!--pd-info-->
            <div class="clear"></div>
            
            <div class="insure">
              <?php if($items->isTheftInsuranceAvailable == 1){?>
              <div class="clearfix insure-hldr"><img src="<?php echo base_url().'assets/images/insurance.jpg'; ?>" alt="insurance"/><input class="checkbox" onclick="teftinsure(event)" data-value="<?php echo $items->itemId;?>" data-key="ins" type="checkbox" id="<?php echo $items->itemId.'insurance';?>" <?php if($items->insurer ==1){?> checked="true" <?php } ?>/><label for="<?php echo $items->itemId.'insurance';?>">I want to opt for 1 year WorldWide Theft Insurance for this product for Rs <span id="<?php echo $items->itemId.'theft';?>"><?php echo $theftinsurance;?></span></label></div> 
              <div class="clearfix" <?php if($items->insurer == 1){?> style="display:block" <?php } else { ?> style="display:none" <?php } ?>  id="<?php echo $items->itemId.'tc'?>"><input onclick="teftinsure(event)" data-key="tnc" data-value="<?php echo $items->itemId;?>" type="checkbox" id="<?php echo $items->itemId.'tnc';?>" <?php if($items->insurer ==1){?> checked="true" <?php } ?> /><label for="<?php echo $items->itemId.'tnc';?>">I agree to terms &amp; conditions</label></div>
              <?php } ?>
              <?php if($items->isDataProtectionAvailable == 1){?>
                <div class="one-assist clearfix" ><img src="<?php echo base_url().'assets/images/oneassist.jpg'; ?>" alt="one assist"/><input data-value="<?php echo $items->itemId;?>" type="checkbox" onclick="dataprotection(event)" id="<?php echo $items->itemId.'assist';?>"/ <?php if($items->dataProtectionInsurer == 2){?> checked="true" <?php } ?>> <label for="<?php echo $items->itemId.'assist';?>">I want 90 days SIM-blocking, Temporary Mobile Replacement & Data Backup plan worth</label></div>
              <?php } ?>
            </div>
            <div class="pd-price clearfix">
                <div style="width:20%">
                  <span>Unit Price</span>
                  <div><?php echo $items->actualPrice;?></div>
                </div>
                <span>X</span>
                <div style="width:40%">
                  <span>Enter Qty</span>
                  <input id="qty_<?php echo $items->itemId;?>" type="number" value="<?php echo $items->quantity;?>" min="1" data-value="<?php echo $items->quantity;?>" onfocus="showQtyConfirmButton(<?php echo $items->itemId;?>)" onKeydown="Javascript: if (event.keyCode==13) showQtyConfirmButton(<?php echo $items->itemId;?>);"/>
                  <div id="confirmQty_<?php echo $items->itemId;?>" class="confirm-qty" style="display:none" onclick="updateQuantity(<?php echo $items->itemId;?>,<?php echo $items->quantity;?>)">OK</div>
                </div>
                <div style="width:30%;text-align: center;">
                  <span>Price</span>
                  <div>Rs <?php echo ($items->actualPrice * $items->quantity);?></div>
                </div>
              </div><!--pd-price-->
            </div><!--added-pd-->
            
          <?php } ?>
          <div id="addCoupon" class="add-coupon" <?php if(empty($carts[0]->couponCode)){?> style="display:block" <?php } else { ?> style="display:none" <?php } ?>>
            <div id="coupon-msg" style="display:none"></div>
            <div style="display:none">Have A Coupon Code?</div>
            <div class="clearfix">
            <input onfocus="clearmsg();" id="couponcode" type="text" placeholder="Enter Coupon Code (If Any)"/><div onclick="applycoupon()" class="apply-coupon">Apply</div>
            </div>
          </div>
          <div id="removeCoupon" onclick="clearcoupon('<?php if(isset($couponCode) && !empty($carts[0]->couponCode)) echo $carts[0]->couponCode;?>')" class="remove-coupon" <?php if(isset($carts[0]->couponCode) && !empty($carts[0]->couponCode)){?> style="display:block" <?php } else { ?> style="display:none" <?php } ?>>Remove Coupon: <?php if(isset($carts[0]->couponCode)) {echo $carts[0]->couponCode;}?></div>
          </div>
          
          <div class="sub-total">
                  <div class="sub-total-head">
                cart total
              </div>                            
              
              <div class="left">Total</div><div class="right">Rs <span id="total"><?php echo $carts[0]->totalPrice; ?></span></div>
              <div id="discount" <?php if(isset($discount)){ ?> style="display:block" <?php } else{ ?> style="display:none" <?php }?>><div class="left">Discount</div><div class="right">Rs <span id="discountAmt"><?php if(isset($discount)) {echo $discount;} ?></span></div></div>
              <div id="discountPrice" <?php if($carts[0]->discountedPrice >= 0 && isset($carts[0]->couponCode)){ ?> style="display:block" <?php } else{ ?> style="display:none" <?php }?>><div class="left">Discounted Price</div><div class="right">Rs <span id="discountedPrice"><?php echo $carts[0]->discountedPrice; ?></span></div></div>
              <div class="left">Shipping<?php if(!empty($authorized['isPrivateDealUser']) && $shipingCharges>0): ?><br><span style="color:red;font-size:0.7em">(Free Delivery Above Rs 1000)</span><?php endif;?>
              </div>
              <?php if(empty($authorized['isPrivateDealUser'])): ?>
                      <div class="right">Free</div>
                  <?php else:?>
                          <?php if($shipingCharges==0){?>
                        <div class="right">Free</div>
                      <?php } else{ ?>
                        <div class="right"> Rs <span id="shppingCharges"><?php echo $shipingCharges; ?></span><br><span style="color:red;font-size:0.7em">&nbsp;</span></div>
                      <?php } ?>
                  <?php endif;?>
              <div class="left">Grand Total</div><div class="right">Rs <span id="grandtotal" style="color:red;"><?php echo $grandTotalPrice; ?></span></div>
          </div>
          <div class="checkout-hldr clear">
            <div class="checkout-btn btn" onclick="checkout(<?php echo $isLoggedIn;?>);">
              checkout
            </div>
          </div>
          <?php } else { ?>
            <div class="empty-cart">
              
            </div><!--empty-msg-->
            <p class="empty-msg tcenter">Your Shopping Cart is empty</p>
            
              <div class="shop-more" onclick="shomoreredirect();">
                Shop More
              </div>
              <div class="clear"></div>
            <?php } ?>
            <div>
            <?php
                if(isset($privatedeals['response']['items']) && (!empty($privatedeals['response']['items']))){ 
                        ?>
                        <input type="hidden" id="email" value="<?php echo $authorized['email']?>">
                        <div class="recommended-cart-pd">
                                <div class="head">
                                    <div>Recommended For You</div>
                                    <div id="view-more-deals" style="display:block;" onclick="showMoreDeals()">View More</div>
                                 </div>
                                <div class="rec-cart-hldr" id="swipe_0">
                                <div class="rec-cart-wrapper">
                                <?php foreach ($privatedeals['response']['items'] as $product) {?>
                                <?php if (in_array($product['itemPojos'][0]['id'], $cartlineitems)) 
                                        continue;
                                ?>
                                <input type="hidden" id="<?php echo $product['itemPojos'][0]['id'] ;?>-url" value="<?php echo $product['url'];?>">
                                <div class="rec-cart-product">
                                 <a  href="<?php echo base_url().$product['url'];?>"><img src="<?php echo $product['image_url']; ?>" target="<?php echo base_url().$product['url'];?>" alt="recomended" onerror="imgDefault()"/></a>
                                  <div class="pd-cart-name"><?php echo $product['title']; ?></div>
                                  <div class="pd-cart-desc"><?php echo $product['description']; ?></div>
                                  <div class="pd-cart-price"><span>Rs</span><span><?php if(isset($product['itemPojos'][0]['sellingPrice'])){echo $product['itemPojos'][0]['sellingPrice']; }?> </span><span style="color: red"><?php echo $product['itemPojos'][0]['dealPojo']['dealPrice']; ?></span></div>
                                <div class="quickbuy-hldr clear" onclick="quickAddToCart(<?php echo $product['itemPojos'][0]['id'] ;?>,<?php echo $product['id']; ?>)">
                                <div class="quickbuy-btn btn">
                                        add to cart
                               </div>
                                  </div>
                                </div>
                                <?php } ?>
                                </div>
                                </div><!--rec-hldr-->
                              </div><!--recomended-pd-->
                        <?php
                        }?>
        <script type="text/javascript">
        <?php if(isset($items) && !empty($items)){?>
          var items = <?php echo json_encode($item);?><?php }?>;
        <?php if(isset($notServiceableLocation)){?>
          var notServiceableLocation = <?php echo $notServiceableLocation;?><?php }?>;
        <?php if(isset($item) && !empty($item)):?>
          <?php $itemString = ''?> 
          <?php foreach($item AS $i):?>
          <?php $itemString .= $i['id'].',';?>
          <?php endforeach;?>
          <?php $itemString = substr($itemString, 0, -1);?>
        <?php endif;?>
        var itemString = '<?php echo $itemString;?>';
        /*var referrer = document.referrer.split('/')[3];
        if(referrer && referrer == 'mobile-phones') {
                delete document.referrer;
                document.location = '/cart';
        }*/
        <?php if(isset($carts[0]->message) && !empty($carts[0]->message)):?>
                var coupon = document.getElementById("couponcode").value
                if (coupon.length > 0) {
                        document.getElementById('coupon-msg').innerHTML = '<?php echo $carts[0]->message;?>';
                        document.getElementById('coupon-msg').style.display = 'block';
                        document.getElementById('cart-quantity-msg').style.display = 'none';
                        document.getElementById('cart-quantity-msg').innerHTML = '';
                }else{
                        document.getElementById('cart-quantity-msg').innerHTML = message;
                        document.getElementById('cart-quantity-msg').style.display = 'block';
                }
                document.getElementById('addCoupon').style.display = 'block';
        <?php endif;?>
        </script>