Dissolved Fractals Posted February 17, 2020 Share Posted February 17, 2020 (edited) Hi, I am trying to modify the invoice template that prints out pdf to know if the order has selected anything other than the default combination. If it is not the default combination, it will do some html/css modifications. Otherwise, leave as is. My two questions are: 1. What is the variable to check if the combination selected in the order is the default or not 2. The product title + the combination can be retrieved using { $order_detail.product_name }, how do I retrieve them separately so I can do modifications on the combination part alone? Additional question: Since the only way for me to check the changes is viewing the pdf file, is there a way for me to view it in html format for quick testing? Edited February 19, 2020 by Dissolved Fractals typo (see edit history) Link to comment Share on other sites More sharing options...
Dissolved Fractals Posted February 19, 2020 Author Share Posted February 19, 2020 A little help? Anyone? Link to comment Share on other sites More sharing options...
ventura Posted February 24, 2020 Share Posted February 24, 2020 In order to do this you need to overwrite the file classes/pdf/HTMLTemplateInvoice.php And inside public function getContent() Add this foreach ($order_details as &$order_detail) { $product = new Product($order_detail['product_id'], false, Context::getContext()->language->id, Context::getContext()->shop->id); $has_combinations= $product->hasCombinations(); $id_default_attribute = (int) Product::getDefaultAttribute($order_detail['product_id'], 0, true); $order_detail['is_default_attribute'] = ($has_combinations && (int)$order_detail['product_attribute_id'] == (int)$id_default_attribute) ? true : false; } Then in /pdf/invoice.product-tab.tpl You can use the variable and or statement {if $order_detail.is_default_attribute} ........ {/if} 1 Link to comment Share on other sites More sharing options...
Dissolved Fractals Posted February 27, 2020 Author Share Posted February 27, 2020 Thanks. What is left now is from my 2nd question so I can do this: { product_title } {if $order_detail.is_default_attribute} ........ {else} {product_attribute} {/if} . To explain further, how do I break down { $order_detail.product_name } so I can separate product attribute(combination) from the product title? 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