# Custom sending of invoices

Sufio allows you to set custom terms to invoice sending, and automatically send invoices to customers only if certain conditions are met.

To enable custom sending of invoices:

1. In your Sufio account, go to the **Settings** → **Emails** page.
2. Switch the **Automatically send invoices** toggle on and select from the dropdown menu **Automatically send invoices** **when orders are****:** **custom**.
3. Click on **Update settings** to save the changes.

You will then need to add a unique [cart attribute](<https://help.shopify.com/themes/customization/cart/get-more-information-with-cart-attributes?ref=sufio>) `Invoice Send` to your cart page that will inform Sufio whether an invoice should be sent for that particular order. Invoices will be sent only if the cart attribute is present and its value is `true`.

To add the cart attribute to the cart page:

1. In your Shopify Admin, go to the **Online Store** → **Themes** page.
2. Click the **Actions** button, and then click **Edit code**.
3. Select **cart.liquid** in the left sidebar. You might use the upper search bar for a faster search.
4. Insert the following code snippet inside the `<form>`. A right place for the field is just before the **Check out** button.

```html
<input type="hidden" name="attributes[Invoice Send]" id="invoice-send" value="true" />
```

## Examples of custom invoice sending

Here are some examples of custom terms that can be used for invoice sending. Use one of the following code snippets as a replacement to the general code snippet above.

### By checkbox

You can add a **Send me an invoice** checkbox to your cart page so that your customers can decide whether they want to receive their invoice or not.

```html
<!-- Shopify cart page -- only send invoices to customers that request them. Used by Sufio for Shopify (sufio.com/shopify). -->
<input type="checkbox" name="attributes[Invoice Send]" id="invoice-send" value="true" />
<label for="invoice-send" class="inline">Send me an invoice</label>
```

### By order value

You can choose to send invoices only for orders with a certain total amount, e.g., higher than zero.

```html
<!-- Shopify cart page -- only send invoices for some orders. Used by Sufio for Shopify (sufio.com/shopify). -->
{% if cart.total_price > 0 %}
  <input type="hidden" name="attributes[Invoice Send]" id="invoice-send" value="true" />
{% endif %}
```

### By product tags

You can send invoices only for orders that contain at least one product tagged with a specific tag, e.g., `Invoice`.

```html
<!-- Shopify cart page -- only send invoices for orders with some products. Used by Sufio for Shopify (sufio.com/shopify). -->
{% for item in cart.items %}
  {% if item.product.tags contains 'Invoice' %}
    {% assign has_tagged_product = true %}
  {% endif %}
{% endfor %}
{% if has_tagged_product %}
  <input type="hidden" name="attributes[Invoice Send]" id="invoice-send" value="true" />
{% endif %}
```

### By customer tags

You can send invoices only to customers tagged as `VIP`. Please note that a customer needs to be logged into their account in your store while shopping.

```html
<!-- Shopify cart page -- only send invoices to some customers. Used by Sufio for Shopify (sufio.com/shopify). -->
{% if customer.tags contains 'VIP' %}
  <input type="hidden" name="attributes[Invoice Send]" id="invoice-send" value="true" />
{% endif %}
```
