add_to_cart: function(name, price, attr, image_src) -> how to save php mysql table column / name, price, quantity /

352
March 12, 2017, at 1:28 PM

add_to_cart: function(name, price, attr, image_src) { var self = this;

        if (self.settings.product_image) {
            if (self.settings.currency_after_number === 'true') {
                self.cart.append(
                    '<li class="animated ' + self.settings.animation + '" data-id=' + attr + '>' +
                    '<div class=' + self.settings.cart + '-left>' +
                    '<img src=' + image_src + ' /></div>' +
                    '<div class=' + self.settings.cart + '-body>' +
                    '<span class=' + self.settings.cart + '-name>' + name + '</span>' +
                    '<span class=' + self.settings.cart + '-price>' + price + self.settings.currency + '</span>' +
                    '<input type="number" min="1" value="1" class=' + self.settings.cart + '-input>' +
                    '<button class=' + self.settings.cart + '-remove>&times;</button>' +
                    '</div>' +
                    '</li>');
            }
        }
    }

Save

screenshot

Answer 1

this is pos system, add_to_cart: function(name, price, attr, image_src) - This function value to save STOCK table column / ' + name + ' = product column, ' + price + self.settings.currency + ' = total column, + self.settings.cart + = quantity column /

Answer 2

CREATE TABLE `stock` ( 
  `stock_id` int(11) NOT NULL, 
  `type` longtext, 
  `category` longtext, 
  `sub_category` longtext, 
  `product` longtext, 
  `quantity` longtext, 
  `rate` longtext, 
  `total` longtext, 
  `reason_note` longtext, 
  `datetime` longtext, 
  `sale_id` varchar(30) DEFAULT NULL, 
  `added_by` varchar(50) DEFAULT NULL, 
  `supplier` int(11) DEFAULT NULL, 
  `vendor` longtext, 
  `user` longtext 
) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
 
-- 
-- Dumping data for table `stock` 
-- 
 
