Post by cpuricelli » Tue Aug 09, 2011 9:34 pm

Hi all,

I am developing a flash module which will allow users to choose options of the item, then I need the flash object to add the item in the cart with the selected options.

I tryied to generate an add to cart url from flash but it is not working:
index.php?route=checkout/cart/update&product_id=28&quantity=1
or
index.php?route=checkout/cart&product_id=40&quantity=1

Any idea on how to do this?
I am running opencart 1.5

Newbie

Posts

Joined
Tue Aug 09, 2011 8:56 pm

Post by uksitebuilder » Tue Aug 09, 2011 11:33 pm

Do people still us flash ?

You realise Iphone/iPad users wont be able to see flash ?

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by cpuricelli » Wed Aug 10, 2011 4:04 pm

For Iphone/iPad we're developing an HTML5 alternative, we have this flash object which allows users to choose the color and see the color changing in the image, moreover they are able to rotate the image

Newbie

Posts

Joined
Tue Aug 09, 2011 8:56 pm

Post by uksitebuilder » Wed Aug 10, 2011 4:15 pm

well, the add to cart buttons use a javascript onlick event

addToCart('4'); // where 4 is the product_id for simple products (no options)

However, for products with options, the following Ajax is used to post data

Code: Select all

<script type="text/javascript"><!--
$('#button-cart').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/update',
		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']['warning']) {
					$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
				
					$('.warning').fadeIn('slow');
				}
				
				for (i in json['error']) {
					$('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>');
				}
			}	 
						
			if (json['success']) {
				$('#notification').html('<div class="attention" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
					
				$('.attention').fadeIn('slow');
					
				$('#cart_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
		}
	});
});
//--></script>
Haven't tested this, but in theory, you should be able to post json encoded data to: index.php?route=checkout/cart/update to achieve the same result ?

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom
Who is online

Users browsing this forum: No registered users and 71 guests