what happens when add to cart button clicks in opencart -


can please tell me, function execute when click on 'add cart' button in store front? code or method execute when add cart button clicked? observed there calculations takes place.

in view/theme/*/template/product/product.tpl

 <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />           &nbsp;           <input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" /> 

in javascript

<script type="text/javascript"><!-- $('#button-cart').bind('click', function() {     $.ajax({         url: 'index.php?route=checkout/cart/add',         type: 'post',         data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),         datatype: 'json',         success: function(json) {             $('.success, .warning, .attention, information, .error').remove();              if (json['error']) {                 if (json['error']['option']) {                     (i in json['error']['option']) {                         $('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');                     }                 }             }              alert(json['success']);             if (json['success']) {                 $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/palioxis/image/close.png" alt="" class="close" /></div>');                  $('.success').fadein('slow');                  $('#cart-total').html(json['total']);                  $('html, body').animate({ scrolltop: 0 }, 'slow');              }            }     }); }); //--></script> 

can brief happens here?

the jquery code looks button id, 'button-cart'.

once clicked, runs ajax code below. data transmitted route=checkout/cart/add url.

the file calls /controller/checkout/cart.php file , looks add() function. data pass add() function 'data'.

then if data passed correctly, jquery code prompt alert message json['success'] , load div layer.

otherwise, if data not passed correctly, give error message on page.

let me know if helps understand it. use opencart.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -