[vc_row full_width=”stretch_row” css=”.vc_custom_1533901535164{background-image: url(https://mlrqmpeszmg6.i.optimole.com/w:auto/h:auto/q:mauto/ig:avif/https://affberry.com/wp-content/uploads/2018/07/headbg.png?id=868) !important;background-position: center !important;background-repeat: no-repeat !important;background-size: cover !important;}”][vc_column][vc_column_text]
Presta Shop
An open source ecommerce software that helps to create a successful online stores for free.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][/vc_column][/vc_row][vc_row disable_element=”yes”][vc_column][vc_column_text]To integrate your Shopify store, you can use the official built-in plugin. Just navigate to your Plugins section of your merchant panel and configure the plugin after activating it.
Besides the Affberry you will also need a private app in your Shopify account.
Login to your Shopify admin panel and navigate to Apps> Manage private apps (a link at the bottom). Create a private app and name it e.g. “Affberry”. The private app needs to have Read and Write permissions for the “Script tags“, the rest of the permissions can stay default. When done use it’s credentials when setting up the plugin in merchant panel.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]
1.Edit the file:
controllers/front/orderconfirmationcontroller.php
find this function initContent()
find this line$presentedOrder = $this->order_presenter->present($order);
Put this code below that line
$currency = new CurrencyCore($cookie->id_currency);
$my_currency_iso_code = $currency->iso_code;
And again find this line
$this->context->smarty->assign(array(
add this code below that line
‘currency’ => $my_currency_iso_code,
Save these files and continue with next step.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]
2.Code
Navigate your directory yourdirectory/themes/classic/templates/checkout/order-confirmation.tpl
find {/block} end of the file. And add below script code before {/block}
<script src="https://yourname.affberry.com/sales/sale.js" type="text/javascript"></script>
<script type="text/javascript">
var accountid ='5';
var campaignid='7';
var cost='{$order.products[0].original_product_price}';
var orderid='{$order.products[0].id_order}';
var productid='{$order.products[0].product_id}';
var currencycode ='{$currency}';
var pluginc='9';//dont change
var trackurl = 'https://yourname.affberry.com/';
register(accountid,campaignid,cost,orderid,productid,currencycode,pluginc,trackurl);
</script>
And now just save it and you are ready to track the sales now.
[/vc_column_text][/vc_column][/vc_row][vc_row disable_element=”yes”][vc_column][vc_column_text]
Per product integration
In case you want to track per product commissions, you should use this integration code instead of the one from step 2.
<script id="pap_x2s6df8d" src="http://URL_TO_affberry/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
if (window.location.href.indexOf('/thank_you') > 0) {
PostAffTracker.setAccountId('Account_ID');
var discount = '';
var discountedperc = 1;
{% for discount in order.discounts %}
discount = '{{ discount.code }}';
if ('{{discount.type}}' !== 'ShippingDiscount') {
discountedperc = 1 - {{ discount.amount | money_without_currency | replace: ',', '' }} / ({{ order.subtotal_price | money_without_currency | replace: ',', '' }} + {{ discount.amount | money_without_currency | replace: ',', '' }});
}
{% endfor %}
{% for line_item in line_items %}
var price = {{ line_item.line_price | money_without_currency | replace: ',', '' }} * discountedperc;
var sale{{ forloop.index }} = PostAffTracker.createSale();
sale{{ forloop.index }}.setTotalCost(price);
sale{{ forloop.index }}.setOrderID('{{order_number}}({{ forloop.index }})');
sale{{ forloop.index }}.setProductID('{{ line_item.sku }}');
sale{{ forloop.index }}.setCoupon(discount);
{% endfor %}
AffTracker.register();
}
</script>
You are done, this is all needed. Save your changes and you are ready to use the integration.
If you would want to use also Lifetime Commissions plugin you need to add the following line to right under sale{{forloop.index}}.setCoupon(discount); to add the customer’s email address to the order.
sale{{forloop.index}}.setData1(Shopify.checkout.email);
Additional info can be found here:https://docs.shopify.com/themes/liquid/objects/orderDo not forget to integrate your shop with the click tracking code.
You can insert it into the theme of your store this way:
Online store> Themes> Customize theme (top right corner)> Theme option (top left corner)> Edit HTML/CSS
In ‘Layout’ directory, there is a file called ‘theme/liquid’. Insert the click tracking code right above </BODY> tag in that file and save it.
[/vc_column_text][/vc_column][/vc_row]