Jump to content

Get Pack content Smarty


PsychoZzzorD

Recommended Posts

Hi everybody !

I'm searching the smarty variable to access the content of a pack with his product's ID if it's possible =)

I would like to get it in the same way than this :

 

"

public static function getProductQuantity($id){

    $product = new Product ($id,Context::getContext()->language->id);
    return $product->quantity;

 }

"

 

This function is a custom one in the frontcontroller that allows me to get the quantity of a product this way

"

{FrontController::getProductQuantity(id)}

"

 

Does somebody have an idea of how I should do to get the pack content ?

Thank you in advance

Link to comment
Share on other sites

  • 2 weeks later...

Hi Rocky, thanks for your answer !

Where should I try this ? Cause I get a similar code into the shopping-cart-prodcut-line.tpl that allows me to see the content of a pack.
But on my homepage (where my pack are displayed), this doesn't work. 

Here is my code

 

{if Pack::isPack($product.id_product)}{assign var=packItems value=Pack::getItemTable($product.id_product, Context::getContext()->language->id)}
	{if $packItems|@count > 0}
		<p class="packInfos">{l s='Voir le détail des articles'}<span class="chevron"></span></p>
			<div class="detailsPack">
				{foreach from=$packItems item=packItem}
				    <p style="text-align: left !important;">
				    <a href="{$link->getProductLink($packItem.id_product, $packItem.link_rewrite, $packItem.category)|escape:'html':'UTF-8'}">
				    <img src="{$link->getImageLink($packItem.link_rewrite, $packItem.id_image, 'cart_default')|escape:'html':'UTF-8'}" alt="{$packItem.name|escape:'html':'UTF-8'}" width="50" height="37.5"/></a>
				    {$packItem.pack_quantity} x <a style="font-size:14px !important;" href="{$link->getProductLink($packItem.id_product, $packItem.link_rewrite, $packItem.category)|escape:'html':'UTF-8'}">{$packItem.name|escape:'html':'UTF-8'}</a></p>
				{/foreach}
			</div>
	{/if}
{/if}

Is it possible that I make it work on my homepage ? Can I put inside this code the ID of the pack I want to show the content ?

Thanks in advance

Link to comment
Share on other sites

I can't see anything wrong with the code, as long as $product.id_product exists. I'm not sure which template you're putting the code in on the homepage. Different Smarty variables will be available depending on which template you are using.

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...