Answer the question
In order to leave comments, you need to log in
Why is the item added to the cart when I select a category?
READY TO PAY for solving my problem
Already asked a question, decided to duplicate it. Suddenly lucky. The site implements a choice of the type of
layouts
, how it was implemented, I painted it in detail last time here .
I calmly switch templates from table to tile and back, everything works fine, BUT as soon as I add an item to the cart, the DOOMSDAY MECHANISM starts, which does not let me sleep!
After we have added any product to the cart (regardless of which table or tile template), each template switch reacts by ADDING the product that we added manually to the cart. And this effect does not end. How many times we switch the mode, so many times the product will be added to the basket.
If we open the basket and remove, for example, 1 product from there, the mechanism will be deactivated and we can again easily switch modes until we add something else to the basket.
I also found out by typing: If you add a product to the basket and then refresh the page, then:
1. when you click on the basket (not the ADD TO CART button, just the basket at the top), the goods will always open in a tiled layout. Removing the cart plugin and installing it myself through the code did not fix the situation, so I returned the code.
2. adding goods is buggy, they are added every other time.
I also want to note that there are only 3 plugins on the site: Advanced search, Cart menu, Pagination styler. I deleted all these plugins, nothing changed. WordPress installed today, no more changes (except for CSS styles and search output through the addition of an additional widget zone - it's probably the code found in the source).
Without the mode switching feature, the site works fine in tabular form. All problems arise precisely in this thing in the .php function But unfortunately, what is written in it is like a Martian manuscript for me ...)))
SITE: https://automechanic24.rf
SHOP
tab
thank.
Answer the question
In order to leave comments, you need to log in
Everything is elementary, because the formation of a link to switch the template is crooked and the same trouble with adding to the cart, when you put an item in the cart, you put it with the link
https://xn--24-6kcajswqomh1c3b.xn--p1ai/shop /?add-... and then a bug, the url should not change
when you switch the template, you switch it via the link
https://xn--24-6kcajswqomh1c3b.xn--p1ai/shop/?cat_...
Respectively when you put the product in the cart and switch the template, the link looks like
https://automechanic24.rf/shop/?add-to-cart=8336&ca...
She says, switch the view to a table view and put the product with id = 8336 in the cart
It was done so because of the crooked code, what is the crookedness without climbing under the hood is not to be guessed. As an option, it makes sense to enable adding goods to the cart through Ajax, WC has such a setting
Well, look what you have transferred to the link to change the display. Check why.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question