MosheDan9 Posted April 22, 2016 Share Posted April 22, 2016 Hi I am looking for a coding solution so that I can modify the results of clicking "add to cart" for just one of my products and not all of them. Really what I would like to do is send the customer to my amazon.com book which I cannot sell on my product store. so instead of add to cart on homepage and on product page for product X adding it to cart, I'd like it to send to linkX in new window. How can I do this? Link to comment Share on other sites More sharing options...
NemoPS Posted April 23, 2016 Share Posted April 23, 2016 I guess you need to check for its ID. In product-list.tpl, locate <a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart', true, NULL, $smarty.capture.default, false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product-attribute="{$product.id_product_attribute|intval}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{if isset($product.product_attribute_minimal_quantity) && $product.product_attribute_minimal_quantity >= 1}{$product.product_attribute_minimal_quantity|intval}{else}{$product.minimal_quantity|intval}{/if}"> <span>{l s='Add to cart'}</span> </a> You can wrap this in a condition, like {if $product.id_product == 67} ... amazon link ... {else} show that button {/if} Link to comment Share on other sites More sharing options...
MosheDan9 Posted April 24, 2016 Author Share Posted April 24, 2016 Thank you. I can edit code but I am not a coder so I don't understand your language "You can wrap this in a condition," Link to comment Share on other sites More sharing options...
MosheDan9 Posted April 24, 2016 Author Share Posted April 24, 2016 (edited) like this?? (i inserted it in red <a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart', true, NULL, $smarty.capture.default, false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product-attribute="{$product.id_product_attribute|intval}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{if isset($product.product_attribute_minimal_quantity) && $product.product_attribute_minimal_quantity >= 1}{$product.product_attribute_minimal_quantity|intval}{else}{$product.minimal_quantity|intval}{/if}" "{if $product.id_product == 67} ... amazon link ... {else} show that button {/if}"> <span>{l s='Add to cart'}</span> </a> any help much appreciated to tweak this if it is not written properly. Edited April 24, 2016 by MosheDan9 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted April 25, 2016 Share Posted April 25, 2016 No, before the <a The a this (all of it, to the closing </a>) should sit in place of "show that button" Link to comment Share on other sites More sharing options...
Prestachamps Posted April 25, 2016 Share Posted April 25, 2016 HI If you want only to replace the link to be the amazon link, then your code should look like this(red code is the new code): <a class="button {if $product.id_product != 67}ajax_add_to_cart_button{/if} btn btn-default" href="{$link->getPageLink('cart', true, NULL, $smarty.capture.default, false)|escape:'html':'UTF-8'}{/if}" rel="nofollow" title="{l s='Add to cart'}" data-id-product-attribute="{$product.id_product_attribute|intval}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{if isset($product.product_attribute_minimal_quantity) && $product.product_attribute_minimal_quantity >= 1}{$product.product_attribute_minimal_quantity|intval}{else}{$product.minimal_quantity|intval}{/if}" > <span>{l s='Add to cart'}</span> </a> Another thing is the first red IF , where you have to remove the class "ajax_add_to_cart_button" from the button in case of the amazon link button, in order to disable the blockcart's default add to cart functionality(the ajax add to cart, wich is not taking in consideration the href of the product) . Since you remove that class, your button will loose some of the css rules/design of the button, you may need to add a different class in case of your button, and add that class to the same css where the ajax_add_to_cart_button is. Regards, Leo Link to comment Share on other sites More sharing options...
NemoPS Posted April 25, 2016 Share Posted April 25, 2016 Well no, that would still send the user to the cart page. It will just run without ajax, but still run Link to comment Share on other sites More sharing options...
MosheDan9 Posted April 25, 2016 Author Share Posted April 25, 2016 So like this> "{if $product.id_product == 67} ... amazon link ... {else} <a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart', true, NULL, $smarty.capture.default, false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product-attribute="{$product.id_product_attribute|intval}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{if isset($product.product_attribute_minimal_quantity) && $product.product_attribute_minimal_quantity >= 1}{$product.product_attribute_minimal_quantity|intval}{else}{$product.minimal_quantity|intval}{/if}" <span>{l s='Add to cart'}</span> </a>{/if}"> does it all close up ok? Link to comment Share on other sites More sharing options...
MosheDan9 Posted April 25, 2016 Author Share Posted April 25, 2016 (edited) Obviously not. I tried it and it didn't seem to do... anything. No error messages. Also product "67" also added to cart. Edited April 25, 2016 by MosheDan9 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted April 27, 2016 Share Posted April 27, 2016 You must close the if at the very end, not before >And make sure you remove the " Link to comment Share on other sites More sharing options...
Prestachamps Posted April 30, 2016 Share Posted April 30, 2016 Hi, Please provide us the url of the test product, then I can verify it exactly 1 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