Developer forum

Forum » Development » toggle 'buy' button

toggle 'buy' button


Reply

hei there!

 

We hawe a customer that wants some prooducts to be shown in the productspage but without the possibilitiy of putting them in the basket.

 

Is there a way to do this by for instace toggling a setting in the edit product page (Activate product?) and using an if/else tag in the template?

 

I'v looked at the tags but cant find something that could be used

 

-jan


Replies

 
Reply

No, a product is either active or not active = it won't be displayed. Create a custom product field and use it's tag for the If Defined condition. Creating a check box won't do, as it's template value will True or False. Of cause you can use JavaScript to measure the text value of the template tag.

 
Reply

hi

 I tried:

 

if ('<!--@Ecom:Product:Field.skjul.Value.Clean-->'=="True")
{
  document.getElementById('kjopID').style.visibility = 'hidden';
}
 

where <!--@Ecom:Product:Field.skjul.Value.Clean--> is a product field I made

 

But DW doesen't render the tag inside <sript></script> blocks

Any Ideas?

do I need to pass the value via the DOM?

 

-jan

 
Reply


Yir, it does. Something else mus be wrong. Type in <!--@DwTemplateTags--> and copy the tag from here to make absolutely sure that it is the same as DW expects. Remember, tags are case sensitive. 

 
Reply

hi

 

I did that and the spelling was correct

 

 

I ended up doing this

<input type="hidden" id="skjolVal" value="<!--@Ecom:Product:Field.skjul.Value.Clean-->">

 

and later:

 

if document.getElementById"skjolVal").value=="True")
{
document.getElementById('kjopID').style.visibility = 'hidden';
}
 and that worked so.. but its a little messy

 

Tried alert()'ing some tags but they all show up unrendered between the script tag

 

-jan

 

 
Reply

Well, I can promise you this much: It's not because of the script blocks that your tags do not get rendered. Feel free to post the complete template code and let's have a look at it.

 
Reply

Doesent seem to be a way to post it! I think the HTML messes with the post-form?

 

this is the script block:

<script type="text/javascript">
var allElements = document.getElementById('prod').getElementsByTagName('span');
allElements[allElements.length-1].innerHTML="";// fjern siste comma
if (document.getElementById("skjolVal").value=="True")
{
document.getElementById('kjopID').style.visibility = 'hidden';
}
</script>
 

 

 
Reply

the script block was inside a DW-loop:

 

<!--@LoopStart(ProductRelatedGroups)--> 

.

.

.

<!--@LoopEnd(ProductRelatedGroups)--> 

 

I moved the alert() outside the loop and it renderd the tag fine.

 

probably the tags dont render iside DW-loops?

 

-jan

 
Reply

A product related tag will not render inside a productgroup loop.

 

You must be logged in to post in the forum