• 0
Sign in to follow this  
Followers 0
Opuls

Opencart add to cart option

Question

Sveiki. Varbūt kādam ir idejas kā uztaisīt opencart add funkciju priekš groza pievienošanas.

Orģināli ir 

'add': function(product_id, quantity) {
		$.ajax({
			url: 'index.php?route=checkout/cart/add',
			type: 'post',
			data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
			dataType: 'json',
			beforeSend: function() {
				$('#cart > button').button('loading');
			},
			success: function(json) {
				$('.alert, .text-danger').remove();

				$('#cart > button').button('reset');

				if (json['redirect']) {
					location = json['redirect'];
				}

				if (json['success']) {
					$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

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

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

					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}
			}
		});

Bet vajag dabūt klāt vēl option vērtību klāt. 

Option php failā saprot kā array mainīgo.

			if (isset($this->request->post['option'])) {
				$option = array_filter($this->request->post['option']);
			} else {
				$option = array();
			}

Kādas idejas kā nodefinēt ? 

OC 2.0 versija.

Edited by Opuls

Share this post


Link to post
Share on other sites

2 answers to this question

  • 1

Cik man no šī izskatās, postā nav option parametra. Paņem firebug un apskaties, kāds posts aiziet. 

Share this post


Link to post
Share on other sites
  • 0

Paldies par ideju. Uz mozillas nostrādā, arī uz internet explorer aiziet, bet Chrome negrib sagremot... 

Sanāk:

product_id=84&quantity=1&option[264]=111

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0