> For the complete documentation index, see [llms.txt](https://partners.tray.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://partners.tray.com.br/themes/construindo-seu-template/referencias/data-attributes/compare.md).

# Compare

{% hint style="danger" %}
**Disponível para uso nas páginas:** catalog e search.
{% endhint %}

{% hint style="info" %}
**Para saber mais sobre como gerenciar produtos acesse o link:** [Gerenciar Produtos](https://basedeconhecimento.tray.com.br/hc/pt-br/articles/6734323229851-Configura%C3%A7%C3%B5es-de-Produto)
{% endhint %}

Para adicionar e remover produtos da [comparação de produtos](https://basedeconhecimento.tray.com.br/hc/pt-br/articles/6734323229851-Configura%C3%A7%C3%B5es-de-Produto) via AJAX, utilize o seguinte snippet:

**Input:**

```html
{#
   # Comparador
   # elements/snippets/Comparador.html
#}
{% if pages.current == 'catalog' and settings.compare %}
<div class="compare-buttons">
    {% set compareCSS = 'compare-hidden' %}

    <a data-compare="remove" href="{{ links.compare_delete ~ product.id }}" class="{{ not product.compare ? compareCSS }}">
        <span class="filter-checkbox checked"></span>
        {{ Translation("remover_comparar") }}
    </a>
    
    <a data-compare="add" href="{{ links.compare_add  ~ product.id }}" class="{{ product.compare ? compareCSS }}">
        <span class="filter-checkbox"></span>
        {{ Translation("comparar_produto") }}
    </a>
</div>
{% endif %}
```

**Output:**

```html
<div class="compare-buttons">
	<a data-compare="remove" href="xxx" class="compare-hidden">
		<span class="filter-checkbox checked"></span>
    	Remover Comparação
    </a>
    <a data-compare="add" href="xxx" class="">
    	<span class="filter-checkbox"></span>
        Comparar Produto
    </a>
</div>
```

### Como Usar <a href="#comousar" id="comousar"></a>

Copie o código acima e crie um arquivo separado, ex: `elements/snippets/comparador.html`

Faça a chamada desse arquivo onde desejar:

```twig
{% element 'snippets/comparador' {"product": product} %}  
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://partners.tray.com.br/themes/construindo-seu-template/referencias/data-attributes/compare.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
