Jump to content

Install tracking sale code for SHAREASALE


Recommended Posts

Hello!

 

I want to sign up in the "Share a sale" affiliate program, and i need so place the tracking code in my confirmation page.

 

<img src="https://shareasale.com/sale.cfm

amount=AMOUNTOFSALE

&tracking=TRACKINGNUMBER

&transtype=sale

&merchantID= MY MERCHANT ID"

width="1" height="1">

 

I figure out that:

TRACKINGNUMBER = id_order

 

But i miss how to get the "order total" from the confirmation page

 

So the tracking code will be:

 

<img src=”https://shareasale.com/sale.cfm?

amount=ORDERTOTAL

&tracking={$id_order}

&transtype=sale

&merchantID=XXXX”

width=”1″ height=”1″>

 

 

Can someone help me to figure out what i can do?

 

Thanks!

 

Link to comment
Share on other sites

PrestaShop does not pass the order total to that page.

 

You would either have to create an override file for the OrderConfirmationController (initContent function), get the order total and add a new smarty variable with the order total, or, you can try to modify the payment module you are using to pass that information too (as it will be called as well and could pass a variable directly from there and not need an override file)

Link to comment
Share on other sites

 

 

You almost become my god, but i couldn't solve it, and now its drive me crazy!

 

 

I did this:

 

1- In orderconfirmationcontroler.php :

 

just before: 

 

$this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');

 

Insert this:

 

   $order = new Order($this->id_order);
   $cart = new Cart($order->id_cart);
   $description="";
   foreach ($cart->getProducts() AS $k=>$v){
   $description.=$v['name']."X".$v['quantity'];
   }   
   $description=urlencode($description);
  
   $this->context->smarty->assign(array(
   'total_to_pay'=>$order->getOrdersTotalPaid(),
   'description'=>$description
   ));
 
 

2- in order-confirmation.tpl

 
amount={$total_to_pay}
&tracking={Tools::getvalue('id_order')}
&transtype=sale
&merchantID=XXXX” width=”1″ height=”1″>
 
 
 
It suppose that the variables are:

AMOUNTOFSALE= {$total_to_pay}

TRACKINGNUMBER={Tools::getvalue('id_order')}

 

 

Doesn't work....    :(

 

PD: i need the total with tax but without the shipping cost...

Link to comment
Share on other sites

Then i use pay by check it works because it load the order-confirmation.tpl

 

But when i pay by paypal module and comeback from paypal payment it load payment.php from paypal/expresscheckout and submit.php

 

I have paypal auto-return disabled.

 

I guest there ir something about it, do know how i can fix it?

Link to comment
Share on other sites

i don't know about whay you're talking now. but:

- orderconfirmation.tpl file appears on confirmation page - when select payment method confirm order

 

you mean that after that you don't see order confirmationt.tpl ?

Link to comment
Share on other sites

Exactly!

 

When you choose paypal, it takes you to the paypal page to do the payment, and when it comes back to the site, it load another page. with the payment.php and submit.php from the paypalexpress module.

 

As i read in other forums, as paypal take some seconds to confirm the payment, thats why it load that page, because the order is not actually confirmed.

 

I am attaching the screenshots from each payment, and you can see, they load different pages.

 

- The pay by check load the order-confirmation.tpl and the paypal load payment.php

 

 

post-721907-0-49348200-1399640096_thumb.png

post-721907-0-29539200-1399640118_thumb.png

Link to comment
Share on other sites

Hello,

 

I found that as i hace some modules, it use paypal expresscheckout, i found it use this:

 

modules/paypal/views/templates/front/order-confirmation.tpl

 