INSERT INTO `stock` (`stock_id`, `type`, `category`, `sub_category`, `product`, `quantity`, `rate`, `total`, `reason_note`, `datetime`, `sale_id`, `added_by`, `supplier`, `vendor`, `user`) VALUES 
(79, 'add', '1', '29', '129', '11', '150000.00', '1650000', '', '1452488779', NULL, NULL, 0, '0', NULL), 
(80, 'add', '1', '43', '135', '12', '60000.00', '720000', '', '1454657480', NULL, NULL, 0, '0', NULL), 
(81, 'add', '1', '29', '141', '5', '70000.00', '350000', '', '1454673587', NULL, NULL, 0, '0', NULL), 
(83, 'add', '1', '29', '141', '20', '70000.00', '1400000', '', '1471673212', NULL, NULL, 0, '0', NULL), 
(194, 'destroy', '1', '29', '160', '2', '8000.00', '16000', '', '1489215981', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, NULL), 
(145, 'add', '1', '29', '160', '30', '10000.00', '300000', 'test 30 iig nemlee', '1488775855', NULL, '{"type":"vendor","id":"10"}', 1, NULL, NULL), 
(193, 'destroy', '1', '29', '172', '3', NULL, '1', '', '1489215484', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, NULL), 
(89, 'add', '1', '29', '139', '20', '10000.00', '200000', '', '1481188978', NULL, NULL, 0, '0', NULL), 
(190, 'add', '1', '29', '160', '4', '8000.00', '32000', '', '1489215092', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, NULL), 
(191, 'destroy', '1', '29', '160', '4', NULL, '1', '', '1489215154', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, NULL), 
(148, 'pos', '1', '29', '160', '30', '10000.00', '300000', 'test 30iig avsan', '1488781432', NULL, '{"type":"vendor","id":"10"}', 1, NULL, NULL), 
(192, 'add', '1', '29', '172', '3', '534534.00', '1603602', '', '1489215418', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, NULL), 
(122, 'add', '1', '29', '160', '10', '8000.00', '80000', '', '1486895188', NULL, '{"type":"vendor","id":"10"}', 1, NULL, NULL), 
(187, 'pos', '1', '29', '160', '10', '10000.00', '100000', '', '1489072207', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, '1'), 
(188, 'loan', '1', '29', '160', '22', '10000.00', '220000', '', '1489072855', NULL, '{"type":"vendor","id":"10"}', NULL, '10', NULL), 
(189, 'pos', '1', '29', '160', '2', '10000.00', '20000', '', '1489131556', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, '1'), 
(151, 'pos', '1', '29', '160', '10', '10000.00', '100000', 'test pos new', '1488825372', NULL, '{"type":"vendor","id":"10"}', NULL, NULL, '1'), 
(152, 'add', '1', '29', '160', '10', '10000.00', '100000', 'test 10 new', '1488825417', NULL, '{"type":"vendor","id":"10"}', 1, NULL, NULL);
<style type="text/css"> 
    body { 
        background: #f2f2f2; 
    } 
    li.tgl-menu-btn { 
        display: none; 
    } 
    p.aldaahide { 
        display:none; 
    } 
    .ct-cart-left { 
        display: none; 
    } 
    .ct-cart ol { 
        padding-left: 22px; 
    } 
    .ct-cart li { 
        padding-top: 10px; 
        padding-bottom: 4px; 
        border-bottom: 1px solid #EEE; 
        list-style-type: none; 
    } 
    .ct-cart-name { 
        float: left; 
        margin-left: 8px; 
        width: 328px; 
    } 
    .ct-cart-price { 
        float: left; 
        width: 130px; 
    } 
    input.ct-cart-input { 
        float: left; 
        width: 66px; 
        margin-top: -3px; 
        margin-right: 115px; 
    } 
    .image { 
        height: 100px; 
        overflow: hidden; 
        float: left; 
        margin-right: 0; 
    } 
    .inner { 
        text-align: left; 
    } 
    img.ct-product-image { 
        width: 150px; 
        height: auto; 
    } 
    button.ct-cart-remove { 
        background: url('../template/back/pos/remove.png') no-repeat 0 0; 
        font-size: 0; 
        border-radius: 0; 
    } 
    .ct-cart-total { 
        position: absolute; 
        right: 0; 
        bottom: 0; 
        background: #2f343b; 
        width: 100%; 
        text-align: right; 
        color: #FFF; 
        font-size: 34px; 
        padding-right: 22px; 
        padding-top: 8px; 
        padding-bottom: 8px; 
    } 
    /* Grid List-iin CSS */ 
    .glyphicon { margin-right:5px; } 
    .thumbnail 
    { 
        margin-bottom: 20px; 
        padding: 0px; 
        -webkit-border-radius: 0px; 
        -moz-border-radius: 0px; 
        border-radius: 0px; 
    } 
    .ct-product { 
        padding: 12px; 
    } 
    .ct-product.list-group-item 
    { 
        float: none; 
        width: 100%; 
        background-color: #fff; 
        margin-bottom: 0; 
    } 
    .ct-product.list-group-item:nth-of-type(odd):hover,.ct-product.list-group-item:hover 
    { 
        background: #f2f2f2; 
    } 
 
    .ct-product.list-group-item .list-group-image 
    { 
        margin-right: 10px; 
    } 
    .ct-product.list-group-item .thumbnail 
    { 
        margin-bottom: 0px; 
    } 
    .ct-product.list-group-item .caption 
    { 
        padding: 9px 9px 0px 9px; 
    } 
    .ct-product.list-group-item:nth-of-type(odd) 
    { 
         
    } 
 
    .ct-product.list-group-item:before, .ct-product.list-group-item:after 
    { 
        display: table; 
        content: " "; 
    } 
 
    .ct-product.list-group-item img 
    { 
        float: left; 
        margin-right: 12px; 
    } 
    .ct-product.list-group-item:after 
    { 
        clear: both; 
    } 
    .list-group-item-text 
    { 
        margin: 0 0 11px; 
    } 
    a.listgridview { 
        border-radius: 0; 
        padding: 7px; 
    } 
    .box-header.with-border { 
        border: 0; 
        margin-bottom: 10px; 
    } 
    .list-group-item { 
        border: 0; 
        border-bottom: 1px solid #EEE; 
    } 
</style>
//Model 
 
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
class Pos_model extends CI_Model { 
	public function __construct() 
	{ 
		parent::__construct(); 
	} 
	public function getallcategory() 
	{ 
	    $q = $this->db->query("SELECT * FROM category ORDER BY category_id ASC"); 
 
	    if($q->num_rows() > 0) 
	        return $q->result(); 
	    return false; 
	} 
	public function getallproduct() 
	{ 
	    $q = $this->db->query("SELECT * FROM product ORDER BY product_id ASC"); 
	     
	    if($q->num_rows() > 0) 
	        return $q->result(); 
	    return false; 
	} 
} 
?> 
 
