Integrating iDevAffiliate with FoxyCart is simple. Here's a quick rundown:
You can integrate with iDevAffiliate directly within iDev's administration, following the instructions on this page and selecting “FoxyCart” from the list.
Alternatively, you can follow these instructions:
Instead of creating a new receipt template, you can use the new template → configuration settings.
{% if context == "receipt" %} {# Replace this line with code from iDevAffiliate #} {% endif %}
^^receipt_only_begin^^ -> {% if first_receipt_display %} ^^receipt_only_end^^ -> {% endif %}
{% if context == "receipt" %}
{% set products_purchased = "" %}
{% for item in items %}
{% set products_purchased = products_purchased ~ item.code %}
{% if item.item_number != items|length %}
{% set products_purchased = products_purchased ~ "|" %}
{% endif %}
{% endfor %}
{% if first_receipt_display %}
<img border="0" src="https://www.YOURDOMAIN.com/idevaffiliate/sale.php?idev_saleamt={{ total_order }}&idev_ordernum={{ order_id }}&products_purchased={{ products_purchased }}" width="1" height="1">
{% endif %}
{% endif %}
To track the total price of items only, you'll make a small change to the iDev code above: replace total_order
with total_item_price
- and that will send the cart subtotal to iDev.
Note that this will send the amount without discounts applied. In order to do that, you can set a twig variable like this at the top of the script: {% set discounted_total = total_item_price + total_discount %}
You'll then use {{ discounted_total }}
in the parameter value instead of {{ total_order }}
Basic setup pretty much identical to v4.x below.
If you'd like to take advantage of the Coupon Code Commissioning feature available with iDevAffiliate, use the following code.
This requires FoxyCart version 1.0+
Place this code before the img
code you get from your iDev account as explained later in this page.
Versions 1.0 - 1.1
{% set active_coupon = "" %} {% for coupon in coupons %} {% set active_coupon = coupon.code %} {% endfor %}
Then append this to the end of the img src value:
&coupon_code={{ active_coupon }}
Which will give you something like this:
{% set active_coupon = "" %}
{% for coupon in coupons %}
{% set active_coupon = coupon.code %}
{% endfor %}
^^receipt_only_begin^^
<img border="0" src="https://www.YOURDOMAIN.com/idevaffiliate/sale.php?idev_saleamt={{ order_total }}&idev_ordernum={{ order_id }}&coupon_code={{ active_coupon }}" width="1" height="1">
^^receipt_only_end^^
Versions 2.0+
{% set active_coupon = "" %} {% for code, coupon in coupons %} {% set active_coupon = code %} {% endfor %}
Then append this to the end of the img src value:
&coupon_code={{ active_coupon }}
Which will give you something like this:
{% set active_coupon = "" %}
{% for code, coupon in coupons %}
{% set active_coupon = code %}
{% endfor %}
^^receipt_only_begin^^
<img border="0" src="https://www.YOURDOMAIN.com/idevaffiliate/sale.php?idev_saleamt={{ order_total }}&idev_ordernum={{ order_id }}&coupon_code={{ active_coupon }}" width="1" height="1">
^^receipt_only_end^^
If you'd like to take advantage of the Per-Product Commissioning feature available with iDevAffiliate, use the following code.
This requires FoxyCart version 1.0+
Place this code before the img
code you get from your iDev account as explained later in this page.
{% set products_purchased = "" %} {% for item in items %} {% set products_purchased = products_purchased ~ item.code %} {% if item.item_number != items|length %} {% set products_purchased = products_purchased ~ "|" %} {% endif %} {% endfor %}
Then append this to the end of the img src value:
&products_purchased={{ products_purchased }}
Which will give you something like this:
{% set products_purchased = "" %}
{% for item in items %}
{% set products_purchased = products_purchased ~ item.code %}
{% if item.item_number != items|length %}
{% set products_purchased = products_purchased ~ "|" %}
{% endif %}
{% endfor %}
^^receipt_only_begin^^
<img border="0" src="https://www.YOURDOMAIN.com/idevaffiliate/sale.php?idev_saleamt={{ order_total }}&idev_ordernum={{ order_id }}&products_purchased={{ products_purchased }}" width="1" height="1">
^^receipt_only_end^^
Pretty much identical to v4.x below.
Pretty much identical to v4.x below.
https
).
order_total
and order_id
.<img border="0" src="https://www.YOURDOMAIN.com/idevaffiliate/sale.php?idev_saleamt=XXX&idev_ordernum=XXX" width="1" height="1">
XXX
with FoxyCart placeholders like ^^order_id^^
and ^^order_total^^
, and surround the code with the receipt only tags to prevent re-triggering the code if you use re-visitable receipts: ^^receipt_only_begin^^<img border="0" src="https://www.YOURDOMAIN.com/idevaffiliate/sale.php?idev_saleamt=^^order_total^^&idev_ordernum=^^order_id^^" width="1" height="1">^^receipt_only_end^^