Jump to content

Block cart getting updated with default attribute combination


Recommended Posts

Hi,

 

I upload a theme which is compatible with prestashop v1.4.0 ---> 1.4.9 ,i am using prestashop version 1.4.6 My website is a tshirt selling site, i have size attribute with combinations like Small,Medium,Large .

 

I am able to generate combinations for the product but when i add a product with different combinations only the default one is getting displayed in block cart and when i click check out only one the default item is incremented and shown.

 

Please find the attachments below

 

I have added 'Holi Wear 'and 'Facebook like' , 2 tees with different combination , but the default value 'Small' of both the tees are getting incremented in the cart as well as the order page.

 

Can any one help me out which file i should change to sort this out.?post-399817-0-41448900-1375634879_thumb.jpgpost-399817-0-84607800-1375634886_thumb.jpg

Link to comment
Share on other sites

  • 1 month later...

Hi, i don't wanna make new topic so i will write here cause my problem is almost the same but with block cart in main page on right top.

I edit some things in blockcart.tpl just by swap positions html marks, first should be .cart_block_product_name, next .quantity-formated and i deleteted .cart_block_combination_of .

 

The weard thing is that everything is ok when something is already in basket, or i add smth and refresh page i got positioning what i want. But when i add and check basket, it updates to default state and there is description of product and it swaps html marks to default :/

I have no idea why, i change blockcart.tpl in modules/blockcart also in themes theme-name/modules/blockcart and have no idea from where it can take this default html settings.

 

I would appreciate for help.

 

online site right now is on http://www.crystalique.eu , u can add product to basket in main page.

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

if u wanna add/swap/change html markup you must edit in ajax-cart.js, everyting is here:

//display the products witch are in json data but not already displayed
	displayNewProducts : function(jsonData) {

		//add every new products or update displaying of every updated products
		$(jsonData.products).each(function(){
			//fix ie6 bug (one more item 'undefined' in IE6)
			if (this.id != undefined)
			{
				//create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty)
				
				if ($('#cart_block dl.products').length == 0)
				{
					$('#cart_block_no_products').before('<dl class="products"></dl>');
					$('#cart_block_no_products').hide();
				}
				//if product is not in the displayed cart, add a new product's line
				var domIdProduct = this.id + '_' + (this.idCombination ? this.idCombination : '0') + '_' + (this.idAddressDelivery ? this.idAddressDelivery : '0');
				var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');
				if ($('#cart_block_product_'+ domIdProduct).length == 0)
				{
					var productId = parseInt(this.id);
					var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
					var content =  '<dt class="hidden" id="cart_block_product_' + domIdProduct + '">';
					var name = (this.name.length > 12 ? this.name.substring(0, 10) + '...' : this.name);
					content += '<a class="cart_block_product_name" href="' + this.link + '" title="' + this.name + '">' + name + '</a>';
					content += ' <span class="quantity-formated"><span class="quantity">' + this.quantity + '</span></span>';
					
					if (parseFloat(this.price_float) > 0)
						content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&token=' + static_token + (this.hasAttributes ? '&ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
					else
						content += '<span class="remove_link"></span>';
					if (typeof(freeProductTranslation) != 'undefined')
						content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span>';
					content += '</dt>';
					//if (this.hasAttributes)
						  //content += '<dd id="cart_block_combination_of_' + domIdProduct + '" class="hidden"><a href="' + this.link + '" title="' + this.name + '">' + //this.attributes + '</a>';
					if (this.hasCustomizedDatas)
						content += ajaxCart.displayNewCustomizedDatas(this);
					if (this.hasAttributes) content += '</dd>';

					$('#cart_block dl.products').append(content);
				}
				//else update the product's line
				else
				{
					var jsonProduct = this;
					if($.trim($('#cart_block_product_' + domIdProduct + ' .quantity').html()) != jsonProduct.quantity || $.trim($('#cart_block_product_' + domIdProduct + ' .price').html()) != jsonProduct.priceByLine)
					{
						// Usual product
						if (!this.is_gift)
							$('#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine);
						else
							$('#cart_block_product_' + domIdProduct + ' .price').html(freeProductTranslation);
						ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.quantity);

						// Customized product
						if (jsonProduct.hasCustomizedDatas)
						{
							customizationFormatedDatas = ajaxCart.displayNewCustomizedDatas(jsonProduct);
							if (!$('#customization_' + domIdProductAttribute).length)
							{
								if (jsonProduct.hasAttributes)
									$('#cart_block_combination_of_' + domIdProduct).append(customizationFormatedDatas);
								else
									$('#cart_block dl.products').append(customizationFormatedDatas);
							}
							else
							{
								$('#customization_' + domIdProductAttribute).html('');
								$('#customization_' + domIdProductAttribute).append(customizationFormatedDatas);
							}
						}
					}
				}
				$('#cart_block dl.products .hidden').slideDown(450).removeClass('hidden');

			var removeLinks = $('#cart_block_product_' + domIdProduct).find('a.ajax_cart_block_remove_link');
			if (this.hasCustomizedDatas && removeLinks.length)
				$(removeLinks).each(function() {
					$(this).remove();
				});
			}
		});
	},
Link to comment
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
×
×
  • Create New...