Inhalte aufrufen

Profilbild

Conditional attributes

attributes

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
5 Antworten zu diesem Thema

#1 logipunk

logipunk

    Newbie

  • Members
  • Punkt
  • 3 Beiträge

Geschrieben: 25 March 2014 - 20:34

Hello 

I have a quick question , is it possible to set up a conditional attributes for the product. 
Here is an example , when user clicks on a product he/she will see one of the attributes on a product page for example a question with a radio button (Yes/No) . When user selects 'Yes', a text box will appear , if no it will disappear etc. 

If yes , can you please explain the set up. 

Thanks

Greg

 

 



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 26 March 2014 - 11:53

No, I don't think that this is possible out of the box. You can add attributes of type textbox or multline textbox
but you cannot let them interact with other controls.

Marcus Gesing

Smartstore AG


#3 Michael Herzog

Michael Herzog

    SmartStore AG

  • Administrators
  • 3498 Beiträge

Geschrieben: 26 March 2014 - 14:07

But if you like to make an adaption here you could very easily edit the following file: 

 

SmartStore.Web->Views->Catalog->_ProductAttributes.cshtml

 

We've done something simmiliar very often with the admin-area.

 

For example have a look at:

 

SmartStore.Admin->Views->Product->_CreateOrUpdate.Info.cshtml

 

There we've got some Javascript funtions that handle the toogling of existing elements.

 

Regards


Michael Herzog
Smartstore AG


#4 logipunk

logipunk

    Newbie

  • Members
  • Punkt
  • 3 Beiträge

Geschrieben: 26 March 2014 - 15:43

Hi Mike 

 

Any chance for a code example ? 



#5 Michael Herzog

Michael Herzog

    SmartStore AG

  • Administrators
  • 3498 Beiträge

Geschrieben: 26 March 2014 - 17:27

I've thought of something like this:

<input type="radio" id="element-toggler"></input>
<input type="radio" id="toggled-element"></input>

<script type="text/javascript">
	$(document).ready(function () {
	    toggleMyElement(false);
	});
	function toggleMyElement(editMode) {
		if(editMode){
			$('#toggled-element').show();
		} 
		else {
			$('#toggled-element').hide();
		}
	}
</script>

Michael Herzog
Smartstore AG


#6 logipunk

logipunk

    Newbie

  • Members
  • Punkt
  • 3 Beiträge

Geschrieben: 05 April 2014 - 18:16

Thanks Mike 

 

here is a small code sample if anyone needs to customize their product attributes . 

 

Steps:

1. Create your attributes for your product(s)

2. Using google chrome inspect a element and find out what those attribute names are. 

3. In this example edit _ProductAttribute.cshtml file (any notepad will do)  ....location ...\SmartStoreNET.Web.1.2.1\Views\Catalog

 

<script type="text/javascript">
 
                     $(document).ready(function () { 
 
window.onload = function() {
                        toggleAcl();
                     };
 
                     $('input:radio').live('change', function(){                                      
                              toggleAcl();    
                      });
    @*
                             $('#product_attribute_1_1_1_4').click(function(){
                                 alert(this.value);
toggleAcl(); *@
                         });
 
                         function toggleAcl() {
                             if ($('#product_attribute_1_1_1_4').is(':checked')) {                               
 
$('#product_attribute_1_2_2').show();
$('label[for="product_attribute_1_2_2"]').show();
                                 $('#product_attribute_1_3_3').show();
$('label[for="product_attribute_1_3_3"]').show();
                                 $('#product_attribute_1_3_3_2').show();
$('label[for="product_attribute_1_3_3_2"]').show();
                                 $('#product_attribute_1_3_3_3').show();
$('label[for="product_attribute_1_3_3_3"]').show();
 
                                 
 
 
                         }
                         else {                                
                                 $('#product_attribute_1_2_2').hide();
$('label[for="product_attribute_1_2_2"]').hide();
                                 $('#product_attribute_1_3_3').hide();
$('label[for="product_attribute_1_3_3"]').hide();
                                 $('#product_attribute_1_3_3_2').hide();
$('label[for="product_attribute_1_3_3_2"]').hide();
                                 $('#product_attribute_1_3_3_3').hide();
$('label[for="product_attribute_1_3_3_3"]').hide();
                         }
        }
</script>



Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: attributes