Cybril Posted November 21, 2014 Share Posted November 21, 2014 Hello, I am trying to add affiliate tracking code to my client's installation and I have seen a few solutions but the code they say to find does not match what I am looking at, I'm guessing my client's is older. I can not find a version number in the code but it does say 'copyright 2007-2012 PrestaShop' so I guess this is from 2012? Can anyone help with what I need to add to OrderConfirmationController.php? I see this in function process: self::$smarty->assign(array( 'is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int)($this->id_order), (int)($this->id_module)) )); There is also this: if (self::$cookie->is_guest) { self::$smarty->assign(array( 'id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order) )); /* If guest we clear the cookie for security reason */ self::$cookie->mylogout(); } which looks more like what I want but I don't want to add it if they are only a guest, I want it for all. So I guess I add those variables from if guest to the top one, but I also need total order - what would this variable be? I see if $order->payment != $module->displayName which looks like a text comparison so I don't want that - is there an $order->total_products? Any help greatly appreciated. This is my first time working with Prestashop. Cybril Link to comment Share on other sites More sharing options...
NemoPS Posted November 22, 2014 Share Posted November 22, 2014 This should work self::$smarty->assign(array( 'id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order), 'is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int)($this->id_order), (int)($this->id_module)) )); But what is your presta version? cause 1.6 looks like $this->context->smarty->assign(array( 'is_guest' => $this->context->customer->is_guest, 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn() )); Link to comment Share on other sites More sharing options...
Cybril Posted November 22, 2014 Author Share Posted November 22, 2014 Thank you, this is what I ended up doing yesterday: self::$smarty->assign(array( 'is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int)($this->id_order), (int)($this->id_module)), 'id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order),'total_products'=>$this->total_products )); if (self::$cookie->is_guest) { //self::$smarty->assign(array( //'id_order' => $this->id_order, //'id_order_formatted' => sprintf('#%06d', $this->id_order) //)); /* If guest we clear the cookie for security reason */ self::$cookie->mylogout(); } Can you confirm total_products variable will work? I don't know the version, I can not find it anywhere in the code. Link to comment Share on other sites More sharing options...
NemoPS Posted November 24, 2014 Share Posted November 24, 2014 Well no, definitely not. Unless you assign it before, it will never work of course Link to comment Share on other sites More sharing options...
Cybril Posted November 24, 2014 Author Share Posted November 24, 2014 Perhaps you could tell me what will work rather than just saying 'definitely not' and 'it will never work of course', I asked in my first post what the total order variable was and also said this was my first time with Prestashop, so a bit more help would be appreciated, being a 'Prestashop Superstar' and all. Link to comment Share on other sites More sharing options...
NemoPS Posted November 25, 2014 Share Posted November 25, 2014 "Prestashop Superstar" is assigned by the forum itself based on the number of posts, nothing I would ever address myself with. That said, try this: $this->context->cart->getProducts(); Link to comment Share on other sites More sharing options...
Cybril Posted November 25, 2014 Author Share Posted November 25, 2014 Thank you, I will try that. Link to comment Share on other sites More sharing options...
Cybril Posted November 25, 2014 Author Share Posted November 25, 2014 Do you also have any idea of how to add a script to footer (or header)? I've added to both and nothing shows up - and the tags in the actual footer do not match any in the template. Is there a cache? Link to comment Share on other sites More sharing options...
NemoPS Posted November 26, 2014 Share Posted November 26, 2014 You mean a <script> tag? Link to comment Share on other sites More sharing options...
Cybril Posted November 26, 2014 Author Share Posted November 26, 2014 Yes, an affiliate tracking link to be precise. I've tried adding to header.tpl and footer.tpl but it never shows up. Link to comment Share on other sites More sharing options...
NemoPS Posted November 28, 2014 Share Posted November 28, 2014 How did you add it exactly? Directly by copying.pasting to a tpl file? It's sup[posed to show up, but you might get compilation errors if you don't wrap it with a cdata block Link to comment Share on other sites More sharing options...
Cybril Posted November 28, 2014 Author Share Posted November 28, 2014 Yes I just posted direct the script tag. There is no compilation error, it's just not showing up, but the strange thing is some of the id's and classes in the output I see on the page do not match the code I see in the template file, it's like it's a completely different file (which would certainly be the reason I'm not seeing the script tag show up) but I can't see where else I should be putting it - there is only one folder (prestashop) under themes. Maybe I'll try the cdata block and see how I go, thanks. Link to comment Share on other sites More sharing options...
Cybril Posted November 28, 2014 Author Share Posted November 28, 2014 No, that didn't work either. Link to comment Share on other sites More sharing options...
NemoPS Posted November 29, 2014 Share Posted November 29, 2014 Try writing something that really has to show up, like in footer.tpl, writeTEST HERE!Then set to force compile in the back office (advanced parameters, performance). See if it pops up Link to comment Share on other sites More sharing options...
Cybril Posted December 1, 2014 Author Share Posted December 1, 2014 The test here didn't work and I didn't find an option in admin (finally got access) to force a compile - I have found out we have Version: 1.4.8.2 - I am now browsing through admin to see if I can add via there - I see back office -> modules -> positions - would I do it in there somewhere? Link to comment Share on other sites More sharing options...
NemoPS Posted December 1, 2014 Share Posted December 1, 2014 Hm, I forgot where it was on that version, maybe preferences, performance. Or, delete the content of tools/smarty/compile (leave index.php) Link to comment Share on other sites More sharing options...
Cybril Posted December 1, 2014 Author Share Posted December 1, 2014 That got it (the delete contents of compile folder) - thank you!! Link to comment Share on other sites More sharing options...
Cybril Posted December 1, 2014 Author Share Posted December 1, 2014 Ah well, on one site, not the other - bah! I'll see what version the other one is. Link to comment Share on other sites More sharing options...
Cybril Posted December 1, 2014 Author Share Posted December 1, 2014 This one is the same version and already had force compile switched on and I deleted the contents of compile for good measure but that did nothing either. Any other ideas? Thanks for your help/patience/persistence. Link to comment Share on other sites More sharing options...
Cybril Posted December 1, 2014 Author Share Posted December 1, 2014 Ok so turns out user error on this one - there was another theme called 'style' and I just assumed it had css etc under it and didn't even look! So all done now, and thank you once again for all your help. Link to comment Share on other sites More sharing options...
Recommended Posts