rytek Posted August 21, 2013 Share Posted August 21, 2013 (edited) Hi. I need to get product list for javascript code displayed on order_confirmation.tpl (...) "_ORDER", { identifier: 'order id', amount: 'total amount without shipping', currency: 'currency', }, [ // first product in order { identifier: 'product id', quantity: 'product quantity in order' }, // secondproduct in order { identifier: 'product id', quantity: 'product quantity in order' }, // rest of them { identifier: 'product id', quantity: 'product quantity in order' } (...) I can fill the first three values ( order id, amount and currency), but i don't know how can I get products from order. I just need 2 values (each product_id and quantity). Thanks for help. Btw. I don't know if I created this topic in proper category. Edited August 21, 2013 by rytek (see edit history) Link to comment Share on other sites More sharing options...
rytek Posted August 21, 2013 Author Share Posted August 21, 2013 Ok, i've done it In controllers/front/OrderConfirmationController.php: $ord_id = new Order($this->id_order); $produkty = $ord_id->getProducts(); $this->context->smarty->assign(array( (...) 'ID_ZAM' => $this->id_order, 'produkty' => $produkty, (...) )); And in order_confirmation.tpl i've added foreach on products, and needed values. Link to comment Share on other sites More sharing options...
teekay Posted November 11, 2013 Share Posted November 11, 2013 Hello, I need to solve this problem too. Can you please post the complete code to do this modification? Thank you Best regards, Link to comment Share on other sites More sharing options...
vekia Posted November 11, 2013 Share Posted November 11, 2013 hello code above is enough, with this code you add a new veriables to smarty array it mean, that in .tpl file you can use these variables like other {$ID_ZAM} {$produkty} Link to comment Share on other sites More sharing options...
rytek Posted November 12, 2013 Author Share Posted November 12, 2013 Hi there. I've sent some code to teekay in the pm, but somebody can have problem with generating the javascript code (the last comma in the product loop could be a problem). {literal} <script type="text/javascript"> var goadservicesq = []; goadservicesq.push( [ "_ORDER", { identifier: 'order id', amount: 'total amount without shipping', currency: 'currency', }, [ {/literal} {foreach from=$produkty item=product name=item} {literal} { identifier: '{/literal}{$product.id_product}{literal}', quantity: '{/literal}{$product.product_quantity}{literal}' } {/literal} {if not $smarty.foreach.item.last}{literal},{/literal}{/if} {/foreach} {literal} ] ] ); (function() { (...) Rest of the gooads script. (...) })(); </script> {/literal} Hope that will help someone 1 Link to comment Share on other sites More sharing options...
teekay Posted November 12, 2013 Share Posted November 12, 2013 Hello, Thank you for your reply. The code was enough...this is true. I managed to solve the problem. Best regards, Link to comment Share on other sites More sharing options...
FelipeGallo Posted November 25, 2014 Share Posted November 25, 2014 Hi! I need to put a list of products of my order in confirmation page script like this: try{ bs.addProdutoComprado({ "cod_compra":"{$id_order}", "id_product":"{$product.id_product}", "nome_product":"{$product.link_rewrite}", "price_unit":"{$product.price}", "category":"{$product.category}", }); }catch(e){ } The variables of the products does not working. Link to comment Share on other sites More sharing options...
rytek Posted November 25, 2014 Author Share Posted November 25, 2014 Hey Felipe, look at the #2 post in this topic, and add required variables to the controllers/front/OrderConfirmationController.php , then try to paste this code in the order_confirmation.tpl: {literal} <script type="text/javascript"> {/literal} {foreach from=$produkty item=product name=item} {literal} bs.addProdutoComprado({ "cod_compra":"{/literal}{$id_order}{literal}", "id_product":"{/literal}{$product.id_product}{literal}", "nome_product":"{/literal}{$product.link_rewrite}{literal}", "price_unit":"{/literal}{$product.price}{literal}", "category":"{/literal}{$product.category}{literal}", }); {/foreach} </script> {/literal} I think it should work. Best Regards, Artur. Link to comment Share on other sites More sharing options...
FelipeGallo Posted November 25, 2014 Share Posted November 25, 2014 Hey Felipe, look at the #2 post in this topic, and add required variables to the controllers/front/OrderConfirmationController.php , then try to paste this code in the order_confirmation.tpl: {literal} <script type="text/javascript"> {/literal} {foreach from=$produkty item=product name=item} {literal} bs.addProdutoComprado({ "cod_compra":"{/literal}{$id_order}{literal}", "id_product":"{/literal}{$product.id_product}{literal}", "nome_product":"{/literal}{$product.link_rewrite}{literal}", "price_unit":"{/literal}{$product.price}{literal}", "category":"{/literal}{$product.category}{literal}", }); {/foreach} </script> {/literal} I think it should work. Best Regards, Artur. Olá Artur, você é brasileiro também? Hi Artur, you is brazilian too? Eu coloco as variáveis no OrderConfirmationController.php dentro de alguma função ou posso colocar no fim do arquivo mesmo? I put the variables no OrderConfirmationController.php inside any function ou just in the last line of the code? Obrigado! Thanks! Link to comment Share on other sites More sharing options...
FelipeGallo Posted November 25, 2014 Share Posted November 25, 2014 The code in OrderConfirmationController.php is like this? $order_id = new Order($this->id_order);$produto = $order_id->getProducts(); $this->context->smarty->assign(array( 'id_order' => $this->id_order, 'id_product' => $this->product.id, 'nome_product' => $this->product.link_rewrite, "price_unit" => $this->product.price, "category" => $this-> product.category )); Link to comment Share on other sites More sharing options...
rytek Posted November 25, 2014 Author Share Posted November 25, 2014 Hello, In funtion initContent() $order = new Order($this->id_order); $produto = $order->getProducts(); $this->context->smarty->assign(array( 'id_order' => $this->id_order, 'produkty' => $produto )); Try this. Best Regards, Artur PS. I'm from Poland Link to comment Share on other sites More sharing options...
FelipeGallo Posted November 25, 2014 Share Posted November 25, 2014 (edited) Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/home/tanagra/public_html/loja/themes/default/order-confirmation.tpl" on line 65 ""category":"{/literal}{$product.category}{literal}"," missing or misspelled literal closing tag' in /home/tanagra/public_html/loja/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:665 Stack trace: #0 /home/tanagra/public_html/loja/tools/smarty/sysplugins/smarty_internal_templatelexer.php(1008): Smarty_Internal_TemplateCompilerBase->trigger_template_error('missing or miss...') #1 /home/tanagra/public_html/loja/tools/smarty/sysplugins/smarty_internal_templatelexer.php(930): Smarty_Internal_Templatelexer->yy_r3_7(Array) #2 /home/tanagra/public_html/loja/tools/smarty/sysplugins/smarty_internal_templatelexer.php(100): Smarty_Internal_Templatelexer->yylex3() #3 /home/tanagra/public_html/loja/tools/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(100): Smarty_Internal_ in /home/tanagra/public_html/loja/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 665 Edited November 25, 2014 by FelipeGallo (see edit history) Link to comment Share on other sites More sharing options...
rytek Posted November 25, 2014 Author Share Posted November 25, 2014 Oh, my bad, it is missing closing {/literal} tag near {/foreach}. {literal} <script type="text/javascript"> {/literal} {foreach from=$produkty item=product name=item} {literal} bs.addProdutoComprado({ "cod_compra":"{/literal}{$id_order}{literal}", "id_product":"{/literal}{$product.id_product}{literal}", "nome_product":"{/literal}{$product.link_rewrite}{literal}", "price_unit":"{/literal}{$product.price}{literal}", "category":"{/literal}{$product.category}{literal}", }); {/literal} {/foreach} {literal} </script> {/literal} Best regards, Artur. Link to comment Share on other sites More sharing options...
nikpony Posted December 2, 2016 Share Posted December 2, 2016 Hello, i still need help in a case like above. I want to display product category name, and manufacturer name in order confirmation page. I can only get the ID'S of both of them but not the names that i need. Please could somebody help me? Thanks in advance. 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