Skip to content Skip to sidebar Skip to footer

Opencart Add Product Options To Opencart

My cart appears to be working except the product options. When I click add cart button then the item gets added, but no options are added with it. I really don't understand why thi

Solution 1:

First Option($key=>value) where you have passed $key => 13 which should be valid key

in array of Option($key=>$Value) where $key represents product_option_id and $value represents Product_option_value_id of product_option_value table so these should be valid which is assigned dynamically when you assign option to product rather than static id.

**Second** Just use the default method of opencart, this will handle other input type as well

$('#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']) {
                    for (i in json['error']['option']) {
                        $('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
                    }
                }

                if (json['error']['profile']) {
                    $('select[name="profile_id"]').after('<span class="error">' + json['error']['profile'] + '</span>');
                }
            } 

            if (json['success']) {
                $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');

                $('.success').fadeIn('slow');

                $('#cart-total').html(json['total']);

                $('html, body').animate({ scrollTop: 0 }, 'slow'); 
            }   
        }
    });
});

Post a Comment for "Opencart Add Product Options To Opencart"