Request fot coupon not working

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
heural
Posts: 58
Joined: 09 Jun 2022, 07:55

Request fot coupon not working

Post by heural » 25 Apr 2023, 08:36

Hi Aimeos-Team,

if I request a coupon code in the basket, the called url in the xhr-Request is http://maydomain/undefined

The code in basket-standard.js makes no sense for me: what is product.data("url")?

Code: Select all

onSubmit() {

                $(document).on("submit", ".basket-standard form", ev => {
                        Aimeos.createSpinner();

                        fetch(product.data("url"), {
                                body: new FormData(ev.currentTarget),
                                method: 'POST'
                        }).then(response => {
                                return response.text();
                        }).then(data => {
                                $(".basket-standard").html(AimeosBasket.updateBasket(data).html());
                        }).finally(() => {
                                Aimeos.removeSpinner();
                        });

                        return false;
                });
        },
If I changed to "ev.currentTarget.form.action" the form works...

Thank you!

User avatar
aimeos
Administrator
Posts: 7885
Joined: 01 Jan 1970, 00:00

Re: Request fot coupon not working

Post by aimeos » 26 Apr 2023, 06:54

You mean this line?

Code: Select all

body: new FormData(ev.currentTarget),
Using "ev.currentTarget.form.action" seems to be wrong too but "ev.currentTarget.form" may be correct.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

heural
Posts: 58
Joined: 09 Jun 2022, 07:55

Re: Request fot coupon not working

Post by heural » 03 May 2023, 11:56

No, I mean

Code: Select all

  fetch(product.data("url"), {
there is no "product" object present.

So if i change to

Code: Select all

 fetch(ev.currentTarget.form.action, {
the request works.

User avatar
aimeos
Administrator
Posts: 7885
Joined: 01 Jan 1970, 00:00

Re: Request fot coupon not working

Post by aimeos » 07 May 2023, 11:02

You are right, that doesn't make any sense but your suggested code doesn't work either in all situations. Instead, we are now using this line, which seem to work perfectly:

Code: Select all

fetch($(ev.currentTarget).attr("action"), {
The updated code is available in aimeos/ai-client-html:2022.10.x-dev. Can you check if it now works for you too?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply