Closed rjsmazevedo closed 4 years ago
Hi, I can see there are a couple of issues with the code here, I'll submit proposed changes shortly.
Firstly, the attribute parameters are only tested for Post not for Get usage. Secondly, the code for handling various not found is incorrect in several ways:
testing with WP5.4.2 woo4.2.2 polylang 2.7.3 php7.4.2 and urls like: language/es/basket-es/?add-to-cart=472&quantity=1&attribute_pa_color=negro
the variation matching by attribute is WooCommerce native functionality in find_matching_product_variation() in class-wc-product-data-store-cpt.php which matches by slug. In Polylang context the attribute value slug should be the correct slug for the current language. Then this plugin attempts to determine what to do if a matching variation is not found.
addToCartHandlerVariable() in this plugin originated as a version of the WooCommerce function add_to_cart_handler_variable() in class-wc-form-handler.php
It appears that the customisation added had the intention of handling situations where add-to-cart is called with product in a different language from the current user interface language. On examination, the customisation does not appear to handle the original intention well, and introduces other problems and compatibility issues with other plugins which may also hook items added to cart.
I suggest therefore removing the customisation from this plugin which you could try in your local version by commenting out lines 45-46 of woo-poly-in tegration/src/Hyyan/WPI/Product/Cart.php
Please note: Hello,
When adding the plug-in, or the add to cart link, stop working with the translated attribute. But disable the plugin or get back to working again. Some help? Did the translation or "attribute_pa_ac" change you?
LINK: cart/?add-to-cart=9038&quantity=1&attribute_pa_ac=00
What product versions and settings are you using when this issue occurs?