Navigation überspringen

[Gelöst] Condition in View that depends on intermediary post

This support ticket is created vor 4 Jahren, 4 Monaten. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 33 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von AlimB3245 vor 4 Jahren, 4 Monaten.

Assistiert von: Minesh.

Author
Artikel
#1745519

Tell us what you are trying to do? I have this VIEW which works fine..

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-item index=other][types field="id" output="raw"][/types],[wpv-item index=last][types field="id" output="raw"][/types]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

This code was provided by Toolset some time back to help me create this list of brand-ids and it was perfect... Since then I have a relationship between eyewear-brands (whose id is output above) and brand-owner... the relationship is many to many with an intermediary post as 'eyewear-store'.. [wpcf-eyewear-store].. it's a 'checkboxes' (multiple choice ) where I could select multiple countries.. the value is 'in' or 'ae'

Now the user who is logged in has this value (in or ae) in its user fields too.. so [wpv-user field='wpcf-user-store'] would give me 'in' or 'ae'..

I want to have a condition where if the logged in user's store 'wpcf-user-store' is IN
THEN
show those brand-ids whose intermediary post custom field 'wpcf-eyewear-store' = IN

I tried it with this but I don't know where to put it..

[wpv-conditional if="( $(wpcf-eyewear-store) eq '[wpv-user field='wpcf-user-store']' )"]

[/wpv-conditional]

Please help... I have a deadline and would appreciate if you could help me with this soon.. I am in timezone GMT +8.00 so I might lose some time due to the time difference.. I hope you are able to provide me some guidance asap..

Here's a link to a post where Jamal helped me set the intermediary post that I am using above...
https://toolset.com/forums/topic/create-a-relationship-between-brand-and-brandowner-connected-to-a-country/

And here's a post that might help as Christian showed me a way on how to filter down a multiple checkboxes in a more efficient way but in that post there was an 'option-0' and 'option-1' part while in the intermediary post there's only 'value to store'..

https://toolset.com/forums/topic/if-condition-for-a-custom-field-with-multiple-checkboxes/

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? versteckter Link

#1745545

In this link
versteckter Link

and in this one
versteckter Link

On hovering over the purchase inventory button the link generated would have a variable 'eb-id' these are the values (brand-ids) that I need displayed only based on the conditions mentioned above..

#1746085

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share access details so I can review your current setup and guide you in the right direction.

Please send me admin user as well as a frontend user for which the user custom field "wpcf-user-store" is set to either in or ae.

#1746395

Minesh
Supporter

Sprachen: Englisch (English )

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

When I try to access the admin URL: versteckter Link
- The above URL redirect me back to the URL: versteckter Link

Can I login to versteckter Link?

#1746401

Hi Minesh

Yes the URL is versteckter Link

I may have given you the wrong one by mistake in the mail earlier.. so please feel free to use.

Regards,
Alim

#1746435

While you are at it, I'll take the chance of putting forward my other related queries

Currently you are trying to get brand-ids from the Brand Owner Profile Content Template..

I'd have this same requirement from Brand Profile Template .. the optician would click on Shop and the brand-ids displayed should be the ones which have a Brand Distributor To Eyewear Brands relationship in the same eyewear-store as the optician's user-store

Now in the Brand Profile you would see some Eyewear Collections which are children of Brands.. so if the optician had to visit an Eyewear Collection Profile, then I'd like to have the Eyewear Collection ID only if the Brand of the Eyewear Collection had the same relationship as above..

Please do advise how I could have these too...

Regards,
Alim

#1746449

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello Alim,

We entertain only one question per ticket. Please open a new ticket with your every new question you may have.

I'm on this page:
=> versteckter Link
- With the button "Purchase Inventory" I see the URL param eb-id with the value 875.

Now, If I go to the user profile here:
=> versteckter Link
And change the "User Store" filed to option "United Arab Amirats" - what value you want to display with the URL param eb-id?

