Post by Steyn » Thu Jan 26, 2017 8:48 pm

Does anybody know of a free add to cart button redirect module to external link? If not, does anybody know how to manually change the link of the add to cart button on the product page? Ver 2.3.0.2

Newbie

Posts

Joined
Sat Nov 19, 2016 6:19 pm

Post by thekrotek » Thu Jan 26, 2017 9:25 pm

What exactly are you trying to achieve? Why do you want external link?

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Steyn » Thu Jan 26, 2017 9:45 pm

as in an Affiliate link

Newbie

Posts

Joined
Sat Nov 19, 2016 6:19 pm

Post by thekrotek » Thu Jan 26, 2017 9:47 pm

So basically you want to display products from YOUR database, but Add to Cart button should redirect customer to 3rd party site?

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Steyn » Thu Jan 26, 2017 9:50 pm

That is correct. I know there is a few good modules one can buy, but with our weak currency, that will be very expensive for me.

Newbie

Posts

Joined
Sat Nov 19, 2016 6:19 pm

Post by thekrotek » Thu Jan 26, 2017 9:56 pm

Guess, in this case you need to have an extra field on product editing page, something like Redirect Link. You need to query this field on front-end and replace all occurrences of cart.add() functions in your template with this redirect link. It's not hard to do, but not something you can achieve without some knowledge in coding.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Steyn » Thu Jan 26, 2017 9:58 pm

OK thank you for your reply

Newbie

Posts

Joined
Sat Nov 19, 2016 6:19 pm

Post by angela » Fri Jan 27, 2017 2:35 am

Did this on one of the sites I'm working on:
Steyn wrote:Does anybody know of a free add to cart button redirect module to external link? If not, does anybody know how to manually change the link of the add to cart button on the product page? Ver 2.3.0.2
In line with thekrotek's suggestion (adding the field to the db, calling that field in the query returns from catalog/model/catalog/product.php & catalog/controller/product/product.php)

You can do something as easy as this in catalog/view/theme/mytheme/template/product/category.php & product.php (basically, anywhere that add to cart button shows - there's quite a few places; search engine, manufacturer pages, etc.):

Find:

Code: Select all

<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>', '<?php echo $product['minimum']; ?>');"><span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span> <i class="fa fa-shopping-cart"></i></button>
Replace with:

Code: Select all

<?php
if ($affiliate_link) {
?>
    <button type="button" onclick="location.href=('<?php echo $affiliate_link;?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart;?></span></button>
<?php } ?>
That way, you can have both an affiliate field and your own products loading. If $affiliate_link returns blank, it defaults to the native add to cart button.

User avatar
New member

Posts

Joined
Fri Dec 02, 2016 2:14 am

Post by thekrotek » Fri Jan 27, 2017 3:12 am

angela wrote:You can do something as easy as this in catalog/view/theme/mytheme/template/product/category.php & product.php (basically, anywhere that add to cart button shows - there's quite a few places; search engine, manufacturer pages, etc.)
Files' extension is .tpl and there're also modules, don't forget them. Every module also have cart.add() function.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Steyn » Fri Jan 27, 2017 4:26 am

Thank you Angela

Newbie

Posts

Joined
Sat Nov 19, 2016 6:19 pm
Who is online

Users browsing this forum: Baidu [Spider] and 62 guests