radge Posted April 16, 2018 Share Posted April 16, 2018 0down votefavorite I have modified the tpl file of the cart so that it has this new functionality, that when a user adds a product it shows a series of recommended products. The code of the tpl file what it does is to make a call to a static method by skipping the controller and returning an array of objects, this does and it works correctly. {foreach from=$cars item=book key=key} {assign var=id_image value=$car->getFullCoverId($carid)} <div class="col-12 col-md-4 col-lg-3 book"> {assign var=auxExplode value=": "|explode:$carname} <img alt="book" src="{$link->getImageLink($car->link_rewrite, $id_image, 'home_default')}"> <span class="grey-small">{$auxExplode[0]}</span> <span class="tittleB marbot">{$auxExplode[1]}</span> {if $car->available_for_order == 1} <form action="{$urls.pages.cart}" method="post" id="add-to-cart-or-refresh-2"> <input type="hidden" name="token" value="{$static_token}"> <input type="hidden" name="id_product" value="{$car->id}" id="product_page_product_id"> <input type="hidden" name="id_customization" value="{$car->id_customization}" id="product_customization_id"> <button id="X" class="btn btn-primary add-to-cart comprar_mat" data-button-action="add-to-cart" type="submit"> {l s='Add to cart' d='Shop.Theme.Actions'} </button> </form> <span class="cursive-span-button">{l s="Price:"} {$carprice}€*</span> {/if} </div> {/foreach} This code at the end shows a form for each button and then what I do from the back is in the JS file refresh the page with this code $body.on( 'click', '#add-to-cart-or-refresh-2', (event) => { event.preventDefault(); updateProductQuantityInCart(event); location.reload(); } ); The problem is that this code works sometimes if and some do not ... and I can not see the fault, I do not know if someone can give me some idea / suggestion or some other way of doing this. Thank you 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