Skip Navigation

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

This support ticket is created 3 years, 8 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+01:00)

This topic contains 50 replies, has 3 voices.

Last updated by AlimB3245 3 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1760147

The eyewear-store field is not used in the front end.. it's a field in the intermediary post for brand-distributor-eyewear-brand relationship

Here's the link to edit the eyewear-store field

hidden link

you have already worked with it here on the ticket below where you created a custom function for me..

https://toolset.com/forums/topic/condition-in-view-that-depends-on-intermediary-post/

Regards,
Alim

#1760151

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok great - the field label you set as "Distribution Store" that is why I was not able to find that field.

Now, I would like to know, have you added the following view anywhere?
=> hidden link

#1760353

Hi Minesh

No, I haven't used it anywhere.. In fact I was a bit confused if I should use a view with a loop or not.. as it's a single variable.. but I realized you do have to loop through the multiple distributors to check the eyewear store and I had no idea how to do that..;-)..

Regards,
Alim

#1760975

Hi Minesh

Hope you are progressing on the requirement..:-)

Just wanted to update you that I have added a conditional container and put the Purchase Inventory Button and the shortcode in the container.. it will however be visible in the frontend for this post

hidden link

For the other eyewear collections it won't be visible..

While I was doing this I realised that earlier I could always drag a block and move it to the container but now that handle seems to be missing.. is it some update in Toolset? How do I drag and drop a block from one location to another now? Please do advise.. as I had to recreate the Button and the shortcode this time..

Regards,
Alim

#1761011

Hi Minesh

I just thought I could help you a bit by rephrasing the requirement...:-)..

So getting the grandparent might be not so difficult.. so eyewear collection's parent is the brand and the brand owner (brand-distributor) is the grand parent.. however in the relationship brand-distributor-eyewear-brand there could be multiple brand distributors.. because they could be of eyewear-store='in' or eyewear-store='ae' or something else..

I want to ensure details ONLY if the wpv-user-store = eyewear-store... if the user (optician) is from india then i need to connect to the brand distributor who is for india.. if this condition is not met I should have no result...

and once this condition is met, I need 4 variable.. the brand owner's name, id, email and phone number.. so do I need to create 4 different views for this or not is something i was confused about too..

Regards,
Alim

#1762993

Hi Minesh

Any update on this?

Regards,
Alim

#1763531

Jamal
Supporter

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

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

Hello Alim,

As Minesh is on vacation, I would like to continue on this ticket with you. I hope that's fine, otherwise, I can put this ticket on hold until next Monday when Minesh would be back.

According to your reply So getting the grandparent might be not so difficult I understand that the original request of this ticket is done, right?
For support rules, we are able to handle only one issue at the time. This helps us to bring you a better service and also helps other users to find all the information here exposed.

Regarding your last question, I am afraid, I do not understand fully what you would try to do. Can you elaborate more on it?

#1763891

Hi Jamal

No worries.. in fact, I am glad it's you who has been assigned this ticket as it's connected to the support you had provided to me

Here's the connected ticket

https://toolset.com/forums/topic/create-a-relationship-between-brand-and-brandowner-connected-to-a-country/

So if you remember, you helped me to create a relationship between a brand and brand distributor for a specific country. This country is an intermediary post value, the field name is 'eyewear-store' and there's a reason why it's a multiple checkbox.. it's a decision you and I had confirmed as necessary due to the fact that if a brand owner could be a distributor for a brand for multiple countries we had to use the multiple checkbox option

My query in that ticket

so if a brand has a distributor for multiple countries, a SELECT field would not help.. hence the checkbox option.. hope I am doing things right with the checkbox, in this case..

Your response

I just tested my first suggestion on a new install and you were right, we can't connect a Brand and a Brand Owner several times for each country.

That was just to bring to your notice why there's a multiple checkbox field in that relationship..;-).. Also the 'eyewear-store' checkbox has 'in' and 'ae' as two options for now (this would be important for you to understand the requirement of this ticket)

