Skip Navigation

[Resolved] Split: Condition in View that depends on intermediary post – QUESTION 1

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 50 replies, has 3 voices.

Last updated by AlimB3245 3 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1765051

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hi Alim, I activated a private reply to share the user that has a value for wpv-user field='wpcf-user-store' as this is needed for the condition on the Brand Owner, right?

Thank you for sharing an example URL, but I still need to fill some gaps, especially why this field will have this value.

Consider the following product hidden link
The linked Brand is "Chopard", right?
Can you give the expected URL for this product?
Can you also explain where the fields came from? From the Brand "Chopard" or from the intermediary post?

I am sure you will understand, that we, supporters, work on several clients' sites and it is difficult for us to keep/remember the context and the data model.
As soon as I understand completely what you would like to get, I'll be more efficient in helping you.
Please explain, with examples(IDs of the involved posts), what would you expect for the URL for the referenced product or for another product.

#1765107

Hi Jamal

Here's the URL to log in

hidden link

(credentials moved to private reply)

When you log in and visit this page

hidden link

you will see the purchase inventory link/button and the URL generated there is as below

hidden link

The last 4 variables are the ones I need.. the rest I have already have..

bo-id
bo-name
bo-email
bo-mobile

they are all custom fields that belong to one brand owner who meets the condition [wpv-user-store]=[eyewear-store]

Chopard Men’s Eyewear Collection Spring/Summer 2020 is the collection that belongs to Chopard the Eyewear Brand

Now Chopard the Eyewear Brand has a brand distributor for India ie Ronak Optik..

so if the optician who logged in had this value in his user data.. if [wpv-user-store] = in and the distributor's [eyewear-store] = in then he is the brand distributor whose id, name, email and mobile I need..

In case there are nultiple distributors who match this condition (if I have chose more than one distributor for the same country by mistake) then the result should be NULL..

The [eyewear-store] field is here..
hidden link

it might be confusing as the name is Distribution Store but the slug is eyewear-store..

Do let me know if you need anything else.

Regards,
Alim

#1765129

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you Alim, I still have some questions:

Consider using the provided user (optician, ID:385), he has its user store equals to "ae", right? hidden link
Consider the product "Chopard Men’s Eyewear Collection Spring/Summer 2020" ID:37253, it is linked to Brand "Chopard" ID:27315, right? hidden link
The Brand "Chopard" is distributed by "Ronak Optik India Pvt. Ltd." with ID:27160, and its Distribution Store equals to "in", right? hidden link

In this case (user store) does not equal to (Distribution store) of the Brand, right?
What are the implications for the expected URL?

What are the expected values for the following fields? I understand that these values come from the current user fields, right?

If this case(same user, same eyewear collection), can you give the expected URL, all the expected values for the fields, and explain where they come from(please provide IDs of the posts or users they come from).

In case there are nultiple distributors who match this condition (if I have chose more than one distributor for the same country by mistake) then the result should be NULL.
Can you provide an example? An eyewear post, a user, and the expected results?

#1765205

Hi Jamal

I think you are trying to get the values in the field .. but the values in the field would be the id, name, email and mobile of the custom post of the BRAND OWNER.

Now what I need is that you get 1 result (if there's 2 it should fail).. from the brand-distributor-eyewear-brand relationship where the logged in user (yes it's current user's fields) = the eyewear store of the distributor..

In this case (user store) does not equal to (Distribution store) of the Brand, right?
What are the implications for the expected URL?

If it does not match then there is no brand owner and hence there will be no ids, name, email or mobile.. simple..:-)..

If this case(same user, same eyewear collection), can you give the expected URL, all the expected values for the fields, and explain where they come from(please provide IDs of the posts or users they come from).

I am not interested in the other fields..;-).. I've already got them.. I only want the grand-parents field which again we have.. I need the condition to be met and if it meets, then just give me the brandowner.. if an brand owner meeting the condition exists I want his id, then I want his name, then I want his email and then I want his mobile..:-)..

Can you provide an example? An eyewear post, a user, and the expected results?
I am not sure I understantand what you mean by an eyewear post, a user etc..
If there's 2 brandowners returned we will have optician buying from 2 distributors.. right? this is not possible as there's supposed to be just one distributor per country.. (this scenario of 2 distributor per country should have never existed but because we have the multiple checkbox option for eyewear store it could happen by mistake).. in this case, the result should be NO BRAND OWNER .. so there's no id, name, mobile or email

Regards,
Alim

#1765209

Please change this to India
hidden link

