Doofinder logo

Support Documentation

Search icon

Add to Cart

Add To Cart

If you are not using the latest version of our plugins, you will have to provide custom JavaScript code to make the button work.

When the add cart button option is enabled, we create an event that triggers every time a person has clicked the button. This event is called doofinder.cart.add.

You need to catch this event and create a function in your code, to call your store's API for the implementation to work. This function will vary from platform to platform. You have to paste the script into your HTML code.

Example of generic implementation:

document.addEventListener('doofinder.cart.add', function(event) {
  const { item_id, amount } = event.detail;
  // add custom code to send the data to your cart API
  console.log(`added ${amount} of item #${item_id}`);
});
add to cart with a variant

Enable Or Disable The Add to Cart Button

To enable or disable the add to cart button in your layer, go to your Admin > Layers > Appearance and swith the add to cart toggle on or off.

add to cart with a variant

To customize your Add to Cart button, read the article Appearance.

Add Quantity Selector

You can incorporate a quantity selector next to your Add to Cart button, as shown in this example:

add to cart with a variant

To do so, it is necessary to include the attribute quantity=”true” in the add-to-cart code line within the product card template. Please note that the unit selector appears after clicking on the "Add to Cart" button.

add to cart with a variant

To access the product card template, navigate to Layers > Appearance, scroll to the Advanced section, and click on Customize. For detailed guidance on managing the product card template, refer to this article.

Add To Cart With A Variant

The add-to-cart feature comes with a variant that allows you to select size, for example, before adding it to the cart, without having to go through the product page.

add to cart with a variant

If you are using the Doofinder plugin to index your content, you can configure the add to cart button, with a variant selector, in a few clicks.

Go to the product card template and locate the following line:

<.add_to_cart for={@item} :let={options} variants={[]} quantity="false">

Simply modify the variants={[]} attribute, in order to add one or several attributes that will be used for the variant selector. In our example, we are using the size attribute, so our code would be as follows:

add to cart with a variant

You can add more attributes, if needed, but note that only one can apply per product. For example, if we have another product, which doesn’t use sizes, but colors, our code would be as follows:

<.add_to_cart for={@item} :let={options} variants={[“size”, color”]} quantity="false">

Prestashop - make sure you have activated the Index product attribute combinations option, from the Doofinder plugin configuration.

How To Configure The Variant Selector, Using A Custom Feed

If you are using a custom Data Feed, make sure you are exporting correctly the variants with a parent product.

The information must be added to the parent product (df_group_leader) and set as follows:

  • TXT file:
header: df_variants_information
value: color%%size
  • XML file:
<df_variants_information><![CDATA[color%%size]]></df_variants_information>

Variants will index the color and size as follows:

  • TXT file:
header: color
value: Black
  • XML file:
<color><![CDATA[Black]]></color>

For further help, please email Support through our contact form, and we will assist you with the process.

If needed, simply log in to your Doofinder admin panel. Click on "Help" in the top blue bar, then select "Contact our Support Team".

Did you find this page helpful?