I'm seeing several solutions online but I'm not sure which covers all bases, or where exactly to put the customization.
Can i know where you want to change URL?(Category /Product Page)
Either one. Product page first. I just found a bunch of references to it in the code, and I'm hoping I don't have to change all of them.
Hello @dhinged
Magento 2 calling below file for get Add to cart url
Magento\Catalog\Block\Product\AbstractProduct
public function getSubmitUrl($product, $additional = []) { $submitRouteData = $this->getData('submit_route_data'); if ($submitRouteData) { $route = $submitRouteData['route']; $params = isset($submitRouteData['params']) ? $submitRouteData['params'] : []; $submitUrl = $this->getUrl($route, array_merge($params, $additional)); } else { $submitUrl = $this->getAddToCartUrl($product, $additional); } return $submitUrl; }
you need to create the plugin for that and edit that URL.
Hope it will help you if it will help you then give Kudo or accept as solution.
Hi, this looks feasible but I've only developed in Magento 1 and developing a plugin in Magento 2 looks pretty different (I'm used to the code pools like core/local/community)... can you recommend some basics or a tutorial?
I'm currently going through this - https://www.demacmedia.com/create-a-magento-2-plugin/ - but I'm not sure how good it is... I have no `src` folder in my Magento 2.2.2-dev folder, and I haven't used composer with Magento yet (though I have with other software).
Please check below link for same
https://www.mageplaza.com/magento-2-module-development/magento-2-plugin-interceptor.html
let me know if you have any question.
If it will help you then give us kudos or mark as solution.