---- dataentry ---- type : integration # do not change this line systems : iDevAffiliate # the system(s) that the integration is for, separated with commas if more than one name : iDevAffiliate Tracking # the name of the integration description : Basic iDevAffiliate tracking for FoxyCart tags : affiliate, tracking, tutorial # tags, separated by commas date_dt : # the date in YYYY-MM-DD format version : # if you have a version for your code, enter it here developer_url : # if you'd like a link back to your site, stick it here ---- ====== iDevAffiliate Integration ====== Integrating [[http://www.idevdirect.com/affiliates/idevaffiliate.php?id=11807|iDevAffiliate]] with FoxyCart is simple. Here's a quick rundown: ===== Integrating with FoxyCart v2.0 ===== You can integrate with iDevAffiliate directly within iDev's administration, following [[https://help.idevaffiliate.com/shopping-cart-integration-instructions/|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. - Go to that page in the FoxyCart admin (templates -> configuration). - Find the "Add custom header and footer code to your templates" section under the "Cart" section - Check that box to expand that section. - Add this code: {% if context == "receipt" %} {# Replace this line with code from iDevAffiliate #} {% endif %} - Copy/paste the code provided by iDevAffiliate, replacing the "Replace this line", but maintain the "if" and "endif" lines. - Replace two lines from the steps below as follows: ^^receipt_only_begin^^ -> {% if first_receipt_display %} ^^receipt_only_end^^ -> {% endif %} - You should be left with something like this: {% 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 %} {% 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 }}%%'' - Save the template settings. - Test. ===== iDevAffiliate v7.0 ===== Basic setup pretty much identical to v4.x below. ==== Coupon Code Commissioning ==== 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^^ ^^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^^ ^^receipt_only_end^^ ==== Per-Product Commissioning ==== If you'd like to take advantage of the [[http://www.idevlibrary.com/docs/Per_Product_Commissions.pdf|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^^ ^^receipt_only_end^^ ===== iDevAffiliate v6.0 ===== Pretty much identical to v4.x below. ===== iDevAffiliate v5.0 ===== Pretty much identical to v4.x below. ===== iDevAffiliate v4.0 ===== **IMPORTANT**: If you're using FoxyCart prior to v0.7.0 you'll need to host [[http://www.idevdirect.com/affiliates/idevaffiliate.php?id=11807|iDevAffiliate]] securely over SSL (''https''). - Check [[http://www.idevdirect.com/affiliates/idevaffiliate.php?id=11807&keyword=iDevAffiliate&custom=134|iDevAffiliate's page]] for instructions. - Login to your iDevAffiliate manager and click on the Cart Integration link. * It doesn't matter what you call your variable names. All that matters is that you put in the right placeholders later, so just call your variable names something descriptive like ''order_total'' and ''order_id''. * iDev will generate some code that should look something like this: - Replace the ''XXX'' with [[:v:0.6.0:docs:placeholders|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^^^^receipt_only_end^^ - Create a separate receipt template in your FoxyCart admin. Include your modified code at the bottom of your template.