Jump to content

How to edit Add to Cart result for 1 product not all?


Recommended Posts

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

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

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 by MosheDan9 (see edit history)
Link to comment
Share on other sites

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

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

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