Jump to content

get the product id


mspace

Recommended Posts

Hello

 

I have created a custom form so the customer can order custom products.

In the form I have a text field that is the product id and the user has to fill it with the relate product id.

 

I need to grab the id from the field in the 

 

<a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product="{$product.id_product|intval}">

 

Is there any way so to pass the value from the field in the data-id-product?

 

thank you

Edited by mspace (see edit history)
Link to comment
Share on other sites

Hello

 

I have created a custom form so the customer can order custom products.

In the form I have a text field that is the product id and the user has to fill it with the relate product id.

 

I need to grab the id from the field in the 

 

<a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product="{$product.id_product|intval}">

 

Is there any way so to pass the value from the field in the data-id-product?

 

thank you

 

I managed to pass the product id to data-id-product.

I pass it to a variable to a php file.

 

$prodid=$_POST['co_prodcod'];

 

Then I echo the button 

 

echo "<a class='button ajax_add_to_cart_button btn btn-default' href='{$link->getPageLink('cart',false, NULL, 'add=1&id_product={$product.id_product|intval}', false)|escape:'html':'UTF-8'}' rel='nofollow' title='{l s='Add to cart'}' data-id-product='{$prodid}'>

 

But now I cannot pass the product id to :

 

href='{$link->getPageLink('cart',false, NULL, 'add=1&id_product={$product.id_product|intval}'

 

so to begin the add to cart functionality 

 

Can someone help with this problem?

Link to comment
Share on other sites

×
×
  • Create New...