Jump to content

Edit History

hakeryk2

hakeryk2


found a solution

Hello,

Is there any possibility to change selected combination to a different one by passing only id of this combination?
There is a variable combinationsFromController which contains basically all informations needed to change selected value (attributes, attributes group) but this is just to overwhelming to determine if product has only color change, input radios, selects and what if there is more than 1 groups of attributes.

This should be in Presta but maybe I can't find it.

Otherwise - maybe someone will create this function :)

Edit: Ok, I made it by myself. Now changing this will be much easier :) 
If I helped please submit Thanks!


 

function selectAttributeByCombinationId(combination_id)
{
	if (typeof combinationsFromController[combination_id] == 'undefined')
		return false;

	var c = combinationsFromController[combination_id];
	var i = 0;
	c.attribute_select = [];

	// prepare easier in use temp array for each selector with group assigned
	$.each(c.attributes_values, function(k){
		c.attribute_select[k] = c.attributes[i];
		i++;
	});

	$.each(c.attribute_select, function(k,v){
		$('#color_' + v).addClass('selected').parent().addClass('selected');
		$('input:radio[value=' + v + ']').prop('checked', true);
		$('input[type=hidden][name=group_' + k + ']').val(v);
		$('select[name=group_' + k + ']').val(v);
	});
	findCombination();
	getProductAttribute();
}



 

hakeryk2

hakeryk2

Hello,

Is there any possibility to change selected combination to a different one by passing only id of this combination?
There is a variable combinationsFromController which contains basically all informations needed to change selected value (attributes, attributes group) but this is just to overwhelming to determine if product has only color change, input radios, selects and what if there is more than 1 groups of attributes.

This should be in Presta but maybe I can't find it.

Otherwise - maybe someone will create this function :)

×
×
  • Create New...