Problems, need help? Have a tip or advice? Post it here.
15 posts Page 2 of 2
I see, that we should have 2 scenarios here.
1st - add product to cart by unique pp_id.
2ns - sort products in cart by page_name.
It was the desired way.

Now, the real actual scenario is that product is added only if can be sorted.
Kinda like that. And it should not be so.

:!: I will accept promotion if this is a real bug, found in the heart of cart system. :!:


Anyway, now fixing this is something that can be done only by KK, as he realizes all implications of changes are to be made.
Thank you all, who followed this.
:D
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi @trendoman,

Now, the real actual scenario is that product is added only if can be sorted.
Kinda like that. And it should not be so.
Could you please post some screenshots displaying the behaviour?

Also do you see it with the multi-template setup you are experimenting with or do you see it even in the normal setup of single product template?
KK wrote: Hi @trendoman,

Now, the real actual scenario is that product is added only if can be sorted.
Kinda like that. And it should not be so.
Could you please post some screenshots displaying the behaviour?

KK, this is a description of algo from previous message, i left 2 posts and 1st post got left on the bottom of the first page of this thread.
Please, confirm that you saw 1st post. I also explained my debug process there.

Regarding the screenshots, you have probably seen it already first hand live on site100/client/test Adding product with the same name adds to quantity. That's because the algo in cart.php works so (as I showed in 1st post).

KK wrote: Also do you see it with the multi-template setup you are experimenting with or do you see it even in the normal setup of single product template?

We can not see it on single product template, because it is not possible to create 2 pages with the same page_name in one template.

Let me reiterate it here: your algo adds product to cart if page has a unique name. This should be amended to, perhaps, unique id.

EDIT:
As an update, to make it easier. Line 305-310, cart.php. This is the source of trouble.
Code: Select all
                        if( $all_ok ){
                            $arr_sort_keys = array(); // used to sort items in the cart
                            $arr_display_attrs = array(); // an array of all selected variant options with values
                            $arr_sort_keys[] = $pg->page_name;

Then come Line 360+, which behavior I already described before.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
You are right, I missed the previous post.

Ok, so I get what the problem is.
Point is I don't think it can be termed as a bug because the current architecture expects only a single product template. Since you are trying to use multiple templates (something the cart was not built for) there are bound to be use-cases where you'll run into such things.

Coming to the problem, one way could be to add the template name also to the sorting key.
What do you say? Please give it a try.
Problem solved in its fullest scope.
Changed
$arr_sort_keys[] = $pg->page_name;

to
$arr_sort_keys[] = $pg->id;


First, I wanted to explain everything as clearly and slowly as possible. And wait for your evaluation, coz only you know what implications can bring the change in system code. Maybe you have some other checks later with those varables.

However, in pursue to solve the annoying bug, I changed this by my understanding and now I can add products with no problem even when page_name is not unique.

Thank you, KK, for inspiration. You make me learn stuff FTL.

PS I still call this a bug, coz you laid here on top of something very specific. You rely on the idea that page_name is unique in template. But this is not sustainable (background condition). What is really sustainable in design is using unique values (pids). And free mind of some background conditions for the code to work in 3 years later :)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
15 posts Page 2 of 2
cron