Skip Navigation

[Resolved] introduce only once comon data for productos and works

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)

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 1 year, 5 months ago.

Assisted by: Minesh.

Author
Posts
#2626281

Tell us what you are trying to do?

to only input the data shared once:

1- works will subsist in time -> will be shown ever
2- products are works which are on sale and share all (possible) data with works.

Repeatable fields and price are not possible and not necessary to share between works and products but virtually all other common data of 1&2 should only be inputted once (AS IT IS IDENTICAL).
By analogy product categories/tags should be identical with works categories/tags as works and products are physically the same except that once emphasis is put on showing (web) and the other time it is put on selling(shop)!

3- shows -> must/should show works ever
4- fairs -> must/should show works ever
These are relations one to many or many to many (seems not to be a problem)

Is there any documentation that you are following?

Is there a similar example that we can see?

- Toolset-dashboard
- product: SILENCIO I
- work: SILENCIO I

What is the link to your site?

hidden link

extern3
Let_me_in_2023

#2626629

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Based on the information you shared with your initial post - I do not get yet exactly what exactly you want.

Can you please share brief description about your issue and send me problem URL as well as what post types you have and what post relationship you have and where exactly you stuck. Few screenshots will also help to understand your issue.

Can you please share as much information as you can that should help me to understand your issue first.

#2626809

hi with plain words:

I intend present artworks on website with el "custom post type" WORK (wich will be broadened further on)

All data necessary for "PRODUCTS" of the shop are stated/comprised/stored in the "custom post type" WORK

question : how can I use that data for the "products" in the shop

I hope I have made me understand well

best Ed.

#2626937

Minesh
Supporter

Languages: English (English )

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

As I understand - you have a shop page:
- hidden link

I tried to build the custom archive on your site but it seems you are using modified theme so I do not see the expected result on frontend.

And with your shop page, actually you want to display the posts belongs to post type "Work" instead of product - is that correct?
If yes:
Please check the following doc that shows information about how you can build the custom shop page:
- https://toolset.com/course-lesson/building-a-custom-woocommerce-shop-page/

But when you create a custom shop page, its dedicated to post type "product" that is why I suggest you should create a custom post type archive in legacy view:
- https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

And then create post type archive for product in legacy view:
- https://toolset.com/documentation/legacy-features/views-plugin/creating-wordpress-custom-post-archives/

Also create a view, from Toolset => Views, and create this view to display the post type belongs to work:
- hidden link

And display the above view outside the product archive's loop.

Another solution I can think of is to use "pre_get_posts" standard wordpress hook and check conditionally that if its a shop/product post type archive then you should inject the post type "word" to query. For example:
- You can add the following code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#benefits-of-adding-custom-code-using-toolset

function func_change_product_archive_post_type_to_work($query) {
  if (!is_admin() and is_post_type_archive('product') ) {
    
      $query->set('post_type', array( 'outfit'));
    }
}

add_action('pre_get_posts','func_change_product_archive_post_type_to_work',99,1);

To demonstrate you, Here is a sandbox site:
- hidden link

Here is the custom post archive for product that displays the post link assigned to "product" post type eventually used for shop page:
=> hidden link

The shop page is set as frontpage:
- hidden link
(as you can see now, the shop page that is set as frontpage is showing outfit post type posts instead of product posts )

As you can see I've added the following code to "Custom Code" section:
=> hidden link

function my_filter_func($query) {
  if (!is_admin() and is_post_type_archive('product') ) {
    
      $query->set('post_type', array( 'outfit'));
    }
}

add_action('pre_get_posts','my_filter_func',99,1);

Above code changes the product archive posts to display the "outfit" post type posts.

#2628033

working on it!
will come back (I suppose I will need more advice/help)

#2628045

Minesh
Supporter

Languages: English (English )

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

Ok fine - thank you.