Now coming to the current ticket.
Brand Owner had a child 'Brand' and Brand has a child 'Eyewear Collection'

We are currently in the 'Eyewear Collection Page' which is a Content Template of Eyewear Collections.

So we are able to get the grand parent ie The Brand Owner.. and if you remember in the previous ticket we had the option of multiple distributors in the brand-distributor-eyewear-brand relationship. Now in addition to the multiple distributors, in each distributor we have a multiple checkbox option.

So once we have the grand parents (it could be multiple) we need to check in the eyewear-store field and match the [wpv-user field='wpcf-user-store'] as the user is logged in.. if they match(eyewear-store and user-store) then I need the ids, name, mobile and email of those grand parents..

I need you to advise me if I can get all of those (ids,name,mobile and email) with one loop and then display then one at at time or do I need to loop each time for each of them.

Also it'd help you to know that Minesh has already created a custom code to check if the user-store matches eyewear-store and it's it's stored in the Custom Code section in Toolset Settings.

Do let me know if you need anymore information..:-)..

Have a nice day..:-)..

Regards,
Alim

#1763895

Hi Jamal,

Also I am aware that due to the imperfect method (multiple checkbox) in brand-distributor-eyewear-store of defining the store, I could end up with 2 instead of 1 grand parent (IF I HAD TO MAKE THE MISTAKE OF CHECKING THE SAME EYEWEAR STORE FOR TWO DIFFERENT DISTRIBUTORS).. One distributor can have 2 eyewear stores but 1 eyewear store should not have 2 distributors.. currently due to human error, this could be possible.

I will be careful not to make this mistake.. but in case that does happen, please do advise what happens when you get the id, name, mobile,email of the grand parent.. I would want to have just one distributor's details and not two.. will it prioritise one and send to me or can you throw an error and not get any details..

I'd prefer to NOT get any details IF there are more than ONE distributors with the [eyewear-store] matching the [user-store]

Regards,
Alim

#1764451

Jamal
Supporter

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

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

Hello Alim and thank you for these details, I think, I understand the request better now. But, I need to know, where would you like to pull these data? Are you working on a content template or a view? Can you provide a screenshot?

As soon as I get these details, I'll check it further and see how we can get this.

#1764765

Hi Jamal..

But, I need to know, where would you like to pull these data? Are you working on a content template or a view? Can you provide a screenshot?

This data would appear on the frontend here...

hidden link

And the content temlate for this is here..

hidden link

The Purchase Inventory Button and some shortcode is inside a conditonal field just so that currently they are not visible on all eyewear collection profiles except the link provided to you..

The shortcode is only a reference for you to know that we are able to get the brand distributors name.. As I mentioned to you earlier, if by an error in input by us, we end up with 2 brand distributors for the same country, it should not display anything but an error or NULL..

so coming to where I want this to appear..

The url on clicking the purchase inventory has the following

hidden link field='wpcf-user-store' output='raw'].youandeyemag.com/?
ec-id=[types field='id' output='raw'][/types]
&ec-name= [wpv-post-title]

PLUS SOME MORE FIELDS

some of those fields that you need to help me with are the ones below

&bo-id=[types field='id' @item='brand-distributor-eyewear-brands.parent'][/types]
&bo-name=[types field='organisation-name' @item='brand-distributor-eyewear-brands.parent'][/types]
&bo-email=[types field='notification-email' @item='brand-distributor-eyewear-brands.parent'][/types]
&bo-mobile=[types field='notification-mobile' @item='brand-distributor-eyewear-brands.parent'][/types]

obviously my [types] field are wrong .. I need ONE brand distributor whose [eyewear-store] = [wpv-user field='wpcf-user-store' output='raw'].. if there more than one then it should be NULL..

