Buy Now Button PrestaShop – Attribute refreshing

I have made this Buy Now button on my website and works with number of items selected but how can I make it so it works with attribute selected without putting custom JS?

My code…

<div class="buton-cumpara-acum">
    
{if isset($static_token)}
<a class="button buy_now_button btn btn-default" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product->id|intval}&token={$static_token}", false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Buy Now'}" data-id-product="{$product->id|intval}"  onclick="this.href = this.href+ '&qty='+$('.buy_now_button').closest('form').find('#quantity_wanted').val() + '&ipa='+  $('.buy_now_button').closest('form').find('#idCombination').val(); " >
<span>{l s='Cumpără acum!'}</span>
</a>
{else}
<a class="button buy_now_button btn btn-default" href="{$link->getPageLink('cart',false, NULL, 'add=1&id_product={$product->id|intval}', false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Buy Now'}" data-id-product="{$product->id|intval}" onclick="this.href = this.href+ '&qty='+$('.buy_now_button').closest('form').find('#quantity_wanted').val() + '&ipa='+  $('.buy_now_button').closest('form').find('#idCombination').val(); " >
<span>{l s='Cumpără acum!'}</span>
</a></div>
{/if}
    {/block}  
  {/if}
</div><br>

to add in my code something like $product.id_product_attribute

Thank you!