0

Newbie here. How can I redirect the customize button on its product page?

enter image description here

I've created the button inside the list.phtml

<button type="submit" id="subs" style="margin-bottom:5px;" onclick="window.location.href='{The bag product URL}';">Subscribe</button>

5
  • Submit is used to send form. If you have a form the submit will send you to the action link of your form. If you don't have, any, then you need to do this directly with some js.
    – Claims
    Commented Sep 15, 2022 at 15:42
  • Okay, but how can I get the product url? Commented Sep 15, 2022 at 15:45
  • Checkout this file path - vendor/magento/module-catalog/view/frontend/templates/product/list.phtml , in the line no 71 for magento latest version 2.4.5 ,they have used the product object to get the product URL like this = $_product->getProductUrl() , the $_product object comes from the $_productCollection , please do let me know if any more help is needed. Commented Sep 15, 2022 at 15:55
  • Yes it works. Thanks. Also could you help me on this? magento.stackexchange.com/questions/359940/… @BharathKumarJ Commented Sep 15, 2022 at 16:31
  • Very Happy that it works , can you please do give me a like , this helps me motivate more to post answers , and sure will check out this post. Commented Sep 15, 2022 at 16:47

1 Answer 1

0

Simply you can do it like this.

<?php $productUrl = $_product->getProductUrl();?>
<a href="<?= $productUrl ?>">Subscribe</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.