Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addToCart(product_id, quantity, option_id, option_value) {
- quantity = typeof(quantity) != 'undefined' ? quantity : 1;
- option_value = typeof(option_value) != 'undefined' ? option_value : 0;
- option_id = typeof(option_id) != 'undefined' ? option_id : 0;
- jQuery.ajax({
- url: 'index.php?route=checkout/cart/add',
- type: 'post',
- cache: false,
- data: 'product_id=' + product_id + '&quantity=' + quantity + '&option_id=' + option_id + '&option_value=' + option_value+'&rnd=' + Math.random(),
- dataType: 'json',
- success: function(jsonObj) {
- $('.success, .warning, .attention, .information, .error').remove();
- if (jsonObj['redirect']) {
- location = jsonObj['redirect'];
- }
- if (jsonObj['success']) {
- $('#notification').html('<div class="success" style="display: none;">' + jsonObj['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
- $('.success').fadeIn('slow');
- $('#cart-total').html(jsonObj['total']);
- $('html, body').animate({ scrollTop: 0 }, 'slow');
- }
- }
- });
- }
- {"success":"Added to cart!","total":"1 product(s) - 52,48u043bu0432."}
- jsonObj: Object
- success: "Added to cart!"
- total: "1 product(s) - 52.48ะปะฒ."
- __proto__: Object
- $('base').attr('href')
- option_value = typeof(option_value) != 'undefined' ? option_value : 0;
- option_id = typeof(option_id) != 'undefined' ? option_id : 0;
- var base = jQuery('base').attr('href');
- jQuery.ajax({
- url: base + 'index.php?route=checkout/cart/add',
- type: 'post',
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement