Exemplo n.º 1
0
 function add()
 {
     if ($_POST['count'] == 0) {
         $this->error("You did not select any product!");
     }
     //强制登录
     if ($this->memberID <= 0 && GetValue('quickbuy') == 0) {
         if ($this->isAjax()) {
             $data = array('status' => 0, 'info' => 'Please Log on!', 'url' => U('MemberPublic/Login'));
             echo json_encode($data);
             exit;
         } else {
             echo "<script>alert('Please Log on!');location.href='" . U('MemberPublic/Login') . "';</script>";
             exit;
         }
     }
     $dao = D("Cart");
     self::$Model = D("Products");
     $prolist = self::$Model->where("id=" . $_POST['id'])->find();
     $attrlist = self::$Model->get_attrs($prolist['cateid'], $_POST['id']);
     $model = array();
     $i = 0;
     //属性列表
     $attributes = array_keys($_POST['attr']);
     $no_select = array();
     //强制值不为空
     foreach ($attrlist as $key => $value) {
         if (($value['input_type'] == 0 || $value['input_type'] == 1) && in_array($value['name'], $attributes) && $_POST['attr'][$value['name']]) {
             $model[$i]['name'] = $value['name'];
             $attr_value = explode('__', $_POST['attr'][$value['name']]);
             $model[$i]['value'] = $attr_value[0];
             $model[$i]['attr_price'] = $attr_value[1];
             $i++;
         } else {
             $no_select[] = $value['name'];
         }
     }
     if (count($no_select) > 0) {
         $this->error("Please select " . implode(',', $no_select) . '!');
     }
     $dao->add_item($this->sessionID, $_POST['id'], $_POST['count'], serialize($model));
     if ($this->isAjax()) {
         $item_count = itemCount();
         $total_count = TotalCount();
         $price_total = getprice_str(cart_total());
         $data = array('status' => 1, 'info' => "<em class='add_ok'></em><span id='shopping_data'>Add <strong>{$_POST['count']}</strong> items Goods To Cart Successful</span>", 'number_total' => $item_count, 'items_total' => $total_count, 'price_total' => $price_total, 'list' => $dao->cart_list($this->sessionID));
         //$this->success('Shopping Cart <a>'.itemCount().'</a> items quantity <a>'.TotalCount().'</a>.<br/>Total '.getprice_str(cart_total()).'.');
         echo json_encode($data);
         exit;
     } else {
         $this->redirect('Cart/disp');
     }
 }
Exemplo n.º 2
0
 function add()
 {
     if ($_POST['count'] == 0) {
         $this->error("You did not select any product!");
     }
     //强制登录
     /*if ($this->memberID <= 0 && GetSettValue('quickbuy')==0) {
     		echo "<script>alert('Please Log on!');location.href='".U('Member-Public/Login')."';</script>";
     		die;
     		}*/
     $dao = D("Cart");
     self::$Model = D("Products");
     $prolist = self::$Model->where("id=" . $_POST['id'])->find();
     $attrlist = self::$Model->get_attrs($prolist['cateid'], $_POST['id']);
     $model = array();
     $i = 0;
     //属性列表
     $attributes = array_keys($_POST['attr']);
     $no_select = array();
     //强制值不为空
     foreach ($attrlist as $key => $value) {
         if ($value['input_type'] == 1 && in_array($value['name'], $attributes) && $_POST['attr'][$value['name']]) {
             $model[$i]['name'] = $value['name'];
             $attr_value = explode('__', $_POST['attr'][$value['name']]);
             $model[$i]['value'] = $attr_value[0];
             $model[$i]['attr_price'] = $attr_value[1];
             $i++;
         } else {
             $no_select[] = $value['name'];
         }
     }
     if (count($no_select) > 0) {
         $this->error("Please select " . implode(',', $no_select) . '!');
     }
     $dao->add_item($this->sessionID, $_POST['id'], $_POST['count'], serialize($model));
     if ($this->isAjax()) {
         $this->success('Shopping Cart <a>' . itemCount() . '</a> items quantity <a>' . TotalCount() . '</a>.<br/>Total ' . getprice_str(cart_total()) . '.');
     } else {
         $this->redirect('Cart/disp');
     }
 }
Exemplo n.º 3
0
        }
        ?>
        
        
        
        
        <tr>
          <td></td>
          <td><label>
              <?php 
        _e("Total Price");
        ?>
              :</label></td>
          <td  class="cell-shipping-total">
          <?php 
        $print_total = cart_total();
        ?>
          <span class="total_cost"><?php 
        print currency_format($print_total);
        ?>
</span>
          
          </td>
        </tr>
      </tbody>
    </table>
  </div>
  <?php 
    }
    ?>
  <?php 
Exemplo n.º 4
0
                	<div class="left_div">
                	<div class="clearfix"></div>
                	<div class="left_product_area">';
return_cart($user);
echo '</div></div>
		    		<!--left side end here-->';