and then this optician should have had the id for Ronak from this screen
hidden link

because he meets the condition and then I want the id, name, email and mobile of Ronak..

In case by mistake there was a another distributor with the eyewear-store as in, then the result should be NO DISTRIBUTOR instead on 2 Distributors (if this is complicated let's avoid it for now).. I would be happy to just get the id of Ronak and not worry about the IF THERE WERE 2 DISTRIBUTORS scenario..;-)..

Regards,
Alim

#1765235

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you Alim, I still need your confirmation on one case and an example for the other case(s).

If we change the store for the user to "India" here hidden link the field needs to be pulled from Ronak ID:27160. So the following fields should return these values hidden link
bo-id
bo-name
bo-email
bo-mobile

Can you confirm that? If yes, can you enter values on these fields and confirm the target URL?

In case by mistake there was another distributor with the eyewear-store as in, then the result should be NO DISTRIBUTOR instead on 2 Distributors (if this is complicated let's avoid it for now).. I would be happy to just get the id of Ronak and not worry about the IF THERE WERE 2 DISTRIBUTORS scenario..;-)..
Can you create an Eyewear collection post to demonstrate this case? This way, we won't be building half solutions that will break later.

I am still confused, and I am not sure if we will come up with a solution involving custom code or just Toolset views and conditions.

#1767107

Hi Jamal

Apologies for the delay.. As mentioned I had the launch of the project on Saturday so I was busy with that.. we went ahead without the 'eyewear collection profile' feature.. it wasn't really the focus so no worries..;-)..

Can you confirm that? If yes, can you enter values on these fields and confirm the target URL?
you got most of it right.. the

bo-name=<wpv-post-title>
bo-id=[types field='id'][/types]
bo-email = [types field='notification-email' separator=','][/types]
bo-mobile=[type field='notification-mobile']

So you got 3 of them right in your screenshot.. the email is the notification email and it can be multiple values as we can add multiple email ids there.. and the separator is a comma.

I've update the Brand Owner Details as requested .. so the URL would be this

hidden link Optik India Pvt. Ltd.&bo-email=ronak@fourplusmedia.com,jamal@toolset.com&bo-mobile=+91123456789

Hope that is clear...:-)..

Regards
Alim

#1767131
Screen Shot 2020-09-06 at 10.13.05 AM.png

For the second part of the requirement

Can you create an Eyewear collection post to demonstrate this case? This way, we won't be building half solutions that will break later.

Please check this..
hidden link

I have added a distributor Chopard for UAE.. so it would have Ronak for India and FourPlus Vision for UAE... But by mistake I have checked the IN checkbox for FourPlus Vision... (screenshot attached)

So in this case if the optician's user-field USER STORE were to be United Arab Emirates, it would show FourPlus Vision bo-id, bo-name, bo-email and bo-mobile.. which would be perfect..

BUT if you were to change the optician's user-field USER-STORE to India, it should show NULL as there are 2 distributors for IN, which is technically a mistake by me as I have clicked on the checkbox INDIA on both distributors.. so the result should be NULL ie the fields bo-id and the others would have blank values.

Hope this is clear..:-)..

I feel if you were to see the VIEWS created here it would help you understand how this can be achieved.. I've achieved this for BRAND PROFILE where we have a BRAND TO DISTRIBUTOR parent relationship.. in this case the difference is it's EYEWEAR COLLECTION to BRAND DISTRIBUTOR grand-parent relationship.. but the logic remains the same..

Here's the CONTENT TEMPLATE of the BRAND PROFILE where you can view the Purchase Inventory button and the URL we have generated.

hidden link

and the URL we have generated.

hidden link field='wpcf-user-store' output='raw'].youandeyemag.com/?eb-id=[types field='id' output='raw'][/types]&eb-name=[wpv-post-title]&logo=[types field='eyewear-brand-logo' output='raw'][/types]&ad-banner=[types field='eyewear-brand-banner' separator=',' output='raw'][/types]&oe-id=[wpv-user field='wpcf-user-employee-id' output='raw']&os-id=[wpv-user field='wpcf-user-organisation-id' output='raw']&os-name=[wpv-user field='wpcf-user-organisation-name' output='raw']&os-email=[wpv-user field='wpcf-user-notification-email' separator=',' output='raw']&os-mobile=[wpv-user field='wpcf-user-notification-mobile' output='raw']&bo-id=[wpv-view name='related-brand-distributor-eyewear-brand-brand-distributor-id']&bo-name=[wpv-view name='related-brand-distributor-eyewear-brand-brand-distributor-name']&bo-email=[wpv-view name='related-brand-distributor-eyewear-brand-brand-distributor-notification-email']&bo-mobile=[wpv-view name='related-brand-distributor-eyewear-brand-brand-distributor-notification-mobile']&&seller-order-notification=[wpv-view name='related-brand-distributor-eyewear-brand-brand-distributor-order-notification']

