Closed Heave-be closed 1 year ago
Hi @Heave-be,
thanks for your detailed comment.
What you described is somehow the intended behavior.
For $cart->add()
, you have to pass the page’s id (not uuid). Internally the id
is renamed to key
– for several reasons.
You can remove the cart item with this specific key
using the $cart->remove()
method.
I tried to use the Page’s uuid
instead of id
. Theoretically this should work. Practically the key
is transformed to lowercase. Page uuid
s are case sensitive. So they are stored with a lowercase key
. When $cart->remove()
is called, the method wants to remove the case sensitive uuid
. E.g. item is stored as page://yewqbkkpvrwbqfbw
, $cart->remove('page://yEWQBkKPvrwBQfBw')
does not work.
Long story short, I modified ProductList::__set()
(which is called when using $cart->add()
) and and removed the conversion to lowercase (e56f9b1ec7c0574634f6ff977dbf135c13f7a106). You can download the develop branch and see if it works for you.
Hi @tobiasfabian,
Cheers for the response!
I tested your develop branch with the Merx plainkit (changed to add products to cart by UUID) seems to be working fine now with the removal of the conversion to lowercase.
Thanks for the "fix"!
Hi,
Love the plugin and the flexibility. I've implemented it into a project, but seem to be having a very strange issue.
The following piece of code should normally work based on the docs:
For some reason this doesn't actually remove the product, but it doesn't trigger the catch block either. ID variable is correct for the product i'm trying to remove.
If I simply display the cart on a page like this:
I get a number of UUID's from products (which are all correct). If I then use the following piece of code to manually remove one of the products:
The product doesn't get removed from the cart either.
Is there something I'm missing here?
—————
EDIT:
After a bit of research and scratching my head, this is what I found out.
When a product is added as follows:
Everything works as intended. Product can be removed from the cart by using the id. However, when adding a product to the cart with a UUID, it causes the bug as explained above:
Is this intended behaviour or a bug?