#1746495

No worries I will create another ticket for those questions.. is there a way to ensure that you answer those? I'd like to have you as the responder as you'd be more aware of what I want.. Anyways we'll worry about that later..;-)..

Brand Owner Dr Harmanns has a relationship with Brand Dr Harmann's for IN (India)

and you said the user-store for the opticians is AE (United Arab Emirate).. so the brand-id should not be visible .. it should be blank..

If Dr Harmann's (the brand owner) had any relationship with brands for AE then those brands would be visible to the optician as his user-store is AE..

Regards,
Alim

#1746965

Minesh
Supporter

Sprachen: Englisch (English )

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

I would like to have little more information.

Where I can find the custom field "wpcf-eyewear-store"?

I'm able to locate from where the custom field ID value 875 is coming from:
=> versteckter Link

But I would like to know where I can find the post custom field "wpcf-eyewear-store" that holds the in or ae value?

#1747395

Hi Minesh

Here's the link to where you will find this..

versteckter Link

If you edit any Brand Owner Or Brand you will find it in the Relationship - Brand DistributorTo Eyewear Brand.. it's an intermediary post of this many to many relationship..

Regards,
Alim

#1747587

Minesh
Supporter

Sprachen: Englisch (English )

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

Can you please check now: versteckter Link

I've added the conditional shortcode to your following view as given under:
=> versteckter Link

<wpv-loop>[wpv-conditional if="( '[types field='eyewear-store' output='raw' item='@brand-distributor-eyewear-brand.intermediary'][/types]' eq '[types usermeta='user-store' output='raw' current_user='true'][/types]' )"][types field="id" output="raw"][/types][/wpv-conditional]
 </wpv-loop>

Can you please confirm it works as expected now.

#1748085

Hi Minesh

Even though it seems that the brand id is not being displayed I don't think the condition has be done properly.. because if the same optician (whose user-store = ae) should have seen all 4 brand-ids here..

versteckter Link

as the brand-owner has relationships with brands with intermediary post->eyewear-store = ae too..

Also these brand-ids have to be comma separated .. that's why the earlier code had displayed them with a index -other and index -last or something and a comma in between, I think..

Anyways you know best.. so I'll wait for the re-worked condition.. also please remember to test with a brand owner that has the brand relationship for a brand with both IN and AE selected as it's a checkbox with multiple selection options..

Regards,
Alim

#1748091

Minesh
Supporter

Sprachen: Englisch (English )

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

ok - if you will have multiple IDs I've again adjusted the view conditional statement as given under:
=> versteckter Link

<wpv-loop>
    [wpv-item index=other][wpv-conditional if="( '[types field='eyewear-store' output='raw' item='@brand-distributor-eyewear-brand.intermediary'][/types]' eq '[types usermeta='user-store' output='raw' current_user='true'][/types]' )"][types field="id" output="raw"][/types][/wpv-conditional],[wpv-item index=last][wpv-conditional if="( '[types field='eyewear-store' output='raw' item='@brand-distributor-eyewear-brand.intermediary'][/types]' eq '[types usermeta='user-store' output='raw' current_user='true'][/types]' )"][types field="id" output="raw"][/types][/wpv-conditional]</wpv-loop>

The above adjusted code will work for multiple ids now with comma separated.

#1748093

Please correct me if I am wrong..

what your condition seems to be trying to do is this

if (optician is from IN and if the brand-owner has IN in its ABC relationship)
display brand id/ids

Am I right?

If so, that's not what I am looking for... because this would display NONE or display ALL.. but in fact I want to display SOME or ANY..

My requirement is that there are multiple brand ids that belong to the brand owner.. these brand ids need to be looped and the condition has to be checked with multiple checkbox options and if this condition is met then display the brand id/ids

Do let me know if that is clear..

Regards,
Alim

#1748097

Sorry sent this message before I saw your message.. let me test again and get back to you..