//Controller 
 
<?php  
if (!defined('BASEPATH'))  
    exit('No direct script access allowed'); 
class Pos extends CI_Controller { 
    function __construct() 
    { 
        parent::__construct(); 
        $this->load->database(); 
        $this->load->library('paypal'); 
        /*cache control*/ 
        $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); 
        $this->output->set_header('Pragma: no-cache'); 
        $this->crud_model->ip_data(); 
        $vendor_system   =  $this->db->get_where('general_settings',array('type' => 'vendor_system'))->row()->value; 
        if($vendor_system !== 'ok'){ 
            redirect(base_url(), 'refresh'); 
        } 
    } 
    public function index() 
    { 
    	$this->load->model('Pos_model'); 
    	$page_data['system_title'] = "Test"; 
    	$page_data['system_name'] = "Test"; 
    	$page_data['category'] = $this->Pos_model->getallcategory(); 
    	$page_data['product'] = $this->Pos_model->getallproduct(); 
        $page_data['all_product'] = $this->db->get('product')->result_array(); 
        $this->load->view('back/vendor/pos/add', $page_data); 
    } 
} 
?> 
 
//View, Select a product is inserted into the cart here 
<?php 
                    $i=0; 
                    foreach($all_product as $row){ 
                        if($this->crud_model->is_added_by('product',$row['product_id'],$this->session->userdata('vendor_id'))){ 
                        $i++; 
                ?> 
                    <div class="ct-product col-lg-2 col-md-3 col-xs-6 shop-items filter-add-product noselect text-center"> 
                        <a href="#" class="ct-product-button"> 
                            <div class="image"><img src="<?php echo $this->crud_model->file_view('product',$row['product_id'],'','','thumb','src','multi','one'); ?>" alt="" class="ct-product-image img-responsive"></div> 
                            <div class="inner"> 
                              <span class="ct-product-title title"><?php mb_internal_encoding('UTF-8'); 
                                    echo mb_substr(strip_tags($row['title']) ,0, 40); ?>...</span><br> 
                              <span data-content="<?php echo $row['sale_price']; ?>" class="price"><b class="ct-product-price"><?php echo $row['sale_price']; ?></b> (<b class="ct-product-quantity"><?php echo $row['current_stock']; ?></b>)</span> 
                            </div> 
                        </a> 
                    </div> 
                <?php }} ?>

Answer 3

//This is import to card function 
 
add_to_cart: function(name, price, attr, image_src) { var self = this; 
 
 if (self.settings.product_image) { 
            if (self.settings.currency_after_number === 'true') { 
                self.cart.append( 
                    '<li class="animated ' + self.settings.animation + '" data-id=' + attr + '>' + 
                    '<div class=' + self.settings.cart + '-left>' + 
                    '<img src=' + image_src + ' /></div>' + 
                    '<div class=' + self.settings.cart + '-body>' + 
                    '<span class=' + self.settings.cart + '-name>' + name + '</span>' + 
                    '<span class=' + self.settings.cart + '-price>' + price + self.settings.currency + '</span>' + 
                    '<input type="number" min="1" value="1" class=' + self.settings.cart + '-input>' + 
                    '<button class=' + self.settings.cart + '-remove>&times;</button>' + 
                    '</div>' + 
                    '</li>'); 
            } 
        } 
    }

Rent Charter Buses Company
READ ALSO
checkboxlist multiple selection in db yii2?

checkboxlist multiple selection in db yii2?

Learned a lot about my question, and didn't figure it outI need to write two or more values in the database from checkboxList() In my view activeForm

1662
DataTable - limit view by customer ID in controller

DataTable - limit view by customer ID in controller

I am trying to fix an issue with a client

337
How to Escape the # (Hash, Pound) Symbol in a String with PHP

How to Escape the # (Hash, Pound) Symbol in a String with PHP

I have a string "Imperial Stars #1: The Stars at War" where I need to escape the # symbol as it truncates the HTML output, so you only see "Imperial Stars"Additionally, the return code to the prior page fails because of the truncation

690
Ajax - Check for database update

Ajax - Check for database update

Im making a autobuy systemI have a invoice page that show with default - payment processing

484