cricket-hockey Posted December 1, 2015 Share Posted December 1, 2015 Is it possible to put an IF statement on the invoice template to print postage labels depending on what carrier has been selected? So for example.... IF carrier 1 is selected then print this image: www.domain.com/label1.jpg If carrier 2 is selected then print this image: www.domain.com/label2.jpg etc If this is possible what should the code be? I've played about with different options without success so far. Link to comment Share on other sites More sharing options...
tuk66 Posted December 7, 2015 Share Posted December 7, 2015 Try {if isset($carrier) && $carrier->name == 'my carrier #1'} <img href="http://www.domain.com/label1.jpg" /> {elseif isset($carrier) && $carrier->name == 'my carrier #2'} <img href="http://www.domain.com/label2.jpg" /> {/if} Link to comment Share on other sites More sharing options...
cricket-hockey Posted December 7, 2015 Author Share Posted December 7, 2015 Thanks for your reply. This still doesn't work. I'm pretty sure that's the code I tried in the first place. I've replaced the carrier name exactly as I have it under Shipping > Carriers and put the correct image link in as follows: {if isset($carrier) && $carrier->name == '2nd Class Post'} <img href="http://www.cricket-hockey.com/img/2ndclass.jpg" /> {elseif isset($carrier) && $carrier->name == '1st Class Post'} <img href="http://www.cricket-hockey.com/img/1stclass.jpg" /> {/if} Any ideas what might be wrong? Link to comment Share on other sites More sharing options...
tuk66 Posted December 8, 2015 Share Posted December 8, 2015 Are you sure you have $carrier variable available in the template? This doesn't apply for all templates by default. Link to comment Share on other sites More sharing options...
cricket-hockey Posted December 8, 2015 Author Share Posted December 8, 2015 How do I check if that variable is available? I'm using invoice.tpl in the default template Link to comment Share on other sites More sharing options...
tuk66 Posted December 8, 2015 Share Posted December 8, 2015 Read code in /classes/pdf/* files. Link to comment Share on other sites More sharing options...
cricket-hockey Posted December 8, 2015 Author Share Posted December 8, 2015 in classes/pdf/HTMLTemplateInvoice.php there is the following code: $carrier = new Carrier($this->order->id_carrier); $tax_breakdowns = $this->getTaxBreakdown(); $data = array( 'tax_exempt' => $tax_exempt, 'use_one_after_another_method' => $this->order_invoice->useOneAfterAnotherTaxComputationMethod(), 'display_tax_bases_in_breakdowns' => $this->order_invoice->displayTaxBasesInProductTaxesBreakdown(), 'product_tax_breakdown' => $this->order_invoice->getProductTaxesBreakdown($this->order), 'shipping_tax_breakdown' => $this->order_invoice->getShippingTaxesBreakdown($this->order), 'ecotax_tax_breakdown' => $this->order_invoice->getEcoTaxTaxesBreakdown(), 'wrapping_tax_breakdown' => $this->order_invoice->getWrappingTaxesBreakdown(), 'tax_breakdowns' => $tax_breakdowns, 'order' => $debug ? null : $this->order, 'order_invoice' => $debug ? null : $this->order_invoice, 'carrier' => $debug ? null : $carrier ); Does that mean the $carrier variable is available in invoice.tpl? Link to comment Share on other sites More sharing options...
cricket-hockey Posted November 23, 2016 Author Share Posted November 23, 2016 Can anyone help me to get this working? I still can't figure out how to make the $carrier variable available in the template Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now