{if $smarty.const._PS_VERSION_ < 1.5 && isset($use_mobile) && $use_mobile}
{include file="$tpl_dir./modules/paypal/views/templates/front/order-confirmation.tpl"}
{else}
{capture name=path}{l s='Order confirmation' mod='paypal'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
 
<h1>{l s='Order confirmation' mod='paypal'}</h1>
 
{assign var='current_step' value='payment'}
{include file="$tpl_dir./order-steps.tpl"}
 
{include file="$tpl_dir./errors.tpl"}
 
{$HOOK_ORDER_CONFIRMATION}
{$HOOK_PAYMENT_RETURN}
 
<!-- SHARE A SALE -->
<img src=”https://shareasale.com/sale.cfm?amount={$total_to_pay}&tracking={Tools::getvalue('id_order')}&transtype=sale&merchantID=XXXX ” width=”1″ height=”1″>
<!-- SHARE A SALE END -->
 
<br />
 
{if $order}
<p>{l s='Total of the transaction (taxes incl.) :' mod='paypal'} <span class="bold">{$price|escape:'htmlall':'UTF-8'}</span></p>
<p>{l s='Your order ID is :' mod='paypal'} <span class="bold">{$order.id_order|intval}</span></p>
<p>{l s='Your PayPal transaction ID is :' mod='paypal'} <span class="bold">{$order.id_transaction|escape:'htmlall':'UTF-8'}</span></p>
{/if}
<br />
 
{if $is_guest}
<a href="{$link->getPageLink('guest-tracking.php', true)}?id_order={$order_reference}" title="{l s='Follow my order' mod='paypal'}" data-ajax="false"><img src="{$img_dir}icon/order.gif" alt="{l s='Follow my order' mod='paypal'}" class="icon" /></a>
<a href="{$link->getPageLink('guest-tracking.php', true)}?id_order={$order_reference}" title="{l s='Follow my order' mod='paypal'}" data-ajax="false">{l s='Follow my order' mod='paypal'}</a>
{else}
<a href="{$link->getPageLink('history.php', true)}" title="{l s='Back to orders' mod='paypal'}" data-ajax="false"><img src="{$img_dir}icon/order.gif" alt="{l s='Back to orders' mod='paypal'}" class="icon" /></a>
<a href="{$link->getPageLink('history.php', true)}" title="{l s='Back to orders' mod='paypal'}" data-ajax="false">{l s='Back to orders' mod='paypal'}</a>
{/if}
{/if}


 

 

And it looks like it use the the variables from:

 

modules/paypal/express_checkout/submit.php

 

THE SUBMIT PHP CODE IS

 



include_once(dirname(__FILE__).'/../../../config/config.inc.php');
include_once(dirname(__FILE__).'/../../../init.php');
 
if (version_compare(_PS_VERSION_, '1.5', '<'))
require_once(_PS_ROOT_DIR_.'/controllers/OrderConfirmationController.php');
 
/**
 * 1.4 Retro-compatibility class
 */
class PayPalExpressCheckoutSubmit extends OrderConfirmationControllerCore
{
public function __construct()
{
$this->paypal = new PayPal();
$this->context = $this->paypal->context;
 
parent::__construct();
 
$this->run();
}
 
public function displayContent()
{
$id_order = (int)Tools::getValue('id_order');
 
$order = new Order($id_order);
$paypal_order = PayPalOrder::getOrderById($id_order);
 
$price = Tools::displayPrice($paypal_order['total_paid'], $this->context->currency);
 
$order_state = new OrderState($id_order);
 
if ($order_state)
$order_state_message = $order_state->template[$this->context->language->id];
 
if (!$order || !$order_state || (isset($order_state_message) && ($order_state_message == 'payment_error')))
{
$this->context->smarty->assign(
array(
'logs' => array($this->paypal->l('An error occurred while processing payment.')),
'order' => $paypal_order,
'price' => $price,
)
);
 
if (isset($order_state_message) && $order_state_message)
$this->context->smarty->assign('message', $order_state_message);
 
$template = 'error.tpl';
}
else
{
$this->context->smarty->assign(
array(
'order' => $paypal_order,
'price' => $price,
)
);
 
$template = 'order-confirmation.tpl';
}
 
$this->context->smarty->assign('use_mobile', (bool) $this->paypal->useMobile());
echo $this->paypal->fetchTemplate($template);
}
}


 

 

Now it sends some info but it can't get the right AMOUNT variable (It don't get it from the controller php file), my tracking code is:

 


amount={$total_to_pay}

&tracking={Tools::getvalue('id_order')}

&transtype=sale

&merchantID=XXXX ” width=”1″ height=”1″>

 

I already try by changing the variable {$total_to_pay} for this ones:

{$total_paid}

{$total_paid}

{$paypal_order}

{$price}

 

I also try it with the code {Tools::getvalue('XXXXXXX')} but doesn't work.

 

NOTE: i prefer the total order amount without tax and shipping

 

Any help?

Link to comment
Share on other sites

  • 8 months later...
  • 3 weeks later...

Hi,

 

If you want to add a tracking code for PayPal module (paypal/views/templates/front/order-confirmation.tpl), you can use this variable 

 

ID = {$order.id_order}

Amount = {$order.total_paid}

$id_order 

won't work ? It seems to be declared here no ?

public function displayContent()
{
$id_order = (int)Tools::getValue('id_order');

what variable should i use to get total amount without shipping AND without tax ? Can't figure that out...

 

Thanks

Link to comment
Share on other sites

  • 2 months later...

https://www.prestashop.com/forums/topic/250595-solved-affiliate-tracking-code/page-3

if you check that link quoting vekia below:

 

 

So you edited the controller .php file. Now in the .tpl file you can use variable {$order} with "subvariables"

to use subvariables you have to use them like this $order->total_order etc.

to display all available variables in the template put this:

{$order|print_r}

put there for example at the top of the .tpl file.

then refresh your website. You will see all available variables. Select one of them. and use it in format: $order->variable
where variable is a name of variable for example: $order->total_order. 

 

 

 

awesome smile.png

you see there variables:
[total_paid] => 37.00
[total_paid_real] => 37.00
[total_products] => 30.83
[total_products_wt] => 37.00
[total_shipping] => 0.00
[total_wrapping] => 0.00
you can use in the .tpl file variables like:
$order->total_paid - it will show: 37.00
$order->total_paid_real - it will show 37.00
$order->total_products - it will show 30.83
$order->total_products_wt- it will show 37.00
$order->total_shipping - it will show 0.00
$order->total_wrapping - it will show 0.00
now you can put one of them to the tracking pixel code 

 

hope this helps.

Edited by zeki893 (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...