Jump to content

[solved] Product list on order_confirmation page


Recommended Posts

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 by rytek (see edit history)
Link to comment
Share on other sites

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

  • 2 months later...

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 :)

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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

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

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

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

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

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/home/tanagra/public_html/loja/themes/default/order-confirmation.tpl" on line 65 "&quot;category&quot;:&quot;{/literal}{$product.category}{literal}&quot;," 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 by FelipeGallo (see edit history)
Link to comment
Share on other sites

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

  • 2 years later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...