Jump to content

A list of combinations at the product page


robinbobin

Recommended Posts

Hi everybody!

Maybe someone can help me to solve my problem? I'm trying to make a list of available combinations inside product page. I placed some code into product.tpl.

It works - the "buy-button" sends me to the cart, but!.. - the combinations are listed in absolute chaos) And every time I refresh the page - their position is new.

I assume that something is rong with - {foreach from=$combinations key=key item=item}, but have no idea how it should be done correctly in prestashop 1.7

Spent some days in google)  - didn't find a solution. Will be great if someone just tell me how to loop the array of combinations with the "foreach"

here is my code to list combinations - 

{foreach from=$combinations key=key item=item}
<form id="buy_block"{if $PS_CATALOG_MODE && !isset($groups) && $product->quantity > 0} class="hidden"{/if} action="{$link->getPageLink('cart')|escape:'html':'UTF-8'}" method="post">

<!-- hidden datas -->
<p class="hidden">
<input type="hidden" name="token" value="{$static_token}" />
<input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="id_product_attribute" id="idCombination" value="{$key}" />
</p>

<div class="m-table__row">
<div class="flexrow">

<!--
<div class="col col__title">
<a href="/product.php.html">{$product->name|escape:'html':'UTF-8'}
{if $item.attributes_values.1}/{$item.attributes_values.1}{/if}
{if $item.attributes_values.1}/{$item.attributes_values.3}{/if}</a>
</div>
-->

<!--
<div class="col col__size"><strong>{$item.attributes_values.1}</strong></div>
<div class="col col__quantity">
<div class="quantity">
<span class="quantity__minus">-</span>
<input class="quantity__input" type="text" value="1" name="quantity">
<span class="quantity__plus">+</span>
</div>
</div>
-->

<div class="col col__btn">
<!-- <a href="/product.php.html#" class="btn btn__green button">Купить</a> --> 
<button type="submit" name="Submit" class="btn btn__green button" style="padding:0;width:50%;">
{if $content_only && (isset($product->customization_required) && $product->customization_required)}{l s='Customize'}{else}{l s='add to cart'}{/if}
</button>
</div>
</div>

<div class="col__full clearfix">
{if $item.quantity > 0}
<p class="availability__yes">
<svg width="18" height="18">
<use xlink:href="#availability__yes"></use>
</svg>
{l s='Available'}
</p>
{else}
<p class="availability__no">
<svg width="18" height="18">
<use xlink:href="#availability__no"></use>
</svg>
{l s='Not available'}
</p>
{/if}
</div>
</div>
</form>
{/foreach}

Thanks for any assistance!

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