Théo Oliveira Posted March 28, 2021 Share Posted March 28, 2021 Hello guys! I have been researching for a long time about how I can change the function of the Add to Cart button on the homepage of my store, I would like to instead of adding to the cart, redirect to the product page, as all products are personalized. My Prestashop version is 1.7.6.8 Thanks!! Link to comment Share on other sites More sharing options...
Guest Posted March 28, 2021 Share Posted March 28, 2021 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Théo Oliveira Posted March 28, 2021 Author Share Posted March 28, 2021 (edited) 24 minutes ago, Guest said: Change URL from your theme product-list.tpl or add-to-cart-product-list.tpl ...... Each template has it differently. So you can't advise exactly. href="{$product.url}" Hey, @GuestThanks! Below is the code "product-add-to-cart.tpl", could you tell me where to change according to your suggestion? {if Group::getCurrent()->id != 4} <div class="product-add-to-cart"> {if !$configuration.is_catalog} <span class="control-label">{l s='Quantity' d='Shop.Theme.Catalog'}</span> {block name='product_quantity'} <div class="product-quantity clearfix"> <div class="qty"> <input type="number" name="qty" id="quantity_wanted" value="{$product.quantity_wanted}" class="input-group" min="{$product.minimal_quantity}" aria-label="{l s='Quantity' d='Shop.Theme.Actions'}" > </div> <div class="add"> <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url} disabled {/if} > {l s='Add to cart' d='Shop.Theme.Actions'} </button> </div> </div> {/block} {block name='product_availability'} <span id="product-availability"> {if $product.show_availability && $product.availability_message} {if $product.availability == 'available'} <i class="material-icons product-available"></i> {elseif $product.availability == 'last_remaining_items'} <i class="material-icons product-last-items"></i> {else} <i class="material-icons product-unavailable"></i> {/if} {$product.availability_message} {/if} </span> {/block} {block name='product_minimal_quantity'} <p class="product-minimal-quantity"> {if $product.minimal_quantity > 1} {l s='The minimum purchase order quantity for the product is %quantity%.' d='Shop.Theme.Checkout' sprintf=['%quantity%' => $product.minimal_quantity] } {/if} </p> {/block} {/if} </div> {/if} or in the code "product-list.tpl": {block name='content'} <section id="main"> {block name='product_list_header'} <h2 class="h2">{$listing.label}</h2> {/block} <section id="products"> {if $listing.products|count} <div id=""> {block name='product_list_top'} {include file='catalog/_partials/products-top.tpl' listing=$listing} {/block} </div> {block name='product_list_active_filters'} <div id="" class="hidden-sm-down"> {$listing.rendered_active_filters nofilter} </div> {/block} <div id=""> {block name='product_list'} {include file='catalog/_partials/products.tpl' listing=$listing} {/block} </div> <div id="js-product-list-bottom"> {block name='product_list_bottom'} {include file='catalog/_partials/products-bottom.tpl' listing=$listing} {/block} </div> {else} {include file='errors/not-found.tpl'} {/if} {hook h="displayCategoryBottom"} </section> </section> {/block} Edited March 28, 2021 by Théo Oliveira (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted March 28, 2021 Share Posted March 28, 2021 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Théo Oliveira Posted March 28, 2021 Author Share Posted March 28, 2021 (edited) 4 minutes ago, Guest said: 1. Take a screenshot of the page where you see the "Add to cart" button. 2. Write if it is a classic template 3. write if you have a module installed that displays the "Add to cart" button in the list of products are the buttons on that store homepage. I'm using a different theme than the default http://retratodado.com.br/ I'm not using module to display "Add to cart" button - The "Add To Cart" button is translated into Portuguese "Adicionar" Edited March 28, 2021 by Théo Oliveira (see edit history) Link to comment Share on other sites More sharing options...
Guest Posted March 28, 2021 Share Posted March 28, 2021 (edited) . Edited July 26, 2021 by Guest Updated script (see edit history) Link to comment Share on other sites More sharing options...
Théo Oliveira Posted March 29, 2021 Author Share Posted March 29, 2021 7 hours ago, Guest said: Ok. product-add-to-cart.tpl original: <div class="add"> <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url} disabled {/if} > <i class="material-icons shopping-cart"></i> {l s='Add to cart' d='Shop.Theme.Actions'} </button> </div> new: <div class="add"> {if $page.page_name == 'index' || if $page.page_name == 'category'} <a href="{$product.url}" class="btn btn-primary add-to-cart"> <i class="material-icons remove_red_eye">remove_red_eye</i> {l s='View' d='Shop.Theme.Actions'} </a> {else} <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url} disabled {/if} > <i class="material-icons shopping-cart"></i> {l s='Add to cart' d='Shop.Theme.Actions'} </button> {/if} </div> Thanks for the attention @Guest, but I changed the codes as suggested and nothing changed when clicking on the "Add to Cart" button but it changed when clicking on the product image, it just broke, when clicking on the product image I was going to an error page I returned to the original code and the error stopped happening. Link to comment Share on other sites More sharing options...
gojin56321 Posted March 29, 2021 Share Posted March 29, 2021 are the catches on that store landing page. I'm utilizing an unexpected topic in comparison to the default I'm not utilizing module to show "Add to truck" button - The "Add To Cart" button is converted into Portuguese "Adicionar" Link to comment Share on other sites More sharing options...
Guest Posted March 29, 2021 Share Posted March 29, 2021 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Théo Oliveira Posted March 29, 2021 Author Share Posted March 29, 2021 12 hours ago, Guest said: So you wrongly put the modified part of the code. Because the button should have been renamed from Add to cart to View. When editing a TPL file, the Cache must be cleaned up. Script updated. Please test now. nothing works, even clearing all caches nothing changes T.T Link to comment Share on other sites More sharing options...
Guest Posted March 29, 2021 Share Posted March 29, 2021 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Théo Oliveira Posted March 29, 2021 Author Share Posted March 29, 2021 SOLVED! @Guest solved the problem for me in private, if you want to comment on the solution here for other people who are going through this they can also do it .. haha Amazing! Link to comment Share on other sites More sharing options...
Guest Posted March 29, 2021 Share Posted March 29, 2021 (edited) . Edited July 26, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
ignaciodemiguel Posted July 13, 2021 Share Posted July 13, 2021 On 3/29/2021 at 5:50 PM, Guest said: I gladly helped Hello guys How is going ? I hope you are good! 😀 I have the same issue that in the past THEO gets. I would like to instead of adding to the cart, redirect to the product page, as all products are personalized My theme is different to the classic one. I purchased one called MODEZ DIGGO from ROY THEMES Thats our web THANKS Link to comment Share on other sites More sharing options...
4ngeluxpunk Posted August 28, 2021 Share Posted August 28, 2021 En 29/3/2021 a las 10:48 AM, Théo Oliveira dijo: SOLVED! @Guest solved the problem for me in private, if you want to comment on the solution here for other people who are going through this they can also do it .. haha Amazing! Hello, you know that it was modified since I have the same problem when adding the code the design breaks. I remain attentive to your comments. 1 Link to comment Share on other sites More sharing options...
capi15 Posted October 21, 2021 Share Posted October 21, 2021 could you please help me and tell me how he fixed? beeing trying for 2 months and desperate now... thank you very much Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 What is the version of Prestashop ? Is a classic theme used ? Upload here: ./themes/classic/templates/catalog/_partials/product-add-to-cart.tpl or ./themes/your theme/templates/catalog/_partials/product-add-to-cart.tpl or if exists ./themes/your theme/templates/catalog/_partials/custom/add-to-cart-product-list.tpl If you use the Warehouse theme, then I can't help it, the theme is complex and is controlled by a lot of JavaScript. 1 Link to comment Share on other sites More sharing options...
capi15 Posted October 22, 2021 Share Posted October 22, 2021 3 hours ago, WebSoft said: What is the version of Prestashop ? Is a classic theme used ? Upload here: ./themes/classic/templates/catalog/_partials/product-add-to-cart.tpl or ./themes/your theme/templates/catalog/_partials/product-add-to-cart.tpl or if exists ./themes/your theme/templates/catalog/_partials/custom/add-to-cart-product-list.tpl If you use the Warehouse theme, then I can't help it, the theme is complex and is controlled by a lot of JavaScript. Hi there, really appreciate your answer, i use etrend template.web site is this one, https://www.azerted.com i was playing last night with ad to cart tpl, but seem controls add to cart button in product page..... what i need is in main page when client clicks on buy open product page and not add to cart, as potucts are clothes with attributes.. Link to comment Share on other sites More sharing options...
capi15 Posted October 22, 2021 Share Posted October 22, 2021 7 hours ago, WebSoft said: What is the version of Prestashop ? Is a classic theme used ? Upload here: ./themes/classic/templates/catalog/_partials/product-add-to-cart.tpl or ./themes/your theme/templates/catalog/_partials/product-add-to-cart.tpl or if exists ./themes/your theme/templates/catalog/_partials/custom/add-to-cart-product-list.tpl If you use the Warehouse theme, then I can't help it, the theme is complex and is controlled by a lot of JavaScript. prestashop version 1.7.6.2, i tried pasting code that was provided further up in product-add-to-cart.tpl but no changes..... Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 There is an error in the code. Here is a working solution. <div class="add"> {if $page.page_name == 'index' || $page.page_name == 'category'} <a href="{$product.url}" class="btn btn-primary add-to-cart"> <i class="material-icons remove_red_eye">remove_red_eye</i> {l s='View' d='Shop.Theme.Actions'} </a> {else} <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url} disabled {/if} > <i class="material-icons shopping-cart"></i> {l s='Add to cart' d='Shop.Theme.Actions'} </button> {/if} </div> 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 You will also need a force recompile template in the execution settings and clearing the cache. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 (edited) The solution I put in the article is for Prestashop 1.7.6.8, I do not have 1.7.6.2. That's why I wrote you to upload your original file here. Edited October 22, 2021 by WebSoft (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 If you want to display a button other than "Add to cart" when the product has attributes, just edit the condition: {if $page.page_name == 'index' || $page.page_name == 'category' || $product.id_product_attribute == 0} 1 Link to comment Share on other sites More sharing options...
capi15 Posted October 22, 2021 Share Posted October 22, 2021 18 minutes ago, WebSoft said: There is an error in the code. Here is a working solution. <div class="add"> {if $page.page_name == 'index' || $page.page_name == 'category'} <a href="{$product.url}" class="btn btn-primary add-to-cart"> <i class="material-icons remove_red_eye">remove_red_eye</i> {l s='View' d='Shop.Theme.Actions'} </a> {else} <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url} disabled {/if} > <i class="material-icons shopping-cart"></i> {l s='Add to cart' d='Shop.Theme.Actions'} </button> {/if} </div> thank you very much will try! this is my original code, could you tell me were to change. {if Group::getCurrent()->id != 4} <div class="product-add-to-cart"> {if !$configuration.is_catalog} <span class="control-label">{l s='Quantity' d='Shop.Theme.Catalog'}</span> {block name='product_quantity'} <div class="product-quantity clearfix"> <div class="qty"> <input type="number" name="qty" id="quantity_wanted" value="{$product.quantity_wanted}" class="input-group" min="{$product.minimal_quantity}" aria-label="{l s='Quantity' d='Shop.Theme.Actions'}" > </div> <div class="add"> <button class="btn btn-primary add-to-cart" data-button-action="display-product" type="submit" {if !$} disabled {/if} > {l s='Add to cart' d='Shop.Theme.Actions'} </button> </div> </div> {/block} {block name='product_availability'} <span id="product-availability"> {if $product.show_availability && $product.availability_message} {if $product.availability == 'available'} <i class="material-icons product-available"></i> {elseif $product.availability == 'last_remaining_items'} <i class="material-icons product-last-items"></i> {else} <i class="material-icons product-unavailable"></i> {/if} {$product.availability_message} {/if} </span> {/block} {block name='product_minimal_quantity'} <p class="product-minimal-quantity"> {if $product.minimal_quantity > 1} {l s='The minimum purchase order quantity for the product is %quantity%.' d='Shop.Theme.Checkout' sprintf=['%quantity%' => $product.minimal_quantity] } {/if} </p> {/block} {/if} </div> {/if} Link to comment Share on other sites More sharing options...
capi15 Posted October 22, 2021 Share Posted October 22, 2021 16 minutes ago, WebSoft said: The solution I put in the article is for Prestashop 1.7.6.8, I do not have 1.7.6.2. That's why I wrote you to upload your original file here. sorry, didnt know could update file, here it goes! product-add-to-cart.tpl 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 (edited) This is not the correct file. This file is valid for product detail no product list. Your theme will have it elsewhere. Edited October 22, 2021 by WebSoft (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 upload here file: ./themes/etrend/templates/catalog/_partials/miniatures/product.tpl 1 Link to comment Share on other sites More sharing options...
capi15 Posted October 22, 2021 Share Posted October 22, 2021 3 minutes ago, WebSoft said: upload here file: ./themes/etrend/templates/catalog/_partials/miniatures/product.tpl here it goes, thankyou very much for your patience product.tpl 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 (edited) original: new: Your update file: product.tpl Edited October 22, 2021 by WebSoft updated TPL file (see edit history) 2 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 (edited) You can like my posts by clicking on the gray heart below the posts 😉 Edited October 22, 2021 by WebSoft (see edit history) 1 Link to comment Share on other sites More sharing options...
capi15 Posted October 22, 2021 Share Posted October 22, 2021 14 minutes ago, WebSoft said: You can like my posts by clicking on the gray heart below the posts 😉 thankyou soo much! you are ace! any other way i caan thank you? if you like any product in our catalog and you can have it!!! just one question, any problems if i translate button? 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 (edited) Admin -> International -> Translations -> -> select Theme translations -> select yout theme (etrend) -> select language to translation -> Search translations -> View Edited October 22, 2021 by WebSoft (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted October 22, 2021 Share Posted October 22, 2021 Recompile template and clear cache ! 2 Link to comment Share on other sites More sharing options...
capi15 Posted October 22, 2021 Share Posted October 22, 2021 23 minutes ago, WebSoft said: Recompile template and clear cache ! all done and working perfectly!!! i dont know how to thank really! if you like anything let me know!!! 1 Link to comment Share on other sites More sharing options...
Andrzej1234 Posted October 25, 2021 Share Posted October 25, 2021 (edited) Hello all, I have small problem with combinations. What I mean. I have two of them It's BEZ and GRAWER. When I click GRAWER it should open additional options without changing anything else. Problem is when I clik GRAWER picture is changed to last item which I add to shop. I'm new on Presta and I don't know where to search this problem. If you could help me i appreciate. example of product you can find here: https://srebropol.pl/zlota-pozytywka-kon-na-biegunach-z-krysztalkami-swarovskiego-12320 Try to click Grawer below price and watch what happed. In attached is product-customization.tpl Regards Andrzej product-customization.tpl Edited October 25, 2021 by Andrzej1234 (see edit history) Link to comment Share on other sites More sharing options...
ComGrafPL Posted February 28, 2022 Share Posted February 28, 2022 On 10/22/2021 at 3:31 PM, 4you.software said: Here is a working solution. That code should work on my file. Cant make this work. See the original file. product-add-to-cart.tpl Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now