Jump to content

Use add to cart form in a customized module


nanogioia

Recommended Posts

Hi, I am willing to use something very similar to the add to cart form that is in a product page, but in a new module that i created. Which one would be the best way to achieve this? Can I try to copy the code included in product.tpl and try to adapt it? Would this be recommendable and achievable?

 

Thanks very much in advance

Link to comment
Share on other sites

can you explain what you exactly trying to achieve/ unfortunately infomrations that you provided it's not enough to understand your expectactions.

 

add to cart is a native prestashop feature which adds product to cart. so... why you want to duplicate this feature in your module? for what purposes?

Link to comment
Share on other sites

Yes it might not sound rational haha, the thing is that i have changed prestashop in order to get rid of the product page, and instead of this open a modal with the product properties and with an add to cart button (here is where i want to duplicate the add to cart function), this is because i dont want to go to a new page just to see the product page and the modal i think is friendlier for the user. Thanks very much

Link to comment
Share on other sites

I achieved to do it copying it the way it do it in product-list.tpl, with this link:

 

<a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)|escape:'html'}" title="{l s='Add to cart'}"><span></span><!--{l s='Add to cart'}--></a>

 

My problem now is that, althogh the products goes into the cart, the page shown does not go to the url of the href, that would be the page of the cart. That is what I want now, just after doing the click to actually go to the link page, in order to show the changes in the cart. I think this might be something to do with ajax or something like that. It may help if I tell that after doing the click, the link gets a new attribute disabled = "disabled"

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