Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category Ajaxcall not working with Magento 2.4.7-p1 and latest Hyvä Theme (1.3.9) #28

Open
Muhamann opened this issue Jul 24, 2024 · 2 comments

Comments

@Muhamann
Copy link

Muhamann commented Jul 24, 2024

Describe the bug
Into-Cart Action on category-page results in wrong API call:
checkout/cart/add/uenc/%25uenc%25/product/1394/

To Reproduce
Steps to reproduce the behavior:

  1. Go to category page
  2. Click on into-cart-button
  3. See error in console / network

Magento version
Magento ver. 2.4.7-p1

Hyva Versions
Hyvä Default Theme: ver. 1.3.9 (latest)

Solving
The error comes from
vendor\monsoonconsulting\magento2-hyva-ajax-add-to-cart\view\frontend\templates\hyva\script\addtocart.phtml
line 31: e.preventDefault();
This line deactivates the functionality in hyvä file:
vendor\hyva-themes\magento2-theme-module\src\view\frontend\templates\page\js\set-uenc.phtml

So this line of code in set-uenc.phtml is never called:
event.target.action.replace('%25uenc%25', hyva.getUenc())
and the result is, that the form URL is the wrong from above:
checkout/cart/add/uenc/%25uenc%25/product/1394/

So solve the issue, the following line must be included in
vendor\monsoonconsulting\magento2-hyva-ajax-add-to-cart\view\frontend\templates\hyva\script\addtocart.phtml:

e.target.action = e.target.action.replace('%25uenc%25', hyva.getUenc());

It must be inserted before:
e.preventDefault();

@callanzimmermann
Copy link
Collaborator

Hey @Muhamann, thanks for flagging this. I will test this later and check the fix you've suggested.
I'll keep you in the loop when it's done.

@Muhamann
Copy link
Author

Hey @Muhamann, thanks for flagging this. I will test this later and check the fix you've suggested. I'll keep you in the loop when it's done.

Thanks.
Of course i am not sure, if i have choosen the most elegant solution ;)

Thank you for your nice module by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants