Jump to content

Adding a Link to the Cart Button


Recommended Posts

Im having a bit of a dilemma, I was wondering if there is a module or a way of doing the following:

Changing the cart button, so instead of clicking on 'add to cart' and going to a new page like normal, I want to be able to add a unique link to that button, that will open up another site. Is this possible?

Thanks

Link to comment
Share on other sites

  • 3 weeks later...

Now that I look at it, the "Add to cart" button on the product page is actually a form submission, not a link. I think you'll need to change line 117 of product.tpl:

<form id="buy_block" action="{$base_dir}cart.php" method="post">



to:

<form id="buy_block" action="{$product->location}" method="get">



This will go to the link in the product location field and add the data at the end of the url like ?qty=

Link to comment
Share on other sites

  • 2 months later...

Hi!
i tested this link with $product->location as Rocky said,and it is succesfull.but when i tryed with another link :
http://localhost/rest/category.php?id_category=5
prestashop answers that

1 error
1. the field location is invalid

it seems that some special characters are not allowed

how can i put the link to add to cart button?i am not a developer and i do not know how to code it

Link to comment
Share on other sites

  • 4 weeks later...

I've got this working with Add to Cart going to a link from the product page, but the Add to Cart button on the featured products page still goes to the cart. I have the same problem as the post above with invalid characters (affiliate links) Any suggestions?

Link to comment
Share on other sites

  • 10 months later...

From Rocky, updated code for this task in 1.4.

 

I suggest entering the unique URL for each product in the Location field of the product, then change the "Add to cart" button in product.tpl to something like this:

 

 

<a href="{$product->location}" target="_blank">{l s='Add to cart'}</a>

 

 

and in product-list.tpl:

 

 

<a href="{$product.location}" target="_blank">{l s='Add to cart'}</a>

 

 

This will open the URL entered in the location field in a new window. The customer will then need to close the window to return to your site.

 

Thank you Rocky!

Link to comment
Share on other sites

  • 4 years later...

Done it, just to test, I insert the URL on the description_short field (import from CSV) (you can change description_short for any other field)

 

on  prouct.tpl

 

Change

 

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

 

to

 

<form id="buy_block"{if $PS_CATALOG_MODE && !isset($groups) && $product->quantity > 0} class="hidden"{/if} action="{$product->description_short|escape:'html':'UTF-8'}" method="post" target="_blank"

 

 

this will open the link on a new window. If you want to open it in the same window, delete target="_blank"

 

on produc-tlist.tpl

 

change current line to this one (line 157)

 

<a class="button ajax_add_to_cart_button btn btn-default" href="{$product.description_short|escape:'html':'UTF-8'}" method="post" target="_blank"> 

 

 

 

Link to comment
Share on other sites

×
×
  • Create New...