?>
		
		
    <!--right side start here-->
        <div class="col-xs-12 col-sm-12 col-md-4 col-lg-4 right_div">
            <div class="right_product_area">
                <div class="right_sponsor_area">
                    <ul>
                        <li><h3>Cart total:&nbsp; <b>$<?php 
echo cart_total($user);
?>
</b></h3></li>
                    </ul>
                </div>
            </div>
            <div class="right_product_area">
                <div class="right_product_area_product_cart_faq">
                    <div class="right_product_area_product_cart_inner_faq">
                    	<center><img alt="" src="faq.jpg"></center>
                        <div class="right_product_area_product_cart_inner_faq_text">
                            <h1><center>Need Assistance?</center></h1>

                            <h2><center>Contact Us.</center></h2>

                            <h3>1-800-NUM-FAKE</h3>
    <tr>
	 <td>
    <div id="btn_width">
		<div style="float:left; display:inline;"><a href="###"  onclick="return jQuery.addtocart();" ><img src="../Public/images/button_buy.jpg" alt="" border="0" /></a></div>
		<div style="float:right;"><a href="###"  onclick="jQuery.savecart();" id="savecart" ><img src="../Public/images/button_in_cart.jpg" alt="" border="0"/></a></div>
    </div>
    
	 <div id="cart_info">
    <div id="cart_alert" style="display:none"></div>
				<div id="cart_ok"  style="display:none">
					<img src="../Public/images/add_ok.jpg" border="0" usemap="#Map">
					<span class="cart_ok_content">Shopping Cart <a><?php 
echo itemCount();
?>
</a> items Total <?php 
echo getprice_str(cart_total());
?>
</span>
					<span><a href="###"  onclick="location.href='<?php 
echo U('Cart/disp');
?>
';" ><img src="../Public/images/button_check.jpg" alt="" border="0" /></a>
						<a href="###" onclick="jQuery.hide_cart_ok_content();"><img src="../Public/images/button_shopping.jpg" alt="" border="0" /></a>
					</span>
					
					<map name="Map" id="Map">
					  <area shape="rect" coords="198,-1,214,13" href="###" onclick="jQuery.hide_cart_ok_content();" />
					</map>
				</div>
    </div>
    </td>
Exemplo n.º 6
0
        foreach ($_SESSION['cart'] as $k => $obj) {
            $total += $obj['price'] * $obj['nb'];
            $nb += $obj['nb'];
        }
    }
    $_SESSION['total'] = $total;
    $_SESSION['nbelem'] = $nb;
}
function print_cart_total()
{
    echo '<br />' . number_format($_SESSION['total'], 2, ",", " ") . '$';
}
function print_cart_nb()
{
    echo number_format($_SESSION['nbelem'], 0, ",", " ") . ' items';
}
if (isset($_POST['submit'])) {
    if ($_POST['submit'] == 'add_o') {
        add_cart_obj($_POST['id'], $_POST['nb']);
    } else {
        if ($_POST['submit'] == 'del_o') {
            del_cart_obj($_POST['name']);
        } else {
            if ($_POST['submit'] == 'validate') {
                validate_cart();
            }
        }
    }
}
cart_total();
 public function add_cart()
 {
     $count = I('post.count', 0, 'intval');
     $pid = I('post.id', 0, 'intval');
     $post = $_POST;
     if ($count <= 0) {
         $this->error("You did not select any product.");
     }
     if (empty($pid)) {
         $this->error("Please add goods to cart again.");
     }
     //强制登录
     if ($this->memberID <= 0 && GetValue('quickbuy') == 0) {
         $this->error('Please Log on.', U('MemberPublic/Login'));
     }
     $cartModel = D('Cart');
     $productModel = D('Products');
     $prolist = $productModel->where("id='{$pid}'")->find();
     $attrlist = $productModel->get_attrs($prolist['cateid'], $pid);
     //属性列表
     $i = 0;
     $attributes = array_keys($post['attr']);
     $attr_data = $no_select = array();
     //print_r($attrlist);
     //强制值不为空
     foreach ($attrlist as $k => $v) {
         if (($v['input_type'] == 0 || $v['input_type'] == 1) && in_array($v['name'], $attributes) && $post['attr'][$v['name']]) {
             $attr_data[$i]['name'] = $v['name'];
             $attr_value = explode('__', $post['attr'][$v['name']]);
             $attr_data[$i]['value'] = $attr_value[0];
             $attr_data[$i]['attr_price'] = $attr_value[1];
             $i++;
         } else {
             $no_select[] = $v['name'];
         }
     }
     if (count($no_select) > 0) {
         $this->error("Please select " . implode(',', $no_select) . '.');
     }
     $cartModel->add_item($this->sessionID, $pid, $count, serialize($attr_data));
     if (IS_AJAX) {
         $item_count = itemCount();
         $total_count = TotalCount();
         $price_total = getprice_str(cart_total());
         $data = array('status' => 1, 'info' => "Add {$_POST['count']} items Goods To Cart Successful</span>", 'item_count' => $item_count, 'total_count' => $total_count, 'price_total' => $price_total);
         $this->ajaxReturn($data);
     } else {
         $this->redirect('Cart/index');
     }
 }