Do let me know if you need any more details. Would really appreciate if this could be resolved today.. My timezone is GMT +8.00 and I think we have a 9 hours difference between you and me..;-).. I have a presentation on Saturday and I'd like to ensure I have tomorrow's day to test this, if possible.. no pressure.. only if possible..;-)..

Have a nice day..:-)..

Regards,
Alim

#1765021

Jamal
Supporter

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

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

Hello Alim, thank you for this feedback, but there are still some gaps to fill before I fully understand the situation, maybe because some fields are empty and they are not returning anything to test with. At least, we'll need a complete data set to test with, which will include, the user field, the intermediary post values, the parent post values.

For example, we will depend on the value of the following shortcode, but it does not return anything for the current user.

 [wpv-user field='wpcf-user-store' output='raw']

Check the following screenshot, several fields do not have any value, and I can't be sure if what we do is correct or not without having values to test against hidden link

I suggest the following:
- We'll work on a separate content template until get all the data that we need, then we'll take the shortcodes and paste them on the button link of the current Eyewear collection content template. I already created this content template hidden link
- We'll work on a specific post until we got this fixed. We can preview the suggested product with this content template on the following hidden link

Here below the current URL structure, I split everything on a line to be easily readable:

https://
	[wpv-user field='wpcf-user-store' output='raw'].youandeyemag.com/
	?ec-id=[types field='id' output='raw'][/types]
	&ec-name=[wpv-post-title]
	&eb-id=[types field='id' @item='eyewear-brand-eyewear-collection.parent' output='raw'][/types]
	&eb-name=[wpv-post-title @item='eyewear-brand-eyewear-collection.parent']
	&logo=[types field='brand-logo' @item='eyewear-brand-eyewear-collection.parent' output='raw'][/types]
	&ad-banner=[types field='eyewear-brand-banner' @item='eyewear-brand-eyewear-collection.parent' 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=[types field='id' @item='brand-distributor-eyewear-brands.parent'][/types]
	&bo-name=[types field='organisation-name' @item='brand-distributor-eyewear-brands.parent'][/types]
	&bo-email=[types field='notification-email' @item='brand-distributor-eyewear-brands.parent'][/types]
	&bo-mobile=[types field='notification-mobile' @item='brand-distributor-eyewear-brands.parent'][/types]

Please explain to me and provide the expected data for the current product for each of these fields. Please provide the exact expected data. For example, what value do you expect the following shortcode to provide:

&bo-name=[types field='organisation-name' @item='brand-distributor-eyewear-brands.parent'][/types]

For the current eyewear collection "Chopard Men’s Eyewear Collection Spring/Summer 2020", what value would you expect for this shortcode, or at least for this URL param "os-email", and from what post it should be pulled?

Basically, I will be testing with a post, and I need to know what is the exact URL you would expect to have. And why?

#1765025

Hi Jamal

I have all the data for all the other fields..:-)..

i just need for the last 4 which are related to BRand Owner and the grand parent relationship.

Regards,
Alim

#1765027

And I was on another ticket with Waqar

https://toolset.com/forums/topic/adding-a-class-to-button-when-a-certain-condition-is-false/page/2/#post-1765023

where we did lose a lot of time because of 'spaces'.. when we expect a NULL value, there have been times when the loops add in spaces .. so we'll need to be careful there..

Regarding your query about the line below not returning any value..

[wpv-user field='wpcf-user-store' output='raw']

This will return a value only when a user of a particular role is logged in.. I can share the login details with you for this to help you understand.. please provide me private reply option..

Regards,
Alim

#1765029

This would help you understand the URL..

hidden link

This URL has variables similar to what you are working on but it's for a user who is not a logged in user but the URL has variables and the user is taken to another application on clicking on 'Shop Online' button.. This is the output of the URL

hidden link

What you are working on is similar but it's not an optician's page but an eyewear collection page and the variables I need are different.. I hope it's clearer..:-)..

Regards,
Alim

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