I just realised we might need this too in the above
seller-order-notification=[wpv-view name='related-brand-distributor-eyewear-brand-brand-distributor-order-notification']

It's a checkbox value of true or false that we have as a field i(order-notification) in the brand-owner details

Hope this is clear..

Regards,
Alim

#1769437

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

I am really sorry that we were not able to get this done before last Saturday. But, I am sure you will understand that I do not understand your setup and data model as much as you or any member of your team. Or at least, that I may forget because of how many clients' sites I need to work on between our replies.

Thank you very much, Alim, for this informations. Unfortunately, I can't verify it on the backend in order to be sure of understanding what is expected.

Currently, there is some kind of server errors that do not allow the backend to fully load, as a result, the Toolset sections that display custom fields values, and the relationships of posts are not visible on the backend. Check these screenshots:
- Eyewear Collection: hidden link
- Eyewear Brand: hidden link
- Brand Owner: hidden link

For example, I can't verify if the "bo-id" in the following URL should 1234 or 27315, or 27160.
hidden link Optik India Pvt. Ltd.&bo-email=ronak@fourplusmedia.com,jamal@toolset.com&bo-mobile=+91123456789
<b>Can you confirm what ID exactly would we expect?</b>

I'll need to have the backend editor to load the Toolset sections in order to check the values and test against them while working on this. Check this error in the source code hidden link
In order to debug this error, we'll need to activate PHP debugging to see what errors are logged in the debug.log file. https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#php-debugging

We may need to deactivate a plugin or switch the theme of they are causing this error.

#1769955
Screen Shot 2020-09-09 at 9.29.43 AM.png

Hi Jamal

I think last night, there was some issue with the WPMU plugin hummingbird and I have deactivated it.. hopefully you should be able to access the relationship fields. Please do check and confirm.

Can you confirm what ID exactly would we expect?
For example, I can't verify if the "bo-id" in the following URL should 1234 or 27315, or 27160.
hidden link Optik India Pvt. Ltd.&bo-email=ronak@fourplusmedia.com,jamal@toolset.com&bo-mobile=+91123456789

I am not sure what the questions implies.. as the id is mentioned in the URL above that you pasted.. it's 1234.. the [types field="id"].. it's part of the CUSTOM GROUP 'Admin' where we have id, email, ye-verified and stores (screen-shot attached)

Do let me know if you need any other clarifications.

Regards,
Alim

#1770823

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you, Alim for confirming the bo-id.
But there is still an issue on your website and I can't see Toolset Metaboxes, check this screenshot hidden link

Let me know when your site is stable and I'll take it from there.

#1771537
Screen Shot 2020-09-10 at 11.06.18 AM.png

Hi Jamal

It seemed to be a strange problem.. the user 'developer' was a part of the multisite and iin network admin it showed him as connected to 4 subsites (including youandeyemag) but when I checked the users in the subsite this user would not show.. as I had given it superadmin privileges I am assuming it was still able to access the data in the subsites.. not sure..;-)..

But anyways I deleted the user and added a new one with the same name and credentials and logged in and checked.. am able to see all details now.. (screenshot attached)

Hopefully this issue will now get resolved.. it's run into 3 pages already!!..;-).. he he..

Do let me know if you have any further queries.

Have a nice day..:-)..

Regards,
Alim

#1772055

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you, Alim. I am working on this, but I am facing several issues that I am not yet able to narrow down.

- I registered a shortcode and it is not working.
- Toolset views shortcode for returning the current user is not working too. Probably a bug on multisite installs.

I'll get back to you as soon as possible.

#1773349

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Alim,

I just want to let you know, that I am progressing in this request. But I find it hard to come up with the right solution, especially as custom code can crash and I need to access the debug.log file.

So far, I have created a view for getting the list of distributors. I want to use it in a custom shortcode, but I'll need to get this working in my local(development) environment, I'll get back to you as soon as I get it produced.

#1773361

Hi Jamal

Thanks for the update..:-)..

I am glad to know you are making progress...

Keep me posted

Have a nice day..:-).

Regards,
Alim

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.